@emberbox/ui 0.1.0 → 0.3.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 (55) 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 +48 -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/CollapsibleSection.vue +75 -0
  15. package/src/components/ComboboxField.vue +132 -0
  16. package/src/components/ConfirmDialog.vue +25 -0
  17. package/src/components/DateTimeField.vue +47 -0
  18. package/src/{komponenten → components}/EmberboxApp.vue +4 -4
  19. package/src/{komponenten/HilfeMockup.vue → components/HelpMockup.vue} +3 -3
  20. package/src/components/HelpPage.vue +16 -0
  21. package/src/components/HelpSection.vue +11 -0
  22. package/src/components/HelpTopic.vue +20 -0
  23. package/src/{komponenten/NeueFassung.vue → components/NewBuildBanner.vue} +8 -8
  24. package/src/components/TextAreaField.vue +14 -0
  25. package/src/components/TextField.vue +29 -0
  26. package/src/components/YesNoField.vue +47 -0
  27. package/src/composables/useConfirm.ts +27 -0
  28. package/src/composables/useNewBuild.ts +45 -0
  29. package/src/composables/usePolling.ts +55 -57
  30. package/src/create-app.ts +11 -0
  31. package/src/index.ts +28 -21
  32. package/src/page.ts +81 -0
  33. package/src/prerender.ts +23 -0
  34. package/src/{stil.css → style.css} +67 -58
  35. package/src/urls.ts +8 -0
  36. package/src/vite/logo.ts +16 -17
  37. package/src/vite/prerender.ts +72 -0
  38. package/src/vite.ts +57 -55
  39. package/dist/vite/vorrendern.d.ts +0 -17
  40. package/dist/vite/vorrendern.js +0 -57
  41. package/src/adressen.ts +0 -8
  42. package/src/app.ts +0 -11
  43. package/src/composables/useNeueFassung.ts +0 -45
  44. package/src/composables/useRueckfrage.ts +0 -27
  45. package/src/fassung.ts +0 -23
  46. package/src/komponenten/AppFuss.vue +0 -58
  47. package/src/komponenten/CodeAnzeige.vue +0 -79
  48. package/src/komponenten/HilfeAbschnitt.vue +0 -11
  49. package/src/komponenten/HilfeSeite.vue +0 -16
  50. package/src/komponenten/HilfeThema.vue +0 -20
  51. package/src/komponenten/Rueckfrage.vue +0 -24
  52. package/src/seite.ts +0 -81
  53. package/src/vite/vorrendern.ts +0 -72
  54. package/src/vorrendern.ts +0 -24
  55. package/src/zwischenablage.ts +0 -34
@@ -0,0 +1,72 @@
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, type Plugin, type ResolvedConfig} from 'vite'
5
+
6
+ /** Which pages of a tool become finished HTML at build time. */
7
+ export interface PrerenderOptions {
8
+ /** Module that exports `render(path, template)`, such as `src/prerender.ts`. */
9
+ entry: string
10
+ /** The public paths, such as `['/', '/hilfe']`. */
11
+ paths: string[]
12
+ }
13
+
14
+ /** What a tool's entry module provides. */
15
+ interface PrerenderEntry {
16
+ render(path: string, template: string): Promise<string>
17
+ }
18
+
19
+ /** The directory below the build output that holds the prerendered pages. */
20
+ export const PAGES_DIR = 'pages'
21
+
22
+ function pageFile(outDir: string, path: string): string {
23
+ return join(outDir, PAGES_DIR, path.replace(/^\/+|\/+$/g, ''), 'index.html')
24
+ }
25
+
26
+ function sitemap(url: string, paths: string[]): string {
27
+ const entries = paths.map(path => ` <url><loc>${url}${path}</loc></url>`).join('\n')
28
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`
29
+ }
30
+
31
+ /**
32
+ * Prerenders the public pages once the client build is written. It builds the entry as an SSR
33
+ * bundle, calls `render` for every path with the built `index.html` as template and writes the
34
+ * result to `pages/<path>/index.html`. `index.html` itself stays the empty shell for all other
35
+ * routes. `sitemap.xml` and `robots.txt` are written next to it.
36
+ */
37
+ export function prerenderPlugin(options: PrerenderOptions, url: string): Plugin {
38
+ let config: ResolvedConfig
39
+ return {
40
+ name: 'emberbox:prerender',
41
+ apply: 'build',
42
+ configResolved(resolved) {
43
+ config = resolved
44
+ },
45
+ async writeBundle() {
46
+ if (config.build.ssr) return
47
+ const outDir = resolve(config.root, config.build.outDir)
48
+ const ssrOutDir = resolve(config.root, 'node_modules', '.emberbox-prerender')
49
+ await build({
50
+ configFile: config.configFile,
51
+ root: config.root,
52
+ mode: config.mode,
53
+ logLevel: 'warn',
54
+ build: {ssr: options.entry, outDir: ssrOutDir, emptyOutDir: true, copyPublicDir: false},
55
+ })
56
+ const name = basename(options.entry, extname(options.entry))
57
+ const bundle = readdirSync(ssrOutDir).find(candidate => /^(.+)\.m?js$/.exec(candidate)?.[1] === name)
58
+ if (!bundle) throw new Error(`The SSR bundle of ${options.entry} is missing in ${ssrOutDir}.`)
59
+ const entry = await import(pathToFileURL(join(ssrOutDir, bundle)).href) as PrerenderEntry
60
+ const template = readFileSync(join(outDir, 'index.html'), 'utf8')
61
+ for (const path of options.paths) {
62
+ const target = pageFile(outDir, path)
63
+ mkdirSync(join(target, '..'), {recursive: true})
64
+ writeFileSync(target, await entry.render(path, template))
65
+ }
66
+ writeFileSync(join(outDir, 'sitemap.xml'), sitemap(url, options.paths))
67
+ writeFileSync(join(outDir, 'robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${url}/sitemap.xml\n`)
68
+ rmSync(ssrOutDir, {recursive: true, force: true})
69
+ config.logger.info(`emberbox: prerendered ${options.paths.length} pages`)
70
+ },
71
+ }
72
+ }
package/src/vite.ts CHANGED
@@ -4,34 +4,34 @@ import {defu} from 'defu'
4
4
  import {execSync} from 'node:child_process'
