@emberbox/ui 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +9 -9
  2. package/dist/vite/logo.d.ts +3 -4
  3. package/dist/vite/logo.js +15 -16
  4. package/dist/vite/prerender.d.ts +17 -0
  5. package/dist/vite/prerender.js +57 -0
  6. package/dist/vite.d.ts +24 -24
  7. package/dist/vite.js +46 -46
  8. package/package.json +6 -6
  9. package/src/build-info.ts +23 -0
  10. package/src/clipboard.ts +34 -0
  11. package/src/components/AppFooter.vue +66 -0
  12. package/src/{komponenten/AppKopf.vue → components/AppHeader.vue} +13 -13
  13. package/src/components/CodeDisplay.vue +78 -0
  14. package/src/components/ConfirmDialog.vue +25 -0
  15. package/src/{komponenten → components}/EmberboxApp.vue +4 -4
  16. package/src/{komponenten/HilfeMockup.vue → components/HelpMockup.vue} +3 -3
  17. package/src/components/HelpPage.vue +16 -0
  18. package/src/components/HelpSection.vue +11 -0
  19. package/src/components/HelpTopic.vue +20 -0
  20. package/src/{komponenten/NeueFassung.vue → components/NewBuildBanner.vue} +8 -8
  21. package/src/composables/useConfirm.ts +27 -0
  22. package/src/composables/useNewBuild.ts +45 -0
  23. package/src/composables/usePolling.ts +55 -57
  24. package/src/create-app.ts +11 -0
  25. package/src/index.ts +22 -21
  26. package/src/page.ts +81 -0
  27. package/src/prerender.ts +23 -0
  28. package/src/{stil.css → style.css} +58 -58
  29. package/src/urls.ts +8 -0
  30. package/src/vite/logo.ts +16 -17
  31. package/src/vite/prerender.ts +72 -0
  32. package/src/vite.ts +55 -55
  33. package/dist/vite/vorrendern.d.ts +0 -17
  34. package/dist/vite/vorrendern.js +0 -57
  35. package/src/adressen.ts +0 -8
  36. package/src/app.ts +0 -11
  37. package/src/composables/useNeueFassung.ts +0 -45
  38. package/src/composables/useRueckfrage.ts +0 -27
  39. package/src/fassung.ts +0 -23
  40. package/src/komponenten/AppFuss.vue +0 -58
  41. package/src/komponenten/CodeAnzeige.vue +0 -79
  42. package/src/komponenten/HilfeAbschnitt.vue +0 -11
  43. package/src/komponenten/HilfeSeite.vue +0 -16
  44. package/src/komponenten/HilfeThema.vue +0 -20
  45. package/src/komponenten/Rueckfrage.vue +0 -24
  46. package/src/seite.ts +0 -81
  47. package/src/vite/vorrendern.ts +0 -72
  48. package/src/vorrendern.ts +0 -24
  49. package/src/zwischenablage.ts +0 -34
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # @emberbox/ui
2
2
 
