@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.
- package/README.md +9 -9
- package/dist/vite/logo.d.ts +3 -4
- package/dist/vite/logo.js +15 -16
- package/dist/vite/prerender.d.ts +17 -0
- package/dist/vite/prerender.js +57 -0
- package/dist/vite.d.ts +24 -24
- package/dist/vite.js +46 -46
- package/package.json +6 -6
- package/src/build-info.ts +23 -0
- package/src/clipboard.ts +34 -0
- package/src/components/AppFooter.vue +66 -0
- package/src/{komponenten/AppKopf.vue → components/AppHeader.vue} +13 -13
- package/src/components/CodeDisplay.vue +78 -0
- package/src/components/ConfirmDialog.vue +25 -0
- package/src/{komponenten → components}/EmberboxApp.vue +4 -4
- package/src/{komponenten/HilfeMockup.vue → components/HelpMockup.vue} +3 -3
- package/src/components/HelpPage.vue +16 -0
- package/src/components/HelpSection.vue +11 -0
- package/src/components/HelpTopic.vue +20 -0
- package/src/{komponenten/NeueFassung.vue → components/NewBuildBanner.vue} +8 -8
- package/src/composables/useConfirm.ts +27 -0
- package/src/composables/useNewBuild.ts +45 -0
- package/src/composables/usePolling.ts +55 -57
- package/src/create-app.ts +11 -0
- package/src/index.ts +22 -21
- package/src/page.ts +81 -0
- package/src/prerender.ts +23 -0
- package/src/{stil.css → style.css} +58 -58
- package/src/urls.ts +8 -0
- package/src/vite/logo.ts +16 -17
- package/src/vite/prerender.ts +72 -0
- package/src/vite.ts +55 -55
- package/dist/vite/vorrendern.d.ts +0 -17
- package/dist/vite/vorrendern.js +0 -57
- package/src/adressen.ts +0 -8
- package/src/app.ts +0 -11
- package/src/composables/useNeueFassung.ts +0 -45
- package/src/composables/useRueckfrage.ts +0 -27
- package/src/fassung.ts +0 -23
- package/src/komponenten/AppFuss.vue +0 -58
- package/src/komponenten/CodeAnzeige.vue +0 -79
- package/src/komponenten/HilfeAbschnitt.vue +0 -11
- package/src/komponenten/HilfeSeite.vue +0 -16
- package/src/komponenten/HilfeThema.vue +0 -20
- package/src/komponenten/Rueckfrage.vue +0 -24
- package/src/seite.ts +0 -81
- package/src/vite/vorrendern.ts +0 -72
- package/src/vorrendern.ts +0 -24
- package/src/zwischenablage.ts +0 -34
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @emberbox/ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
13
|
-
[README
|
|
12
|
+
Setup and examples are in the
|
|
13
|
+
[repository README](https://github.com/rainbowdashlabs/emberbox#readme).
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## License
|
|
16
16
|
|
|
17
|
-
MIT.
|
|
18
|
-
|
|
17
|
+
MIT. The logo pictograms in `logos/` come from [Lucide](https://lucide.dev) (ISC); both license
|
|
18
|
+
texts are in `LICENSE`.
|
package/dist/vite/logo.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
2
|
+
/** The tools for which `@emberbox/ui` ships a logo. */
|
|
3
3
|
export type Logo = 'emberbox' | 'alarmzettel' | 'statussim' | 'calltaker';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
|
18
|
+
const files = logoFiles(logo);
|
|
20
19
|
return {
|
|
21
20
|
name: 'emberbox:logo',
|
|
22
21
|
configureServer(server) {
|
|
23
|
-
server.middlewares.use((
|
|
24
|
-
const name =
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
36
|
-
this.emitFile({ type: 'asset', fileName: name, source: readFileSync(
|
|
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
|
|
5
|
-
export {
|
|
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
|
-
/**
|
|
8
|
-
export interface
|
|
9
|
-
/** `false`
|
|
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
|
-
/**
|
|
11
|
+
/** Additional Nuxt UI settings of the tool, applied on top of the Emberbox defaults. */
|
|
12
12
|
ui?: NuxtUIOptions['ui'];
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/**
|
|
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
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** Which public pages are prerendered at build time; needs `url`. */
|
|
18
|
+
prerender?: PrerenderOptions;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
|
24
|
+
export declare const OWN_ICONS: string[];
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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
|
|
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
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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
|
-
*
|
|
36
|
-
* `@emberbox/ui
|
|
37
|
-
*
|
|
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(
|
|
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 {
|
|
6
|
-
export {
|
|
7
|
-
const
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
|
12
|
+
const DEFAULTS = {
|
|
13
13
|
colors: {
|
|
14
|
-
primary: '
|
|
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: '
|
|
24
|
+
label: 'field-label',
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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
|
|
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
|
-
*
|
|
38
|
-
*
|
|
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
|
|
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
|
-
*
|
|
52
|
-
*
|
|
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
|
|
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
|
-
*
|
|
57
|
-
* `COMMIT
|
|
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
|
|
71
|
-
*
|
|
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
|
|
73
|
+
const BUILD_INFO = { commit: commit(), builtAt: process.env.BUILD_TIME || new Date().toISOString() };
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
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
|
-
*
|
|
80
|
-
* `@emberbox/ui
|
|
81
|
-
*
|
|
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(
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
throw new Error('emberbox():
|
|
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:
|
|
91
|
-
theme: { colors:
|
|
92
|
-
ui: defu(
|
|
93
|
-
icon: { clientBundle: { scan:
|
|
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(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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:
|
|
110
|
+
{ tag: 'script', children: COLOR_MODE_SCRIPT, injectTo: 'head' },
|
|
111
111
|
],
|
|
112
|
-
generateBundle(
|
|
113
|
-
if (
|
|
114
|
-
this.emitFile({ type: 'asset', fileName: '
|
|
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
|
-
|
|
119
|
-
|
|
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.
|
|
4
|
-
"description": "
|
|
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
|
-
"./
|
|
19
|
+
"./prerender": "./src/prerender.ts",
|
|
20
20
|
"./vite": {
|
|
21
21
|
"types": "./dist/vite.d.ts",
|
|
22
22
|
"import": "./dist/vite.js"
|
|
23
23
|
},
|
|
24
|
-
"./
|
|
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
|
|
31
|
-
"logos": "node scripts/logos
|
|
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
|
+
}
|
package/src/clipboard.ts
ADDED
|
@@ -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 '../
|
|
5
|
+
import {HUB_URL} from '../urls'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
-
|
|
15
|
-
|
|
14
|
+
subtitle?: string
|
|
15
|
+
home?: string
|
|
16
16
|
logo?: string
|
|
17
|
-
}>(), {
|
|
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="
|
|
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="
|
|
31
|
+
<span v-if="subtitle" class="eyebrow hidden sm:inline">{{ subtitle }}</span>
|
|
32
32
|
</ULink>
|
|
33
33
|
</div>
|
|
34
|
-
<nav v-if="$slots.
|
|
35
|
-
<slot name="
|
|
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="
|
|
38
|
+
<slot name="actions"/>
|
|
39
39
|
<UColorModeButton/>
|
|
40
|
-
<slot name="
|
|
40
|
+
<slot name="account"/>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="h-[3px] bg-signal"/>
|