5
5
  import type {PluginOption} from 'vite'
6
6
  import {type Logo, logoPlugin} from './vite/logo.js'
7
- import {vorrenderPlugin, type VorrendernOptionen} from './vite/vorrendern.js'
7
+ import {prerenderPlugin, type PrerenderOptions} from './vite/prerender.js'
8
8
 
9
- export {SEITEN_VERZEICHNIS, type VorrendernOptionen} from './vite/vorrendern.js'
9
+ export {PAGES_DIR, type PrerenderOptions} from './vite/prerender.js'
10
10
  export type {Logo} from './vite/logo.js'
11
11
 
12
- /** Einstellungen, mit denen ein Werkzeug `emberbox()` an seine Lage anpasst. */
13
- export interface EmberboxOptionen {
14
- /** `false` für Werkzeuge ohne vue-router; Links werden dann als einfache Anker gerendert. */
12
+ /** Settings a tool passes to `emberbox()`. */
13
+ export interface EmberboxOptions {
14
+ /** `false` for tools without vue-router; links are then rendered as plain anchors. */
15
15
  router?: boolean
16
- /** Zusätzliche Nuxt-UI-Einstellungen des Werkzeugs, die über die Emberbox-Vorgaben gelegt werden. */
16
+ /** Additional Nuxt UI settings of the tool, applied on top of the Emberbox defaults. */
17
17
  ui?: NuxtUIOptions['ui']
18
- /** Die öffentliche Adresse, etwa `https://calltaker.emberbox.app`; ein `/` am Ende fällt weg. */
19
- adresse?: string
20
- /** Welches Emberbox-Logo als Favicon, Touch-Icon und Vorschaubild ausgeliefert wird. */
18
+ /** The public address, such as `https://calltaker.emberbox.app`; a trailing `/` is dropped. */
19
+ url?: string
20
+ /** Which Emberbox logo is served as favicon, touch icon and preview image. */
21
21
  logo?: Logo
22
- /** Welche öffentlichen Seiten beim Bauen vorgerendert werden; braucht `adresse`. */
23
- vorrendern?: VorrendernOptionen
22
+ /** Which public pages are prerendered at build time; needs `url`. */
23
+ prerender?: PrerenderOptions
24
24
  }
25
25
 
26
- const FARBEN = ['primary', 'signal', 'success', 'info', 'warning', 'error']
26
+ const COLORS = ['primary', 'signal', 'success', 'info', 'warning', 'error']
27
27
 
28
28
  /**
29
- * Die Vorgaben, mit denen jede Nuxt-UI-Komponente im Emberbox-Stil erscheint. Die Farbnamen zeigen
30
- * auf die Paletten aus `stil.css`; `primary` ist dort die Tinte, Rot bleibt Signalen und Fehlern.
29
+ * The defaults that make every Nuxt UI component appear in the Emberbox style. The colour names
30
+ * point to the palettes in `style.css`; `primary` is ink there, red is kept for signals and errors.
31
31
  */
32
- const VORGABEN: NuxtUIOptions['ui'] = {
32
+ const DEFAULTS: NuxtUIOptions['ui'] = {
33
33
  colors: {
34
- primary: 'stahl',
34
+ primary: 'steel',
35
35
  signal: 'signal',
36
36
  success: 'green',
37
37
  info: 'blue',
@@ -41,26 +41,28 @@ const VORGABEN: NuxtUIOptions['ui'] = {
41
41
  },
42
42
  formField: {
43
43
  slots: {
44
- label: 'feld-label',
44
+ label: 'field-label',
45
45
  },
46
46
  },
47
47
  }
48
48
 
49
49
  /**
50
- * Wo nach benutzten Icons gesucht wird. Anders als die Vorgabe von `@nuxt/icon` auch in `.ts`- und
51
- * `.js`-Dateien, weil Werkzeuge Icons in Menü- und Routentabellen eintragen.
50
+ * Where to look for used icons. Unlike the `@nuxt/icon` default this includes `.ts` and `.js`
51
+ * files, because tools list icons in menu and route tables.
52
52
  */
53
- const ICON_SUCHE = {
53
+ const ICON_SCAN = {
54
54
  globInclude: ['**/*.{vue,ts,tsx,js,jsx}'],
55
55
  globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*', '**/*.d.ts'],
56
56
  }
57
57
 
58
58
  /**
59
- * Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
60
- * stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
59
+ * The icons of the `@emberbox/ui` components. The scan does not walk `node_modules`, so they are
60
+ * listed here; whoever gives a component an icon adds it here.
61
61
  */
62
- export const EIGENE_ICONS = [
62
+ export const OWN_ICONS = [
63
63
  'i-lucide-check',
64
+ 'i-lucide-chevron-down',
65
+ 'i-lucide-chevron-right',
64
66
  'i-lucide-copy',
65
67
  'i-lucide-github',
66
68
  'i-lucide-layout-grid',
@@ -71,14 +73,14 @@ export const EIGENE_ICONS = [
71
73
  ]
72
74
 
73
75
  /**
74
- * Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
75
- * denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
76
+ * Sets the class `dark` before the first paint, so the page does not flash light. Reads the same
77
+ * key as Nuxt UI's colour mode (`useDark` from VueUse) and follows the system without a choice.
76
78
  */
77
- 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){}})()`
79
+ 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){}})()`
78
80
 
79
81
  /**
80
- * Der kurze Commit, aus dem gebaut wird. Ein Image-Build ohne `.git` reicht ihn als Umgebungsvariable
81
- * `COMMIT` herein; ohne beides heißt er `dev`.
82
+ * The short commit being built. An image build without `.git` passes it in as the environment
83
+ * variable `COMMIT`; without either it is `dev`.
82
84
  */
83
85
  function commit(): string {
84
86
  if (process.env.COMMIT) return process.env.COMMIT
@@ -90,56 +92,56 @@ function commit(): string {
90
92
  }
91
93
 
92
94
  /**
93
- * Commit und Bauzeit dieses Bauvorgangs. Einmal je Prozess bestimmt, damit Client- und SSR-Build
94
- * eines Werkzeugs dieselbe Fassung tragen.
95
+ * Commit and build time of this build. Determined once per process, so the client and SSR build of
96
+ * a tool carry the same build info.
95
97
  */
96
- const FASSUNG = {commit: commit(), gebaut: process.env.GEBAUT || new Date().toISOString()}
98
+ const BUILD_INFO = {commit: commit(), builtAt: process.env.BUILD_TIME || new Date().toISOString()}
97
99
 
98
100
  /**
99
- * Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
100
- * Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
101
- * installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
101
+ * Sets up Nuxt UI in the Emberbox style and puts the colour mode script into every HTML page.
102
+ * Replaces `@tailwindcss/vite` in a tool, since Nuxt UI brings it along. Icons are bundled from the
103
+ * installed Iconify collections, so the browser fetches nothing from the Iconify API.
102
104
  *
103
- * Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
104
- * `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
105
- * neueren Build erkennen.
105
+ * Commit and build time (`BUILD_TIME` from the environment, or now) are available as `buildInfo`
106
+ * from `@emberbox/ui`, and every build gets a `build.json` by which open pages notice a newer
107
+ * build.
106
108
  */
107
- export function emberbox(optionen: EmberboxOptionen = {}): PluginOption[] {
108
- const adresse = optionen.adresse?.replace(/\/+$/, '') ?? ''
109
- if (optionen.vorrendern && !adresse) {
110
- throw new Error('emberbox(): Zum Vorrendern fehlt die adresse.')
109
+ export function emberbox(options: EmberboxOptions = {}): PluginOption[] {
110
+ const url = options.url?.replace(/\/+$/, '') ?? ''
111
+ if (options.prerender && !url) {
112
+ throw new Error('emberbox(): prerendering needs a url.')
111
113
  }
112
114
  return [
113
115
  ui({
114
- router: optionen.router ?? true,
115
- theme: {colors: FARBEN},
116
- ui: defu(optionen.ui, VORGABEN),
117
- icon: {clientBundle: {scan: ICON_SUCHE, icons: EIGENE_ICONS}},
116
+ router: options.router ?? true,
117
+ theme: {colors: COLORS},
118
+ ui: defu(options.ui, DEFAULTS),
119
+ icon: {clientBundle: {scan: ICON_SCAN, icons: OWN_ICONS}},
118
120
  scanPackages: ['@emberbox/ui'],
119
121
  }),
120
122
  {
121
123
  name: 'emberbox',
122
124
  config: () => ({
123
125
  define: {
124
- __EMBERBOX_COMMIT__: JSON.stringify(FASSUNG.commit),
125
- __EMBERBOX_GEBAUT__: JSON.stringify(FASSUNG.gebaut),
126
- __EMBERBOX_ADRESSE__: JSON.stringify(adresse),
127
- __EMBERBOX_BILD__: JSON.stringify(optionen.logo ? '/logo-512.png' : ''),
126
+ __EMBERBOX_COMMIT__: JSON.stringify(BUILD_INFO.commit),
127
+ __EMBERBOX_BUILT_AT__: JSON.stringify(BUILD_INFO.builtAt),
128
+ __EMBERBOX_URL__: JSON.stringify(url),
129
+ __EMBERBOX_IMAGE__: JSON.stringify(options.logo ? '/logo-512.png' : ''),
128
130
  },
129
131
  optimizeDeps: {exclude: ['@emberbox/ui', '@iconify/vue']},
130
132
  resolve: {dedupe: ['vue', 'vue-router', '@nuxt/ui']},
131
133
  ssr: {noExternal: ['@emberbox/ui', '@nuxt/ui']},
132
134
  }),
133
135
  transformIndexHtml: () => [
134
- {tag: 'script', children: FARBMODUS_SKRIPT, injectTo: 'head'},
136
+ {tag: 'script', children: COLOR_MODE_SCRIPT, injectTo: 'head'},
135
137
  ],
136
- generateBundle(this, ausgabe) {
137
- if (ausgabe.format === 'es' && !this.environment?.config.build.ssr) {
138
- this.emitFile({type: 'asset', fileName: 'fassung.json', source: JSON.stringify(FASSUNG)})
138
+ generateBundle(this, output) {
139
+ if (output.format === 'es' && !this.environment?.config.build.ssr) {
140
+ this.emitFile({type: 'asset', fileName: 'build.json', source: JSON.stringify(BUILD_INFO)})
139
141
  }
140
142
  },
141
143
  },
142
- optionen.logo ? logoPlugin(optionen.logo) : false,
143
- optionen.vorrendern && adresse ? vorrenderPlugin(optionen.vorrendern, adresse) : false,
144
+ options.logo ? logoPlugin(options.logo) : false,
145
+ options.prerender && url ? prerenderPlugin(options.prerender, url) : false,
144
146
  ]
145
147
  }
@@ -1,17 +0,0 @@
1
- import { type Plugin } from 'vite';
2
- /** Welche Seiten eines Werkzeugs beim Bauen als fertiges HTML entstehen. */
3
- export interface VorrendernOptionen {
4
- /** Modul, das `render(pfad, vorlage)` exportiert, etwa `src/vorrendern.ts`. */
5
- eintrag: string;
6
- /** Die öffentlichen Pfade, etwa `['/', '/hilfe']`. */
7
- pfade: string[];
8
- }
9
- /** Das Verzeichnis unter dem Build, in dem die vorgerenderten Seiten liegen. */
10
- export declare const SEITEN_VERZEICHNIS = "seiten";
11
- /**
12
- * Rendert nach dem Client-Build die öffentlichen Seiten vor. Dazu baut es den Eintrag als
13
- * SSR-Bündel, ruft für jeden Pfad `render` mit der gebauten `index.html` als Vorlage auf und legt
14
- * das Ergebnis unter `seiten/<pfad>/index.html` ab. Die `index.html` selbst bleibt die leere Hülle
15
- * für alle übrigen Routen. Daneben entstehen `sitemap.xml` und `robots.txt`.
16
- */
17
- export declare function vorrenderPlugin(optionen: VorrendernOptionen, adresse: string): Plugin;
@@ -1,57 +0,0 @@
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
- /** Das Verzeichnis unter dem Build, in dem die vorgerenderten Seiten liegen. */
6
- export const SEITEN_VERZEICHNIS = 'seiten';
7
- function seitenDatei(ausgabe, pfad) {
8
- return join(ausgabe, SEITEN_VERZEICHNIS, pfad.replace(/^\/+|\/+$/g, ''), 'index.html');
9
- }
10
- function sitemap(adresse, pfade) {
11
- const eintraege = pfade.map(pfad => ` <url><loc>${adresse}${pfad}</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${eintraege}\n</urlset>\n`;
13
- }
14
- /**
15
- * Rendert nach dem Client-Build die öffentlichen Seiten vor. Dazu baut es den Eintrag als
16
- * SSR-Bündel, ruft für jeden Pfad `render` mit der gebauten `index.html` als Vorlage auf und legt
17
- * das Ergebnis unter `seiten/<pfad>/index.html` ab. Die `index.html` selbst bleibt die leere Hülle
18
- * für alle übrigen Routen. Daneben entstehen `sitemap.xml` und `robots.txt`.
19
- */
20
- export function vorrenderPlugin(optionen, adresse) {
21
- let config;
22
- return {
23
- name: 'emberbox:vorrendern',
24
- apply: 'build',
25
- configResolved(aufgeloest) {
26
- config = aufgeloest;
27
- },
28
- async writeBundle() {
29
- if (config.build.ssr)
30
- return;
31
- const ausgabe = resolve(config.root, config.build.outDir);
32
- const ssrAusgabe = resolve(config.root, 'node_modules', '.emberbox-vorrendern');
33
- await build({
34
- configFile: config.configFile,
35
- root: config.root,
36
- mode: config.mode,
37
- logLevel: 'warn',
38
- build: { ssr: optionen.eintrag, outDir: ssrAusgabe, emptyOutDir: true, copyPublicDir: false },
39
- });
40
- const name = basename(optionen.eintrag, extname(optionen.eintrag));
41
- const datei = readdirSync(ssrAusgabe).find(kandidat => /^(.+)\.m?js$/.exec(kandidat)?.[1] === name);
42
- if (!datei)
43
- throw new Error(`Das SSR-Bündel von ${optionen.eintrag} fehlt in ${ssrAusgabe}.`);
44
- const eintrag = await import(pathToFileURL(join(ssrAusgabe, datei)).href);
45
- const vorlage = readFileSync(join(ausgabe, 'index.html'), 'utf8');
46
- for (const pfad of optionen.pfade) {
47
- const ziel = seitenDatei(ausgabe, pfad);
48
- mkdirSync(join(ziel, '..'), { recursive: true });
49
- writeFileSync(ziel, await eintrag.render(pfad, vorlage));
50
- }
51
- writeFileSync(join(ausgabe, 'sitemap.xml'), sitemap(adresse, optionen.pfade));
52
- writeFileSync(join(ausgabe, 'robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${adresse}/sitemap.xml\n`);
53
- rmSync(ssrAusgabe, { recursive: true, force: true });
54
- config.logger.info(`emberbox: ${optionen.pfade.length} Seiten vorgerendert`);
55
- },
56
- };
57
- }
package/src/adressen.ts DELETED
@@ -1,8 +0,0 @@
1
- /** Die Startseite aller Emberbox-Werkzeuge. */
2
- export const HUB_URL = 'https://emberbox.app'
3
-
4
- /** Das gemeinsame Impressum aller Werkzeuge. */
5
- export const IMPRESSUM_URL = `${HUB_URL}/impressum`
6
-
7
- /** Die gemeinsame Datenschutzerklärung aller Werkzeuge. */
8
- export const DATENSCHUTZ_URL = `${HUB_URL}/datenschutz`
package/src/app.ts DELETED
@@ -1,11 +0,0 @@
1
- import {type Component, createApp, createSSRApp} from 'vue'
2
-
3
- /**
4
- * Erzeugt die App eines Werkzeugs im Browser. Ist die Seite vorgerendert, übernimmt Vue das
5
- * vorhandene HTML (Hydration), sonst baut es die Seite neu auf. Vor `mount` muss der Router bereit
6
- * sein (`await router.isReady()`), damit die Hydration dieselbe Seite trifft.
7
- */
8
- export function appErzeugen(wurzel: Component) {
9
- const vorgerendert = (document.getElementById('app')?.childElementCount ?? 0) > 0
10
- return vorgerendert ? createSSRApp(wurzel) : createApp(wurzel)
11
- }
@@ -1,45 +0,0 @@
1
- import {onBeforeUnmount, onMounted, ref} from 'vue'
2
- import {fassung} from '../fassung'
3
-
4
- /** Wie oft eine offene Seite nachfragt, welchen Build der Server ausliefert. */
5
- export const PRUEFEN_ALLE_MS = 60_000
6
-
7
- /**
8
- * Ob der Server einen neueren Build ausliefert als den, in dem diese Seite läuft. Die Seite fragt
9
- * dazu ab und zu und bei jeder Rückkehr in den Vordergrund die `fassung.json` ab, die `emberbox()`
10
- * neben jeden Build legt. Eine über ein Deployment offen gebliebene Seite liefe sonst mit dem alten
11
- * Frontend gegen den neuen Server.
12
- */
13
- export function useNeueFassung() {
14
- const neu = ref(false)
15
- let zeitgeber: ReturnType<typeof setInterval> | undefined
16
-
17
- async function pruefen(): Promise<void> {
18
- if (neu.value) return
19
- try {
20
- const antwort = await fetch('/fassung.json', {cache: 'no-store'})
21
- if (!antwort.ok) return
22
- const {gebaut} = await antwort.json() as {gebaut?: string}
23
- neu.value = Boolean(gebaut) && gebaut !== fassung.gebaut
24
- } catch {
25
- neu.value = false
26
- }
27
- }
28
-
29
- function sichtbar(): void {
30
- if (document.visibilityState === 'visible') void pruefen()
31
- }
32
-
33
- onMounted(() => {
34
- zeitgeber = setInterval(() => void pruefen(), PRUEFEN_ALLE_MS)
35
- document.addEventListener('visibilitychange', sichtbar)
36
- void pruefen()
37
- })
38
-
39
- onBeforeUnmount(() => {
40
- clearInterval(zeitgeber)
41
- document.removeEventListener('visibilitychange', sichtbar)
42
- })
43
-
44
- return neu
45
- }
@@ -1,27 +0,0 @@
1
- import {useOverlay} from '@nuxt/ui/composables'
2
- import Rueckfrage from '../komponenten/Rueckfrage.vue'
3
-
4
- /** Was eine Rückfrage außer der Frage selbst zeigt. */
5
- export interface RueckfrageOptionen {
6
- /** Ein Satz unter der Frage, etwa was die Handlung auslöst. */
7
- erklaerung?: string
8
- /** Die Beschriftung des bestätigenden Knopfs. */
9
- bestaetigung?: string
10
- /** Ob die Handlung etwas zerstört; der Knopf erscheint dann in Signalrot. */
11
- gefahr?: boolean
12
- }
13
-
14
- /**
15
- * Eine Bestätigung im Seiteninneren statt `window.confirm`, das die ganze Seite blockiert und
16
- * damit auch jede laufende Abfrage anhält. Muss im `setup` einer Komponente unter `EmberboxApp`
17
- * aufgerufen werden. Jede Rückfrage legt ihr Fenster neu an und räumt es nach dem Schließen weg.
18
- *
19
- * @returns eine Funktion, die die Rückfrage öffnet und mit `true` auflöst, wenn bestätigt wurde
20
- */
21
- export function useRueckfrage() {
22
- const overlay = useOverlay()
23
- return async (frage: string, optionen: RueckfrageOptionen = {}): Promise<boolean> => {
24
- const fenster = overlay.create(Rueckfrage, {destroyOnClose: true})
25
- return Boolean(await fenster.open({frage, ...optionen}).result)
26
- }
27
- }
package/src/fassung.ts DELETED
@@ -1,23 +0,0 @@
1
- declare const __EMBERBOX_COMMIT__: string | undefined
2
- declare const __EMBERBOX_GEBAUT__: string | undefined
3
-
4
- /**
5
- * Der Build, in dem das Werkzeug läuft. `emberbox()` setzt beides beim Bauen: den kurzen Commit
6
- * und die Bauzeit als ISO-Zeitpunkt. Ohne `emberbox()`, etwa in einem Testlauf, heißt der Commit
7
- * `dev` und die Bauzeit bleibt leer.
8
- */
9
- export const fassung = {
10
- commit: typeof __EMBERBOX_COMMIT__ === 'string' ? __EMBERBOX_COMMIT__ : 'dev',
11
- gebaut: typeof __EMBERBOX_GEBAUT__ === 'string' ? __EMBERBOX_GEBAUT__ : '',
12
- }
13
-
14
- /**
15
- * Die Bauzeit in der Zeitzone des Lesers, oder leer, wenn sie fehlt. Hängt vom Leser ab und gehört
16
- * deshalb erst nach dem Einhängen ins Bild, nie ins vorgerenderte HTML.
17
- */
18
- export function gebautLesbar(): string {
19
- const zeitpunkt = new Date(fassung.gebaut)
20
- return Number.isNaN(zeitpunkt.getTime())
21
- ? ''
22
- : zeitpunkt.toLocaleString('de-DE', {dateStyle: 'medium', timeStyle: 'short'})
23
- }
@@ -1,58 +0,0 @@
1
- <script setup lang="ts">
2
- import ULink from '@nuxt/ui/components/Link.vue'
3
- import UIcon from '@nuxt/ui/components/Icon.vue'
4
- import {DATENSCHUTZ_URL, HUB_URL, IMPRESSUM_URL} from '../adressen'
5
- import {onMounted, ref} from 'vue'
6
- import {fassung, gebautLesbar} from '../fassung'
7
-
8
- /**
9
- * Der Fuß eines Werkzeugs: Hinweis, dass es kein offizielles Angebot ist, Links zu emberbox.app,
10
- * Impressum, Datenschutz, Hilfe und Quellcode, Urheber, Lizenz und der laufende Build.
11
- */
12
- const props = withDefaults(defineProps<{
13
- werkzeug: string
14
- quelle: string
15
- lizenz: string
16
- hilfe?: string
17
- hinweis?: string
18
- }>(), {
19
- hinweis: 'Kein offizielles Angebot einer Feuerwehr oder Leitstelle.',
20
- })
21
-
22
- const jahr = new Date(fassung.gebaut).getUTCFullYear() || new Date().getUTCFullYear()
23
- const gebaut = ref('')
24
- onMounted(() => {
25
- gebaut.value = gebautLesbar()
26
- })
27
- const links = [
28
- {label: 'emberbox.app', to: HUB_URL},
29
- {label: 'Impressum', to: IMPRESSUM_URL},
30
- {label: 'Datenschutz', to: DATENSCHUTZ_URL},
31
- ...(props.hilfe ? [{label: 'Hilfe', to: props.hilfe}] : []),
32
- ]
33
- </script>
34
-
35
- <template>
36
- <footer class="mt-auto border-t border-default">
37
- <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">
38
- <p class="m-0 max-w-sm text-center md:text-left">{{ hinweis }}</p>
39
- <div class="flex flex-col items-center gap-1 text-center">
40
- <p class="m-0 flex flex-wrap items-center justify-center gap-x-3 gap-y-1">
41
- <template v-for="(link, index) in links" :key="link.to">
42
- <span v-if="index > 0" aria-hidden="true">·</span>
43
- <ULink :to="link.to" class="text-default hover:underline">{{ link.label }}</ULink>
44
- </template>
45
- </p>
46
- <ULink :to="quelle" target="_blank" rel="noreferrer noopener"
47
- class="flex items-center gap-1.5 text-default hover:underline">
48
- <UIcon name="i-lucide-github" aria-hidden="true"/>
49
- GitHub
50
- </ULink>
51
- <span>© {{ jahr }} RainbowDashLabs and Contributor</span>
52
- <span>Made with ❤️ and 🏳️‍🌈</span>
53
- <span>Licensed under {{ lizenz }}</span>
54
- <span class="tabular">{{ werkzeug }} {{ fassung.commit }} · built {{ gebaut }}</span>
55
- </div>
56
- </div>
57
- </footer>
58
- </template>
@@ -1,79 +0,0 @@
1
- <script setup lang="ts">
2
- import UButton from '@nuxt/ui/components/Button.vue'
3
- import UPopover from '@nuxt/ui/components/Popover.vue'
4
- import UTooltip from '@nuxt/ui/components/Tooltip.vue'
5
- import {renderSVG} from 'uqr'
6
- import {computed, onBeforeUnmount, ref} from 'vue'
7
- import {inZwischenablage} from '../zwischenablage'
8
-
9
- /**
10
- * Ein Beitrittscode, groß und kopierbar. Mit `link` lässt sich auch die Adresse kopieren, unter
11
- * der man mit dem Code direkt beitritt, und mit `qr` als QR-Code zeigen. `verdeckt` hält den Code
12
- * unscharf, bis er gedrückt gehalten oder per Tastatur fokussiert wird, damit er bei geteiltem
13
- * Bildschirm nicht mitgelesen wird.
14
- */
15
- const props = defineProps<{
16
- titel: string
17
- code: string
18
- link?: string
19
- qr?: boolean
20
- verdeckt?: boolean
21
- }>()
22
-
23
- const ANZEIGE_MS = 1500
24
-
25
- const zeigen = ref(false)
26
- const ergebnis = ref<{ was: 'code' | 'link', gelungen: boolean } | null>(null)
27
- const qrBild = computed(() => renderSVG(props.link ?? props.code, {border: 1}))
28
- let zeitgeber: ReturnType<typeof setTimeout> | undefined
29
-
30
- const meldung = computed(() => ergebnis.value === null
31
- ? ''
32
- : ergebnis.value.gelungen ? 'Kopiert' : 'Kopieren fehlgeschlagen')
33
-
34
- function symbol(was: 'code' | 'link', ruhend: string): string {
35
- if (ergebnis.value?.was !== was) return ruhend
36
- return ergebnis.value.gelungen ? 'i-lucide-check' : 'i-lucide-x'
37
- }
38
-
39
- async function kopieren(was: 'code' | 'link'): Promise<void> {
40
- const gelungen = await inZwischenablage(was === 'link' && props.link ? props.link : props.code)
41
- ergebnis.value = {was, gelungen}
42
- clearTimeout(zeitgeber)
43
- zeitgeber = setTimeout(() => {
44
- ergebnis.value = null
45
- }, ANZEIGE_MS)
46
- }
47
-
48
- onBeforeUnmount(() => clearTimeout(zeitgeber))
49
- </script>
50
-
51
- <template>
52
- <div class="inline-flex flex-col gap-1">
53
- <span class="feld-label">{{ titel }}</span>
54
- <div class="inline-flex items-center gap-1 rounded-sm border border-default bg-default py-1 pl-3 pr-1">
55
- <span class="tabular select-all text-lg font-medium transition-[filter]"
56
- :class="verdeckt && !zeigen ? 'blur-sm' : ''"
57
- :tabindex="verdeckt ? 0 : undefined"
58
- :aria-label="verdeckt ? `${titel}: ${code}` : undefined"
59
- @pointerdown="zeigen = true" @pointerup="zeigen = false" @pointerleave="zeigen = false"
60
- @focus="zeigen = true" @blur="zeigen = false">{{ code }}</span>
61
- <UTooltip :text="ergebnis?.was === 'code' ? meldung : 'Code kopieren'">
62
- <UButton :icon="symbol('code', 'i-lucide-copy')" color="neutral" variant="ghost" size="sm"
63
- :aria-label="`Code ${titel} kopieren`" @click="kopieren('code')"/>
64
- </UTooltip>
65
- <UTooltip v-if="link" :text="ergebnis?.was === 'link' ? meldung : 'Link kopieren'">
66
- <UButton :icon="symbol('link', 'i-lucide-link')" color="neutral" variant="ghost" size="sm"
67
- :aria-label="`Link für ${titel} kopieren`" @click="kopieren('link')"/>
68
- </UTooltip>
69
- <UPopover v-if="qr">
70
- <UButton icon="i-lucide-qr-code" color="neutral" variant="ghost" size="sm" :aria-label="`QR-Code für ${titel}`"/>
71
- <template #content>
72
- <div class="size-56 bg-white p-2 text-black [&>svg]:size-full" role="img" :aria-label="`QR-Code für ${titel}`"
73
- v-html="qrBild"/>
74
- </template>
75
- </UPopover>
76
- <span class="sr-only" role="status">{{ meldung }}</span>
77
- </div>
78
- </div>
79
- </template>
@@ -1,11 +0,0 @@
1
- <script setup lang="ts">
2
- /** Ein Abschnitt der Hilfe mit Überschrift, der mehrere Themen zusammenfasst. */
3
- defineProps<{ titel: string }>()
4
- </script>
5
-
6
- <template>
7
- <section :aria-label="titel" class="flex flex-col gap-4 rounded-sm border border-default bg-default p-5">
8
- <h2 class="headline m-0 text-xl">{{ titel }}</h2>
9
- <slot/>
10
- </section>
11
- </template>
@@ -1,16 +0,0 @@
1
- <script setup lang="ts">
2
- import ULink from '@nuxt/ui/components/Link.vue'
3
-
4
- /** Der Rahmen einer Hilfe-Seite: Titel, Rücksprung und darunter die Abschnitte. */
5
- withDefaults(defineProps<{ titel: string, zurueck?: string }>(), {zurueck: '/'})
6
- </script>
7
-
8
- <template>
9
- <main class="mx-auto flex w-full max-w-4xl flex-col gap-6 p-5">
10
- <header class="flex flex-col items-center gap-1 text-center">
11
- <h1 class="headline m-0 text-3xl">{{ titel }}</h1>
12
- <ULink :to="zurueck" class="text-sm underline">Zurück</ULink>
13
- </header>
14
- <slot/>
15
- </main>
16
- </template>