3
- Gemeinsamer Stil und gemeinsame Bausteine der [Emberbox](https://emberbox.app)-Werkzeuge für
4
- Ausbildung und Übung in der Feuerwehr. Baut auf [Nuxt UI](https://ui.nuxt.com) auf und bringt
5
- dessen Komponenten im Emberbox-Stil mit, dazu Kopf, Fuß, Code-Anzeige, Rückfragen, Hilfe-Seiten,
6
- SEO und Vorrendern.
3
+ Shared look and building blocks of the [Emberbox](https://emberbox.app) tools for fire brigade
4
+ training and exercises. Built on [Nuxt UI](https://ui.nuxt.com), it brings Nuxt UI's components in
5
+ the Emberbox style, plus header, footer, code display, confirmation dialogs, help pages, SEO and
6
+ prerendering. The components' texts are German.
7
7
 
8
8
  ```sh
9
9
  npm install @emberbox/ui
10
10
  ```
11
11
 
12
- Einrichtung und Beispiele stehen im
13
- [README des Repositorys](https://github.com/rainbowdashlabs/emberbox#readme).
12
+ Setup and examples are in the
13
+ [repository README](https://github.com/rainbowdashlabs/emberbox#readme).
14
14
 
15
- ## Lizenz
15
+ ## License
16
16
 
17
- MIT. Die Piktogramme der Logos in `logos/` stammen aus [Lucide](https://lucide.dev) (ISC); beide
18
- Lizenztexte stehen in `LICENSE`.
17
+ MIT. The logo pictograms in `logos/` come from [Lucide](https://lucide.dev) (ISC); both license
18
+ texts are in `LICENSE`.
@@ -1,9 +1,8 @@
1
1
  import type { Plugin } from 'vite';
2
- /** Die Werkzeuge, für die `@emberbox/ui` ein Logo mitbringt. */
2
+ /** The tools for which `@emberbox/ui` ships a logo. */
3
3
  export type Logo = 'emberbox' | 'alarmzettel' | 'statussim' | 'calltaker';
4
4
  /**
5
- * Liefert das Logo eines Werkzeugs als `favicon.svg`, `apple-touch-icon.png` und `logo-512.png`
6
- * im Wurzelverzeichnis aus, im Entwicklungsserver wie im Build, und verlinkt die ersten beiden im
7
- * Kopf jeder Seite.
5
+ * Serves a tool's logo as `favicon.svg`, `apple-touch-icon.png` and `logo-512.png` at the root, in
6
+ * the dev server as in the build, and links the first two in the head of every page.
8
7
  */
9
8
  export declare function logoPlugin(logo: Logo): Plugin;
package/dist/vite/logo.js CHANGED
@@ -1,39 +1,38 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  const LOGOS = fileURLToPath(new URL('../../logos/', import.meta.url));
4
- /** Welche Datei unter welchem Namen im Wurzelverzeichnis des Werkzeugs liegt. */
5
- function dateien(logo) {
4
+ const CONTENT_TYPES = { svg: 'image/svg+xml', png: 'image/png' };
5
+ /** Which file is served under which name at the tool's root. */
6
+ function logoFiles(logo) {
6
7
  return {
7
8
  'favicon.svg': `${LOGOS}${logo}.svg`,
8
9
  'apple-touch-icon.png': `${LOGOS}${logo}-180.png`,
9
10
  'logo-512.png': `${LOGOS}${logo}-512.png`,
10
11
  };
11
12
  }
12
- const TYPEN = { svg: 'image/svg+xml', png: 'image/png' };
13
13
  /**
14
- * Liefert das Logo eines Werkzeugs als `favicon.svg`, `apple-touch-icon.png` und `logo-512.png`
15
- * im Wurzelverzeichnis aus, im Entwicklungsserver wie im Build, und verlinkt die ersten beiden im
16
- * Kopf jeder Seite.
14
+ * Serves a tool's logo as `favicon.svg`, `apple-touch-icon.png` and `logo-512.png` at the root, in
15
+ * the dev server as in the build, and links the first two in the head of every page.
17
16
  */
18
17
  export function logoPlugin(logo) {
19
- const liste = dateien(logo);
18
+ const files = logoFiles(logo);
20
19
  return {
21
20
  name: 'emberbox:logo',
22
21
  configureServer(server) {
23
- server.middlewares.use((anfrage, antwort, weiter) => {
24
- const name = anfrage.url?.split('?')[0]?.slice(1) ?? '';
25
- const datei = liste[name];
26
- if (!datei)
27
- return weiter();
28
- antwort.setHeader('Content-Type', TYPEN[name.split('.').pop() ?? ''] ?? 'application/octet-stream');
29
- antwort.end(readFileSync(datei));
22
+ server.middlewares.use((request, response, next) => {
23
+ const name = request.url?.split('?')[0]?.slice(1) ?? '';
24
+ const file = files[name];
25
+ if (!file)
26
+ return next();
27
+ response.setHeader('Content-Type', CONTENT_TYPES[name.split('.').pop() ?? ''] ?? 'application/octet-stream');
28
+ response.end(readFileSync(file));
30
29
  });
31
30
  },
32
31
  generateBundle() {
33
32
  if (this.environment?.config.build.ssr)
34
33
  return;
35
- for (const [name, datei] of Object.entries(liste)) {
36
- this.emitFile({ type: 'asset', fileName: name, source: readFileSync(datei) });
34
+ for (const [name, file] of Object.entries(files)) {
35
+ this.emitFile({ type: 'asset', fileName: name, source: readFileSync(file) });
37
36
  }
38
37
  },
39
38
  transformIndexHtml: () => [
@@ -0,0 +1,17 @@
1
+ import { type Plugin } from 'vite';
2
+ /** Which pages of a tool become finished HTML at build time. */
3
+ export interface PrerenderOptions {
4
+ /** Module that exports `render(path, template)`, such as `src/prerender.ts`. */
5
+ entry: string;
6
+ /** The public paths, such as `['/', '/hilfe']`. */
7
+ paths: string[];
8
+ }
9
+ /** The directory below the build output that holds the prerendered pages. */
10
+ export declare const PAGES_DIR = "pages";
11
+ /**
12
+ * Prerenders the public pages once the client build is written. It builds the entry as an SSR
13
+ * bundle, calls `render` for every path with the built `index.html` as template and writes the
14
+ * result to `pages/<path>/index.html`. `index.html` itself stays the empty shell for all other
15
+ * routes. `sitemap.xml` and `robots.txt` are written next to it.
16
+ */
17
+ export declare function prerenderPlugin(options: PrerenderOptions, url: string): Plugin;
@@ -0,0 +1,57 @@
1
+ import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { basename, extname, join, resolve } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { build } from 'vite';
5
+ /** The directory below the build output that holds the prerendered pages. */
6
+ export const PAGES_DIR = 'pages';
7
+ function pageFile(outDir, path) {
8
+ return join(outDir, PAGES_DIR, path.replace(/^\/+|\/+$/g, ''), 'index.html');
9
+ }
10
+ function sitemap(url, paths) {
11
+ const entries = paths.map(path => ` <url><loc>${url}${path}</loc></url>`).join('\n');
12
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`;
13
+ }
14
+ /**
15
+ * Prerenders the public pages once the client build is written. It builds the entry as an SSR
16
+ * bundle, calls `render` for every path with the built `index.html` as template and writes the
17
+ * result to `pages/<path>/index.html`. `index.html` itself stays the empty shell for all other
18
+ * routes. `sitemap.xml` and `robots.txt` are written next to it.
19
+ */
20
+ export function prerenderPlugin(options, url) {
21
+ let config;
22
+ return {
23
+ name: 'emberbox:prerender',
24
+ apply: 'build',
25
+ configResolved(resolved) {
26
+ config = resolved;
27
+ },
28
+ async writeBundle() {
29
+ if (config.build.ssr)
30
+ return;
31
+ const outDir = resolve(config.root, config.build.outDir);
32
+ const ssrOutDir = resolve(config.root, 'node_modules', '.emberbox-prerender');
33
+ await build({
34
+ configFile: config.configFile,
35
+ root: config.root,
36
+ mode: config.mode,
37
+ logLevel: 'warn',
38
+ build: { ssr: options.entry, outDir: ssrOutDir, emptyOutDir: true, copyPublicDir: false },
39
+ });
40
+ const name = basename(options.entry, extname(options.entry));
41
+ const bundle = readdirSync(ssrOutDir).find(candidate => /^(.+)\.m?js$/.exec(candidate)?.[1] === name);
42
+ if (!bundle)
43
+ throw new Error(`The SSR bundle of ${options.entry} is missing in ${ssrOutDir}.`);
44
+ const entry = await import(pathToFileURL(join(ssrOutDir, bundle)).href);
45
+ const template = readFileSync(join(outDir, 'index.html'), 'utf8');
46
+ for (const path of options.paths) {
47
+ const target = pageFile(outDir, path);
48
+ mkdirSync(join(target, '..'), { recursive: true });
49
+ writeFileSync(target, await entry.render(path, template));
50
+ }
51
+ writeFileSync(join(outDir, 'sitemap.xml'), sitemap(url, options.paths));
52
+ writeFileSync(join(outDir, 'robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${url}/sitemap.xml\n`);
53
+ rmSync(ssrOutDir, { recursive: true, force: true });
54
+ config.logger.info(`emberbox: prerendered ${options.paths.length} pages`);
55
+ },
56
+ };
57
+ }
package/dist/vite.d.ts CHANGED
@@ -1,39 +1,39 @@
1
1
  import type { NuxtUIOptions } from '@nuxt/ui/unplugin';
2
2
  import type { PluginOption } from 'vite';
3
3
  import { type Logo } from './vite/logo.js';
4
- import { type VorrendernOptionen } from './vite/vorrendern.js';
5
- export { SEITEN_VERZEICHNIS, type VorrendernOptionen } from './vite/vorrendern.js';
4
+ import { type PrerenderOptions } from './vite/prerender.js';
5
+ export { PAGES_DIR, type PrerenderOptions } from './vite/prerender.js';
6
6
  export type { Logo } from './vite/logo.js';
7
- /** Einstellungen, mit denen ein Werkzeug `emberbox()` an seine Lage anpasst. */
8
- export interface EmberboxOptionen {
9
- /** `false` für Werkzeuge ohne vue-router; Links werden dann als einfache Anker gerendert. */
7
+ /** Settings a tool passes to `emberbox()`. */
8
+ export interface EmberboxOptions {
9
+ /** `false` for tools without vue-router; links are then rendered as plain anchors. */
10
10
  router?: boolean;
11
- /** Zusätzliche Nuxt-UI-Einstellungen des Werkzeugs, die über die Emberbox-Vorgaben gelegt werden. */
11
+ /** Additional Nuxt UI settings of the tool, applied on top of the Emberbox defaults. */
12
12
  ui?: NuxtUIOptions['ui'];
13
- /** Die öffentliche Adresse, etwa `https://calltaker.emberbox.app`; ein `/` am Ende fällt weg. */
14
- adresse?: string;
15
- /** Welches Emberbox-Logo als Favicon, Touch-Icon und Vorschaubild ausgeliefert wird. */
13
+ /** The public address, such as `https://calltaker.emberbox.app`; a trailing `/` is dropped. */
14
+ url?: string;
15
+ /** Which Emberbox logo is served as favicon, touch icon and preview image. */
16
16
  logo?: Logo;
17
- /** Welche öffentlichen Seiten beim Bauen vorgerendert werden; braucht `adresse`. */
18
- vorrendern?: VorrendernOptionen;
17
+ /** Which public pages are prerendered at build time; needs `url`. */
18
+ prerender?: PrerenderOptions;
19
19
  }
20
20
  /**
21
- * Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
22
- * stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
21
+ * The icons of the `@emberbox/ui` components. The scan does not walk `node_modules`, so they are
22
+ * listed here; whoever gives a component an icon adds it here.
23
23
  */
24
- export declare const EIGENE_ICONS: string[];
24
+ export declare const OWN_ICONS: string[];
25
25
  /**
26
- * Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
27
- * denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
26
+ * Sets the class `dark` before the first paint, so the page does not flash light. Reads the same
27
+ * key as Nuxt UI's colour mode (`useDark` from VueUse) and follows the system without a choice.
28
28
  */
29
- export declare const FARBMODUS_SKRIPT = "(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()";
29
+ export declare const COLOR_MODE_SCRIPT = "(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()";
30
30
  /**
31
- * Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
32
- * Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
33
- * installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
31
+ * Sets up Nuxt UI in the Emberbox style and puts the colour mode script into every HTML page.
32
+ * Replaces `@tailwindcss/vite` in a tool, since Nuxt UI brings it along. Icons are bundled from the
33
+ * installed Iconify collections, so the browser fetches nothing from the Iconify API.
34
34
  *
35
- * Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
36
- * `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
37
- * neueren Build erkennen.
35
+ * Commit and build time (`BUILD_TIME` from the environment, or now) are available as `buildInfo`
36
+ * from `@emberbox/ui`, and every build gets a `build.json` by which open pages notice a newer
37
+ * build.
38
38
  */
39
- export declare function emberbox(optionen?: EmberboxOptionen): PluginOption[];
39
+ export declare function emberbox(options?: EmberboxOptions): PluginOption[];
package/dist/vite.js CHANGED
@@ -2,16 +2,16 @@ import ui from '@nuxt/ui/vite';
2
2
  import { defu } from 'defu';
3
3
  import { execSync } from 'node:child_process';
4
4
  import { logoPlugin } from './vite/logo.js';
5
- import { vorrenderPlugin } from './vite/vorrendern.js';
6
- export { SEITEN_VERZEICHNIS } from './vite/vorrendern.js';
7
- const FARBEN = ['primary', 'signal', 'success', 'info', 'warning', 'error'];
5
+ import { prerenderPlugin } from './vite/prerender.js';
6
+ export { PAGES_DIR } from './vite/prerender.js';
7
+ const COLORS = ['primary', 'signal', 'success', 'info', 'warning', 'error'];
8
8
  /**
9
- * Die Vorgaben, mit denen jede Nuxt-UI-Komponente im Emberbox-Stil erscheint. Die Farbnamen zeigen
10
- * auf die Paletten aus `stil.css`; `primary` ist dort die Tinte, Rot bleibt Signalen und Fehlern.
9
+ * The defaults that make every Nuxt UI component appear in the Emberbox style. The colour names
10
+ * point to the palettes in `style.css`; `primary` is ink there, red is kept for signals and errors.
11
11
  */
12
- const VORGABEN = {
12
+ const DEFAULTS = {
13
13
  colors: {
14
- primary: 'stahl',
14
+ primary: 'steel',
15
15
  signal: 'signal',
16
16
  success: 'green',
17
17
  info: 'blue',
@@ -21,23 +21,23 @@ const VORGABEN = {
21
21
  },
22
22
  formField: {
23
23
  slots: {
24
- label: 'feld-label',
24
+ label: 'field-label',
25
25
  },
26
26
  },
27
27
  };
28
28
  /**
29
- * Wo nach benutzten Icons gesucht wird. Anders als die Vorgabe von `@nuxt/icon` auch in `.ts`- und
30
- * `.js`-Dateien, weil Werkzeuge Icons in Menü- und Routentabellen eintragen.
29
+ * Where to look for used icons. Unlike the `@nuxt/icon` default this includes `.ts` and `.js`
30
+ * files, because tools list icons in menu and route tables.
31
31
  */
32
- const ICON_SUCHE = {
32
+ const ICON_SCAN = {
33
33
  globInclude: ['**/*.{vue,ts,tsx,js,jsx}'],
34
34
  globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*', '**/*.d.ts'],
35
35
  };
36
36
  /**
37
- * Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
38
- * stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
37
+ * The icons of the `@emberbox/ui` components. The scan does not walk `node_modules`, so they are
38
+ * listed here; whoever gives a component an icon adds it here.
39
39
  */
40
- export const EIGENE_ICONS = [
40
+ export const OWN_ICONS = [
41
41
  'i-lucide-check',
42
42
  'i-lucide-copy',
43
43
  'i-lucide-github',
@@ -48,13 +48,13 @@ export const EIGENE_ICONS = [
48
48
  'i-lucide-x',
49
49
  ];
50
50
  /**
51
- * Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
52
- * denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
51
+ * Sets the class `dark` before the first paint, so the page does not flash light. Reads the same
52
+ * key as Nuxt UI's colour mode (`useDark` from VueUse) and follows the system without a choice.
53
53
  */
54
- export const FARBMODUS_SKRIPT = `(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()`;
54
+ export const COLOR_MODE_SCRIPT = `(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()`;
55
55
  /**
56
- * Der kurze Commit, aus dem gebaut wird. Ein Image-Build ohne `.git` reicht ihn als Umgebungsvariable
57
- * `COMMIT` herein; ohne beides heißt er `dev`.
56
+ * The short commit being built. An image build without `.git` passes it in as the environment
57
+ * variable `COMMIT`; without either it is `dev`.
58
58
  */
59
59
  function commit() {
60
60
  if (process.env.COMMIT)
@@ -67,55 +67,55 @@ function commit() {
67
67
  }
68
68
  }
69
69
  /**
70
- * Commit und Bauzeit dieses Bauvorgangs. Einmal je Prozess bestimmt, damit Client- und SSR-Build
71
- * eines Werkzeugs dieselbe Fassung tragen.
70
+ * Commit and build time of this build. Determined once per process, so the client and SSR build of
71
+ * a tool carry the same build info.
72
72
  */
73
- const FASSUNG = { commit: commit(), gebaut: process.env.GEBAUT || new Date().toISOString() };
73
+ const BUILD_INFO = { commit: commit(), builtAt: process.env.BUILD_TIME || new Date().toISOString() };
74
74
  /**
75
- * Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
76
- * Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
77
- * installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
75
+ * Sets up Nuxt UI in the Emberbox style and puts the colour mode script into every HTML page.
76
+ * Replaces `@tailwindcss/vite` in a tool, since Nuxt UI brings it along. Icons are bundled from the
77
+ * installed Iconify collections, so the browser fetches nothing from the Iconify API.
78
78
  *
79
- * Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
80
- * `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
81
- * neueren Build erkennen.
79
+ * Commit and build time (`BUILD_TIME` from the environment, or now) are available as `buildInfo`
80
+ * from `@emberbox/ui`, and every build gets a `build.json` by which open pages notice a newer
81
+ * build.
82
82
  */
83
- export function emberbox(optionen = {}) {
84
- const adresse = optionen.adresse?.replace(/\/+$/, '') ?? '';
85
- if (optionen.vorrendern && !adresse) {
86
- throw new Error('emberbox(): Zum Vorrendern fehlt die adresse.');
83
+ export function emberbox(options = {}) {
84
+ const url = options.url?.replace(/\/+$/, '') ?? '';
85
+ if (options.prerender && !url) {
86
+ throw new Error('emberbox(): prerendering needs a url.');
87
87
  }
88
88
  return [
89
89
  ui({
90
- router: optionen.router ?? true,
91
- theme: { colors: FARBEN },
92
- ui: defu(optionen.ui, VORGABEN),
93
- icon: { clientBundle: { scan: ICON_SUCHE, icons: EIGENE_ICONS } },
90
+ router: options.router ?? true,
91
+ theme: { colors: COLORS },
92
+ ui: defu(options.ui, DEFAULTS),
93
+ icon: { clientBundle: { scan: ICON_SCAN, icons: OWN_ICONS } },
94
94
  scanPackages: ['@emberbox/ui'],
95
95
  }),
96
96
  {
97
97
  name: 'emberbox',
98
98
  config: () => ({
99
99
  define: {
100
- __EMBERBOX_COMMIT__: JSON.stringify(FASSUNG.commit),
101
- __EMBERBOX_GEBAUT__: JSON.stringify(FASSUNG.gebaut),
102
- __EMBERBOX_ADRESSE__: JSON.stringify(adresse),
103
- __EMBERBOX_BILD__: JSON.stringify(optionen.logo ? '/logo-512.png' : ''),
100
+ __EMBERBOX_COMMIT__: JSON.stringify(BUILD_INFO.commit),
101
+ __EMBERBOX_BUILT_AT__: JSON.stringify(BUILD_INFO.builtAt),
102
+ __EMBERBOX_URL__: JSON.stringify(url),
103
+ __EMBERBOX_IMAGE__: JSON.stringify(options.logo ? '/logo-512.png' : ''),
104
104
  },
105
105
  optimizeDeps: { exclude: ['@emberbox/ui', '@iconify/vue'] },
106
106
  resolve: { dedupe: ['vue', 'vue-router', '@nuxt/ui'] },
107
107
  ssr: { noExternal: ['@emberbox/ui', '@nuxt/ui'] },
108
108
  }),
109
109
  transformIndexHtml: () => [
110
- { tag: 'script', children: FARBMODUS_SKRIPT, injectTo: 'head' },
110
+ { tag: 'script', children: COLOR_MODE_SCRIPT, injectTo: 'head' },
111
111
  ],
112
- generateBundle(ausgabe) {
113
- if (ausgabe.format === 'es' && !this.environment?.config.build.ssr) {
114
- this.emitFile({ type: 'asset', fileName: 'fassung.json', source: JSON.stringify(FASSUNG) });
112
+ generateBundle(output) {
113
+ if (output.format === 'es' && !this.environment?.config.build.ssr) {
114
+ this.emitFile({ type: 'asset', fileName: 'build.json', source: JSON.stringify(BUILD_INFO) });
115
115
  }
116
116
  },
117
117
  },
118
- optionen.logo ? logoPlugin(optionen.logo) : false,
119
- optionen.vorrendern && adresse ? vorrenderPlugin(optionen.vorrendern, adresse) : false,
118
+ options.logo ? logoPlugin(options.logo) : false,
119
+ options.prerender && url ? prerenderPlugin(options.prerender, url) : false,
120
120
  ];
121
121
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@emberbox/ui",
3
- "version": "0.1.0",
4
- "description": "Gemeinsamer Stil und gemeinsame Bausteine der Emberbox-Werkzeuge, auf Basis von Nuxt UI.",
3
+ "version": "0.2.0",
4
+ "description": "Shared look and building blocks of the Emberbox tools, built on Nuxt UI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -16,19 +16,19 @@
16
16
  ],
17
17
  "exports": {
18
18
  ".": "./src/index.ts",
19
- "./vorrendern": "./src/vorrendern.ts",
19
+ "./prerender": "./src/prerender.ts",
20
20
  "./vite": {
21
21
  "types": "./dist/vite.d.ts",
22
22
  "import": "./dist/vite.js"
23
23
  },
24
- "./stil.css": "./src/stil.css",
24
+ "./style.css": "./src/style.css",
25
25
  "./logos/*": "./logos/*"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.vite.json",
29
29
  "typecheck": "vue-tsc -b",
30
- "icons": "node scripts/icons-pruefen.mjs",
31
- "logos": "node scripts/logos-bauen.mjs",
30
+ "icons": "node scripts/check-icons.mjs",
31
+ "logos": "node scripts/build-logos.mjs",
32
32
  "prepack": "npm run build"
33
33
  },
34
34
  "dependencies": {
@@ -0,0 +1,23 @@
1
+ declare const __EMBERBOX_COMMIT__: string | undefined
2
+ declare const __EMBERBOX_BUILT_AT__: string | undefined
3
+
4
+ /**
5
+ * The build the tool runs in. `emberbox()` sets both at build time: the short commit and the build
6
+ * time as an ISO timestamp. Without `emberbox()`, for example in a test run, the commit is `dev`
7
+ * and the build time stays empty.
8
+ */
9
+ export const buildInfo = {
10
+ commit: typeof __EMBERBOX_COMMIT__ === 'string' ? __EMBERBOX_COMMIT__ : 'dev',
11
+ builtAt: typeof __EMBERBOX_BUILT_AT__ === 'string' ? __EMBERBOX_BUILT_AT__ : '',
12
+ }
13
+
14
+ /**
15
+ * The build time in the reader's time zone, or empty when it is missing. It depends on the reader
16
+ * and therefore belongs on the page only after mounting, never in prerendered HTML.
17
+ */
18
+ export function formatBuiltAt(): string {
19
+ const time = new Date(buildInfo.builtAt)
20
+ return Number.isNaN(time.getTime())
21
+ ? ''
22
+ : time.toLocaleString('de-DE', {dateStyle: 'medium', timeStyle: 'short'})
23
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Puts text on the clipboard. On an unencrypted address, such as a tool in the local network, the
3
+ * Clipboard API is missing; a briefly inserted text selection helps then.
4
+ *
5
+ * @returns whether the text really is on the clipboard
6
+ */
7
+ export async function copyToClipboard(text: string): Promise<boolean> {
8
+ try {
9
+ if (navigator.clipboard?.writeText) {
10
+ await navigator.clipboard.writeText(text)
11
+ return true
12
+ }
13
+ } catch {
14
+ return legacyCopy(text)
15
+ }
16
+ return legacyCopy(text)
17
+ }
18
+
19
+ function legacyCopy(text: string): boolean {
20
+ const field = document.createElement('textarea')
21
+ field.value = text
22
+ field.setAttribute('readonly', '')
23
+ field.style.position = 'fixed'
24
+ field.style.opacity = '0'
25
+ document.body.appendChild(field)
26
+ field.select()
27
+ try {
28
+ return document.execCommand('copy')
29
+ } catch {
30
+ return false
31
+ } finally {
32
+ field.remove()
33
+ }
34
+ }
@@ -0,0 +1,66 @@
1
+ <script setup lang="ts">
2
+ import UIcon from '@nuxt/ui/components/Icon.vue'
3
+ import ULink from '@nuxt/ui/components/Link.vue'
4
+ import {onMounted, ref} from 'vue'
5
+ import emberboxLogo from '../../logos/emberbox.svg?url'
6
+ import {buildInfo, formatBuiltAt} from '../build-info'
7
+ import {HUB_URL, IMPRINT_URL, PRIVACY_URL} from '../urls'
8
+
9
+ /**
10
+ * A tool's footer: a notice that it is not an official offer, the way back to the Emberbox hub,
11
+ * links to imprint, privacy policy, help and source code, copyright, license and the running
12
+ * build. The hub itself turns the backlink off with `backlink: false`.
13
+ */
14
+ const props = withDefaults(defineProps<{
15
+ tool: string
16
+ source: string
17
+ license: string
18
+ help?: string
19
+ notice?: string
20
+ backlink?: boolean
21
+ }>(), {
22
+ notice: 'Kein offizielles Angebot einer Feuerwehr oder Leitstelle.',
23
+ backlink: true,
24
+ })
25
+
26
+ const year = new Date(buildInfo.builtAt).getUTCFullYear() || new Date().getUTCFullYear()
27
+ const builtAt = ref('')
28
+ onMounted(() => {
29
+ builtAt.value = formatBuiltAt()
30
+ })
31
+ const links = [
32
+ {label: 'Impressum', to: IMPRINT_URL},
33
+ {label: 'Datenschutz', to: PRIVACY_URL},
34
+ ...(props.help ? [{label: 'Hilfe', to: props.help}] : []),
35
+ ]
36
+ </script>
37
+
38
+ <template>
39
+ <footer class="mt-auto border-t border-default">
40
+ <div class="mx-auto grid w-full max-w-[1560px] gap-4 px-4 py-5 text-[13px] text-muted md:grid-cols-[1fr_auto_1fr] md:px-6">
41
+ <p class="m-0 max-w-sm text-center md:text-left">{{ notice }}</p>
42
+ <div class="flex flex-col items-center gap-1 text-center">
43
+ <ULink v-if="backlink" :to="HUB_URL"
44
+ class="mb-1 flex items-center gap-2 text-sm text-default hover:text-highlighted hover:underline">
45
+ <img :src="emberboxLogo" alt="" width="20" height="20" class="size-5 rounded-[3px]">
46
+ <span>Ein Werkzeug der <strong class="font-semibold">Emberbox</strong></span>
47
+ </ULink>
48
+ <p class="m-0 flex flex-wrap items-center justify-center gap-x-3 gap-y-1">
49
+ <template v-for="(link, index) in links" :key="link.to">
50
+ <span v-if="index > 0" aria-hidden="true">·</span>
51
+ <ULink :to="link.to" class="text-default hover:underline">{{ link.label }}</ULink>
52
+ </template>
53
+ </p>
54
+ <ULink :to="source" target="_blank" rel="noreferrer noopener"
55
+ class="flex items-center gap-1.5 text-default hover:underline">
56
+ <UIcon name="i-lucide-github" aria-hidden="true"/>
57
+ GitHub
58
+ </ULink>
59
+ <span>© {{ year }} RainbowDashLabs and Contributor</span>
60
+ <span>Made with ❤️ and 🏳️‍🌈</span>
61
+ <span>Licensed under {{ license }}</span>
62
+ <span class="tabular">{{ tool }} {{ buildInfo.commit }} · built {{ builtAt }}</span>
63
+ </div>
64
+ </div>
65
+ </footer>
66
+ </template>
@@ -2,19 +2,19 @@
2
2
  import UIcon from '@nuxt/ui/components/Icon.vue'
3
3
  import ULink from '@nuxt/ui/components/Link.vue'
4
4
  import UColorModeButton from '@nuxt/ui/components/color-mode/ColorModeButton.vue'
5
- import {HUB_URL} from '../adressen'
5
+ import {HUB_URL} from '../urls'
6
6
 
7
7
  /**
8
- * Die Kopfleiste eines Werkzeugs: das Logo als Rücksprung zu emberbox.app, Name und Untertitel,
9
- * Navigation, Aktionen, Farbmodus und ein Platz für ein Konto. Darunter liegt der rote
10
- * Signalbalken. Ohne `logo` steht an seiner Stelle ein Raster-Symbol.
8
+ * A tool's header bar: the logo as the way back to emberbox.app, name and subtitle, navigation,
9
+ * actions, colour mode and a slot for an account. The red signal bar runs below it. Without
10
+ * `logo`, a grid icon takes its place.
11
11
  */
12
12
  withDefaults(defineProps<{
13
13
  name: string
14
- untertitel?: string
15
- start?: string
14
+ subtitle?: string
15
+ home?: string
16
16
  logo?: string
17
- }>(), {start: '/'})
17
+ }>(), {home: '/'})
18
18
  </script>
19
19
 
20
20
  <template>
@@ -26,18 +26,18 @@ withDefaults(defineProps<{
26
26
  <img v-if="logo" :src="logo" alt="" class="size-8 rounded-sm">
27
27
  <UIcon v-else name="i-lucide-layout-grid" class="size-5"/>
28
28
  </ULink>
29
- <ULink :to="start" class="flex items-baseline gap-2 text-highlighted hover:text-highlighted">
29
+ <ULink :to="home" class="flex items-baseline gap-2 text-highlighted hover:text-highlighted">
30
30
  <span class="font-condensed text-xl font-bold uppercase tracking-wide">{{ name }}</span>
31
- <span v-if="untertitel" class="eyebrow hidden sm:inline">{{ untertitel }}</span>
31
+ <span v-if="subtitle" class="eyebrow hidden sm:inline">{{ subtitle }}</span>
32
32
  </ULink>
33
33
  </div>
34
- <nav v-if="$slots.navigation" class="flex grow flex-wrap gap-x-5 gap-y-1">
35
- <slot name="navigation"/>
34
+ <nav v-if="$slots.nav" class="flex grow flex-wrap gap-x-5 gap-y-1">
35
+ <slot name="nav"/>
36
36
  </nav>
37
37
  <div class="ml-auto flex shrink-0 items-center gap-2">
38
- <slot name="aktionen"/>
38
+ <slot name="actions"/>
39
39
  <UColorModeButton/>
40
- <slot name="konto"/>
40
+ <slot name="account"/>
41
41
  </div>
42
42
  </div>
43
43
  <div class="h-[3px] bg-signal"/>