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",
"private": true,
"version": "0.0.0",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",

View file

@ -1,28 +1,22 @@
<script>
import SvelteSeo from "svelte-seo";
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 Footer from "./lib/Footer.svelte";
import Header from "./lib/Header.svelte";
function configsFor(matches) {
return matches
? { src: logoMobile, width: 350, height: 96 }
: { src: logo, width: 460, height: 200 };
}
const title = "Embroidery Viewer";
const description = "A free online tool to view embroidery files.";
const keywords =
"Free Emrbroidery Viewer, embroidery design, sewing machine, preview .pes files, preview embroider designs, brother machine.";
</script>
<SvelteSeo
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 {title} {description} {keywords} />
<SvelteSeo
openGraph={{
title: "Embroidery Viewer",
description: "A free online tool to view embroidery files.",
title,
description,
url: "https://embroideryviewer.xyz/",
type: "website",
images: [
@ -36,37 +30,13 @@
}}
/>
<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>
<Header />
<main>
<FileViewer />
</main>
<footer>
<p>
Copyright © 2022 <a
href="https://leomurca.xyz"
target="_blank"
rel="noreferrer">Leonardo Murça</a
>.
</p>
</footer>
<Footer />
<style>
.logo {
background-image: logo;
}
main {
display: flex;
flex-direction: column;
@ -75,11 +45,4 @@
box-sizing: border-box;
padding: 15px;
}
@media only screen and (max-device-width: 812px) {
.logo {
width: 100%;
padding: 20px;
}
}
</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/
export default defineConfig({
plugins: [svelte()],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
},
});