explorata/src/App.vue

155 lines
3.1 KiB
Vue
Raw Normal View History

2022-01-08 13:12:15 +01:00
<template>
<div id="main">
<h1 id="main-title">
<span id="burger-toggle" @click="toggleMainMenu">{{
mainMenu == true ? "▼" : "☰"
}}</span>
Cellular Automata Explorer
</h1>
<div id="container">
<MainMenu v-if="mainMenu || windowWidth >= 800" />
<CanvasBoard />
</div>
2022-12-04 17:24:45 +01:00
<MenuReset row-title="" />
2022-01-08 13:12:15 +01:00
</div>
</template>
<script>
2022-12-02 15:53:49 +01:00
import MainMenu from "./components/MainMenu.vue";
import CanvasBoard from "./components/CanvasBoard.vue";
2022-12-04 17:24:45 +01:00
import MenuReset from "./components/MenuReset.vue";
import { mapState, mapWritableState, mapActions } from "pinia";
import { globalStore } from "./stores/index.js";
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
export default {
name: "App",
components: {
MainMenu,
2022-12-04 17:24:45 +01:00
MenuReset,
2022-12-02 15:53:49 +01:00
CanvasBoard,
},
data() {
return {
windowWidth: window.innerWidth,
};
},
computed: {
...mapState(globalStore, ["mainMenu", "activeSubMenu"]),
...mapWritableState(globalStore, ["canvasWidth", "canvasHeight"]),
},
mounted() {
this.$nextTick(() => {
window.addEventListener("resize", this.onResize);
});
},
beforeUnmount() {
window.removeEventListener("resize", this.onResize);
},
methods: {
...mapActions(globalStore, [
"setBoardWidth",
"setBoardHeight",
"setMainMenu",
]),
toggleMainMenu() {
this.setMainMenu(!this.mainMenu);
},
onResize() {
this.$nextTick(() => {
this.windowWidth = window.innerWidth;
this.canvasWidth = window.innerWidth;
this.canvasHeight = window.innerHeight;
this.setBoardWidth();
this.setBoardHeight();
});
},
},
2022-12-02 15:53:49 +01:00
};
2022-01-08 13:12:15 +01:00
</script>
<style scope>
2022-12-04 16:08:56 +01:00
:root {
--dark1: #000000;
--dark2: #333333;
--dark3: #666666;
--light1: #999999;
--light2: #cccccc;
--light3: #eeeeee;
}
2022-12-02 15:53:49 +01:00
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
/* color: #2c3e50; */
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
* {
margin: 0;
padding: 0;
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
body {
2022-12-04 16:08:56 +01:00
background: var(--dark1);
color: var(--light3);
2022-12-02 15:53:49 +01:00
font-family: Courier New;
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
canvas {
flex: auto;
2022-12-04 16:08:56 +01:00
background: rgb(0, 0, 0);
background: linear-gradient(
90deg,
rgba(0, 0, 0, 1) 0%,
rgba(131, 131, 131, 1) 52%,
rgba(0, 0, 0, 1) 100%
);
2022-12-02 15:53:49 +01:00
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
h1,
h2 {
font-weight: bold;
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
h1 {
margin: 10px auto;
font-size: larger;
text-transform: uppercase;
2022-12-02 15:53:49 +01:00
}
2022-01-08 13:12:15 +01:00
2022-12-02 15:53:49 +01:00
#container {
display: flex;
height: calc(100vh - 100px);
overflow: hidden;
flex-direction: column;
}
#burger-toggle {
display: none;
cursor: pointer;
font-size: 1.5em;
vertical-align: middle;
2022-12-04 16:08:56 +01:00
color: var(--light2);
}
@media screen and (max-width: 800px) {
h1 {
font-size: medium;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 10px;
}
#burger-toggle {
display: inline;
}
#main-menu {
2022-12-04 16:08:56 +01:00
background: var(--dark2);
margin: 0 auto;
}
2022-12-02 15:53:49 +01:00
}
2022-01-08 13:12:15 +01:00
</style>