Profectus-Demo/src/App.vue

72 lines
2 KiB
Vue
Raw Normal View History

2021-05-19 17:21:51 -05:00
<template>
2023-05-16 23:38:31 -05:00
<div v-if="appErrors.length > 0" class="error-container" :style="theme"><Error :errors="appErrors" /></div>
<template v-else>
<div id="modal-root" :style="theme" />
<div class="app" :style="theme" :class="{ useHeader }">
<Nav v-if="useHeader" />
<Game />
<TPS v-if="unref(showTPS)" />
<GameOverScreen />
<NaNScreen />
<component :is="gameComponent" />
</div>
</template>
2021-05-19 17:21:51 -05:00
</template>
2022-03-19 23:59:52 -05:00
<script setup lang="tsx">
2023-05-16 23:38:31 -05:00
import "@fontsource/roboto-mono";
import Error from "components/Error.vue";
2022-03-19 23:59:52 -05:00
import { jsx } from "features/feature";
2023-05-16 23:38:31 -05:00
import state from "game/state";
2022-03-19 23:59:52 -05:00
import { coerceComponent, render } from "util/vue";
import { CSSProperties } from "vue";
import { computed, toRef, unref } from "vue";
2022-02-27 16:04:56 -06:00
import Game from "./components/Game.vue";
import GameOverScreen from "./components/GameOverScreen.vue";
import NaNScreen from "./components/NaNScreen.vue";
import Nav from "./components/Nav.vue";
import TPS from "./components/TPS.vue";
import projInfo from "./data/projInfo.json";
import themes from "./data/themes";
2022-03-19 23:59:52 -05:00
import settings, { gameComponents } from "./game/settings";
import "./main.css";
const useHeader = projInfo.useHeader;
const theme = computed(() => themes[settings.theme].variables as CSSProperties);
2022-01-13 22:25:47 -06:00
const showTPS = toRef(settings, "showTPS");
2023-05-16 23:38:31 -05:00
const appErrors = toRef(state, "errors");
2022-03-19 23:59:52 -05:00
const gameComponent = computed(() => {
return coerceComponent(jsx(() => (<>{gameComponents.map(render)}</>)));
2022-03-19 23:59:52 -05:00
});
2021-05-19 17:21:51 -05:00
</script>
2021-06-11 23:38:16 -05:00
<style scoped>
2021-07-24 17:08:52 -05:00
.app {
background-color: var(--background);
2021-09-04 16:51:41 -05:00
color: var(--foreground);
display: flex;
flex-flow: column;
min-height: 100%;
height: 100%;
2021-07-24 17:08:52 -05:00
}
#modal-root {
position: absolute;
min-height: 100%;
height: 100%;
2023-02-20 21:42:18 -06:00
color: var(--foreground);
}
2023-05-16 23:38:31 -05:00
.error-container {
background: var(--background);
overflow: auto;
width: 100%;
height: 100%;
}
.error-container > .error {
position: static;
}
2021-05-19 17:21:51 -05:00
</style>