Merge pull request #5 from leomurca/feature/display_app_version

Display app version at footer
This commit is contained in:
Leonardo Murça 2022-11-27 12:37:19 -03:00 committed by GitHub
commit 697d69ac68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 49 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "embroidery-viewer", "name": "embroidery-viewer",
"private": true, "private": true,
"version": "0.0.0", "version": "1.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View file

@ -1,28 +1,22 @@
<script> <script>
import SvelteSeo from "svelte-seo"; import SvelteSeo from "svelte-seo";
import FileViewer from "./lib/FileViewer.svelte"; import FileViewer from "./lib/FileViewer.svelte";
import MediaQuery from "./lib/MediaQuery.svelte";
import logo from "./assets/embroidery-viewer-logo.webp";
import logoMobile from "./assets/embroidery-viewer-logo-mobile.webp";
import thumbnail from "./assets/thumbnail.webp"; import thumbnail from "./assets/thumbnail.webp";
import Footer from "./lib/Footer.svelte";
import Header from "./lib/Header.svelte";
function configsFor(matches) { const title = "Embroidery Viewer";
return matches const description = "A free online tool to view embroidery files.";
? { src: logoMobile, width: 350, height: 96 } const keywords =
: { src: logo, width: 460, height: 200 }; "Free Emrbroidery Viewer, embroidery design, sewing machine, preview .pes files, preview embroider designs, brother machine.";
}
</script> </script>
<SvelteSeo <SvelteSeo {title} {description} {keywords} />
title="Embroidery Viewer"
description="A free online tool to view embroidery files."
keywords="Free Emrbroidery Viewer, embroidery design, sewing machine, preview .pes files, preview embroider designs, brother machine."
/>
<SvelteSeo <SvelteSeo
openGraph={{ openGraph={{
title: "Embroidery Viewer", title,
description: "A free online tool to view embroidery files.", description,
url: "https://embroideryviewer.xyz/", url: "https://embroideryviewer.xyz/",
type: "website", type: "website",
images: [ images: [
@ -36,37 +30,13 @@
}} }}
/> />
<header> <Header />
<a href="/">
<MediaQuery query="(min-width: 481px) and (max-width: 812px)" let:matches>
{@const configs = configsFor(matches)}
<img
class="logo"
alt="Embroidery viewer logo."
src={configs.src}
width={configs.width}
height={configs.height}
/>
</MediaQuery>
</a>
</header>
<main> <main>
<FileViewer /> <FileViewer />
</main> </main>
<footer> <Footer />
<p>
Copyright © 2022 <a
href="https://leomurca.xyz"
target="_blank"
rel="noreferrer">Leonardo Murça</a
>.
</p>
</footer>
<style> <style>
.logo {
background-image: logo;
}
main { main {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -75,11 +45,4 @@
box-sizing: border-box; box-sizing: border-box;
padding: 15px; padding: 15px;
} }
@media only screen and (max-device-width: 812px) {
.logo {
width: 100%;
padding: 20px;
}
}
</style> </style>

25
src/lib/Footer.svelte Normal file
View file

@ -0,0 +1,25 @@
<script>
import { appVersion } from "../utils/env";
</script>
<footer>
<p>
Copyright © 2022 <a
href="https://leomurca.xyz"
target="_blank"
rel="noreferrer">Leonardo Murça</a
>.
</p>
<p>
version: {appVersion()}
</p>
</footer>
<style>
footer {
bottom: 0;
}
p {
text-align: center;
}
</style>

39
src/lib/Header.svelte Normal file
View file

@ -0,0 +1,39 @@
<script>
import MediaQuery from "../lib/MediaQuery.svelte";
import logo from "../assets/embroidery-viewer-logo.webp";
import logoMobile from "../assets/embroidery-viewer-logo-mobile.webp";
const configsFor = (matches) => {
return matches
? { src: logoMobile, width: 350, height: 96 }
: { src: logo, width: 460, height: 200 };
};
</script>
<header>
<a href="/">
<MediaQuery query="(min-width: 481px) and (max-width: 812px)" let:matches>
{@const configs = configsFor(matches)}
<img
class="logo"
alt="Embroidery viewer logo."
src={configs.src}
width={configs.width}
height={configs.height}
/>
</MediaQuery>
</a>
</header>
<style>
.logo {
background-image: logo;
}
@media only screen and (max-device-width: 812px) {
.logo {
width: 100%;
padding: 20px;
}
}
</style>

6
src/utils/env.js Normal file
View file

@ -0,0 +1,6 @@
// @ts-nocheck
function appVersion() {
return APP_VERSION;
}
export { appVersion };

View file

@ -4,4 +4,7 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [svelte()], plugins: [svelte()],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
},
}); });