Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show build info on home page #347

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"globals": {
"process": true
},
"plugins": ["jest", "prettier"],
"rules": {
"max-len": ["error", 80],
Expand Down
2 changes: 2 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default [
preventAssignment: true,
/* workaround for missing env variable */
"process.env.NODE_ENV": JSON.stringify("production"),
"process.env.APP_VERSION": JSON.stringify(pkg.version),
"process.env.BUILD_DATE": JSON.stringify(new Date().toISOString()),
}),
babel({ exclude: "node_modules/**", babelHelpers: "bundled" }),
],
Expand Down
9 changes: 9 additions & 0 deletions src/css/tales.css
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ label.range input {
flex-direction: column;
width: 40rem;
max-width: 90%;
min-height: 100vh;
margin: 0 auto;
}

Expand Down Expand Up @@ -456,6 +457,14 @@ label.range input {
flex: 1 1 auto;
}

#home footer {
margin-top: auto;
padding: 1rem 0;
text-align: center;
font-size: var(--font-size-small);
font-style: italic;
}

#editor {
display: flex;
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/js/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { uploader } from "./upload";
import { slideBounds } from "./slide-bounds";
import { settings } from "../settings";
import { normalizeRect } from "../util/geometry";
import i18n from "../i18n";
import { i18n } from "../i18n";

/**
* The speed in which the editor zoom level changes when the user zooms in/out.
Expand Down
2 changes: 1 addition & 1 deletion src/js/editor/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connect, trigger, withInputSignals } from "flyps";
import { h } from "flyps-dom-snabbdom";
import { intersectRects, padRect } from "../util/geometry";
import * as previewMove from "./preview-move";
import i18n from "../i18n";
import { i18n } from "../i18n";

export function previewRect(
rect,
Expand Down
2 changes: 1 addition & 1 deletion src/js/editor/upload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { signal, trigger } from "flyps";
import { h } from "flyps-dom-snabbdom";
import i18n from "../i18n";
import { i18n } from "../i18n";

let dropTarget = signal();

Expand Down
1 change: 1 addition & 0 deletions src/js/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"home.tale-name-prompt": "Gib einen Namen für deine Geschichte ein",
"home.build-info": "Version %{version} (%{buildDate})",

"editor.unwritten-tale": "Eine ungeschriebene Geschichte…",
"editor.tell": "Erzählen",
Expand Down
1 change: 1 addition & 0 deletions src/js/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"home.tale-name-prompt": "Enter the name of your tale",
"home.build-info": "Version %{version} (%{buildDate})",

"editor.unwritten-tale": "An unwritten tale…",
"editor.tell": "Tell",
Expand Down
7 changes: 6 additions & 1 deletion src/js/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ const polyglot = new Polyglot({
});

export const i18n = (...args) => polyglot.t(...args);
export default i18n;

export const dateFormatter = new Intl.DateTimeFormat(language, {
year: "numeric",
month: "2-digit",
day: "2-digit",
});
15 changes: 13 additions & 2 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "./slide";
import { editor } from "./editor/index";
import { presenter } from "./presenter/index";
import * as router from "./router";
import i18n from "./i18n/index";
import { i18n, dateFormatter } from "./i18n/index";
import { arrowRight } from "./icons";

handler(
Expand Down Expand Up @@ -97,6 +97,17 @@ let taleList = withInputSignals(
tales => h("ul.tale-list", tales.map(taleItem)),
);

connector("app/version", () => process.env.APP_VERSION || "dev");
connector("app/build-date", () =>
dateFormatter.format(new Date(process.env.BUILD_DATE)),
);

let footer = () => {
const version = connect("app/version").value();
const buildDate = connect("app/build-date").value();
return h("footer", i18n("home.build-info", { version, buildDate }));
};

let home = () => {
let onKeydown = e => {
switch (e.which) {
Expand Down Expand Up @@ -139,8 +150,8 @@ let home = () => {
arrowRight(),
),
]),

taleList(),
footer(),
]);
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/presenter/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h } from "flyps-dom-snabbdom";

import { viewport } from "../viewport";
import i18n from "../i18n";
import { i18n } from "../i18n";

const notFound = () => h("div", i18n("editor.unwritten-tale"));

Expand Down
2 changes: 1 addition & 1 deletion src/js/settings/export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h } from "flyps-dom-snabbdom";
import { connect, trigger, withInputSignals } from "flyps";
import i18n from "../i18n";
import { i18n } from "../i18n";

/**
* Export of a Tale as self-contained HTML file.
Expand Down
2 changes: 1 addition & 1 deletion src/js/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../util/effects";
import { posterDimSetting } from "./poster";
import { themeSetting } from "./theme";
import { transitionSettings } from "./transition";
import i18n from "../i18n";
import { i18n } from "../i18n";
import { exportSettings } from "./export";

const DEFAULT_SETTINGS = {
Expand Down
2 changes: 1 addition & 1 deletion src/js/settings/poster.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
trigger,
withInputSignals,
} from "flyps";
import i18n from "../i18n";
import { i18n } from "../i18n";

/**
* Settings for the poster in the editor.
Expand Down
2 changes: 1 addition & 1 deletion src/js/settings/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
trigger,
withInputSignals,
} from "flyps";
import i18n from "../i18n";
import { i18n } from "../i18n";

/**
* The application UI theme (light/dark).
Expand Down
2 changes: 1 addition & 1 deletion src/js/settings/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect, handler, signal, trigger, withInputSignals } from "flyps";
import { easingAnimator } from "../animation";
import { vec3 } from "gl-matrix";
import { DEFAULT_SLIDE_TRANSITION_DURATION } from "../config";
import i18n from "../i18n";
import { i18n } from "../i18n";

/**
* Possible values (in ms) for transition duration setting.
Expand Down