add version to the about component

This commit is contained in:
Yanick Champoux 2022-04-17 12:59:37 -04:00
parent 156330c990
commit 78af4eac28
3 changed files with 35 additions and 32 deletions

View File

@ -1,5 +1,9 @@
<Card> <Card>
<h2 slot="header">Welcome to the docks</h2> <div slot="header" class="header">
<h2>Welcome to the docks</h2>
<p class="version">version {import.meta.env.PACKAGE_VERSION}</p>
</div>
<p> <p>
This app is a ship builder for the game This app is a ship builder for the game
@ -25,47 +29,30 @@
Written by Written by
<a href="https://twitter.com/yenzie">Yanick Champoux</a> <a href="https://twitter.com/yenzie">Yanick Champoux</a>
. Code available on . Code available on
<a href="https://github.com/aotds/aotds-shipyard">Github</a> <a href="https://github.com/aotds/aotds-shipyard">Github</a>.
</p> </p>
<div slot="footer" />
</Card> </Card>
<script> <script>
import { import { Modal, Card } from "svelte-chota";
Modal, Card
} from 'svelte-chota';
</script> </script>
<style> <style>
h2 { h2 {
margin-bottom: 1em;
font-size: var(--font-scale-14); font-size: var(--font-scale-14);
font-family: Faktos; font-family: Faktos;
margin-bottom: 0px;
} }
aside { .header {
background-color: rgb(254, 218, 184); margin-bottom: 1em;
position: absolute; display: flex;
height: 20em; align-items: baseline;
max-width: 50%;
z-index: 200;
padding: 1em;
border: 3px solid var(--indigo-dye);
border-radius: 1em;
left: 0px;
border-left: 0px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
top: 6em;
font-size: var(--font-scale-11);
}
h3 {
text-align: center;
margin: 0px;
} }
p { p {
margin-left: 2em; margin-left: 2em;
} }
.version {
flex: 1;
text-align: right;
}
</style> </style>

View File

@ -0,0 +1,11 @@
import { test, expect } from "vitest";
import { render } from "@testing-library/svelte";
import About from "./About.svelte";
test("version is present", () => {
import.meta.env.PACKAGE_VERSION = '1.2.3';
const { queryByText } = render(About);
expect(queryByText(/version 1.2.3/)).toBeTruthy();
});

View File

@ -8,6 +8,11 @@ export default {
adapter: adapter({ fallback: "index.html" }), adapter: adapter({ fallback: "index.html" }),
paths: { base: dev ? "" : "/aotds-docks" }, paths: { base: dev ? "" : "/aotds-docks" },
vite: { vite: {
define: {
"import.meta.env.PACKAGE_VERSION": JSON.stringify(
process.env.npm_package_version
),
},
build: { build: {
rollupOptions: { rollupOptions: {
plugins: [analyze()], plugins: [analyze()],