@emberbox/ui 0.0.0-stage → 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/LICENSE +44 -0
- package/README.md +17 -2
- package/dist/vite/logo.d.ts +8 -0
- package/dist/vite/logo.js +43 -0
- package/dist/vite/prerender.d.ts +17 -0
- package/dist/vite/prerender.js +57 -0
- package/dist/vite.d.ts +39 -0
- package/dist/vite.js +121 -0
- package/logos/alarmzettel-180.png +0 -0
- package/logos/alarmzettel-512.png +0 -0
- package/logos/alarmzettel.svg +1 -0
- package/logos/calltaker-180.png +0 -0
- package/logos/calltaker-512.png +0 -0
- package/logos/calltaker.svg +1 -0
- package/logos/emberbox-180.png +0 -0
- package/logos/emberbox-512.png +0 -0
- package/logos/emberbox.svg +1 -0
- package/logos/statussim-180.png +0 -0
- package/logos/statussim-512.png +0 -0
- package/logos/statussim.svg +1 -0
- package/package.json +62 -4
- package/src/build-info.ts +23 -0
- package/src/clipboard.ts +34 -0
- package/src/components/AppFooter.vue +66 -0
- package/src/components/AppHeader.vue +45 -0
- package/src/components/CodeDisplay.vue +78 -0
- package/src/components/ConfirmDialog.vue +25 -0
- package/src/components/EmberboxApp.vue +22 -0
- package/src/components/HelpMockup.vue +15 -0
- package/src/components/HelpPage.vue +16 -0
- package/src/components/HelpSection.vue +11 -0
- package/src/components/HelpTopic.vue +20 -0
- package/src/components/NewBuildBanner.vue +24 -0
- package/src/composables/useConfirm.ts +27 -0
- package/src/composables/useNewBuild.ts +45 -0
- package/src/composables/usePolling.ts +91 -0
- package/src/create-app.ts +11 -0
- package/src/index.ts +34 -0
- package/src/page.ts +81 -0
- package/src/prerender.ts +23 -0
- package/src/style.css +172 -0
- package/src/urls.ts +8 -0
- package/src/vite/logo.ts +49 -0
- package/src/vite/prerender.ts +72 -0
- package/src/vite.ts +145 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RainbowDashLabs and Contributor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The pictograms in logos/ are derived from Lucide (https://lucide.dev) and are
|
|
26
|
+
distributed under the following license:
|
|
27
|
+
|
|
28
|
+
ISC License
|
|
29
|
+
|
|
30
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of
|
|
31
|
+
Feather (MIT). All other copyright (c) for Lucide are held by Lucide
|
|
32
|
+
Contributors 2022.
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
36
|
+
copyright notice and this permission notice appear in all copies.
|
|
37
|
+
|
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
39
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
40
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
41
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
42
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
43
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
44
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @emberbox/ui
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @emberbox/ui
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Setup and examples are in the
|
|
13
|
+
[repository README](https://github.com/rainbowdashlabs/emberbox#readme).
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
MIT. The logo pictograms in `logos/` come from [Lucide](https://lucide.dev) (ISC); both license
|
|
18
|
+
texts are in `LICENSE`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/** The tools for which `@emberbox/ui` ships a logo. */
|
|
3
|
+
export type Logo = 'emberbox' | 'alarmzettel' | 'statussim' | 'calltaker';
|
|
4
|
+
/**
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
export declare function logoPlugin(logo: Logo): Plugin;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
const LOGOS = fileURLToPath(new URL('../../logos/', import.meta.url));
|
|
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) {
|
|
7
|
+
return {
|
|
8
|
+
'favicon.svg': `${LOGOS}${logo}.svg`,
|
|
9
|
+
'apple-touch-icon.png': `${LOGOS}${logo}-180.png`,
|
|
10
|
+
'logo-512.png': `${LOGOS}${logo}-512.png`,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
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.
|
|
16
|
+
*/
|
|
17
|
+
export function logoPlugin(logo) {
|
|
18
|
+
const files = logoFiles(logo);
|
|
19
|
+
return {
|
|
20
|
+
name: 'emberbox:logo',
|
|
21
|
+
configureServer(server) {
|
|
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));
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
generateBundle() {
|
|
32
|
+
if (this.environment?.config.build.ssr)
|
|
33
|
+
return;
|
|
34
|
+
for (const [name, file] of Object.entries(files)) {
|
|
35
|
+
this.emitFile({ type: 'asset', fileName: name, source: readFileSync(file) });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
transformIndexHtml: () => [
|
|
39
|
+
{ tag: 'link', attrs: { rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' }, injectTo: 'head' },
|
|
40
|
+
{ tag: 'link', attrs: { rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }, injectTo: 'head' },
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -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
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NuxtUIOptions } from '@nuxt/ui/unplugin';
|
|
2
|
+
import type { PluginOption } from 'vite';
|
|
3
|
+
import { type Logo } from './vite/logo.js';
|
|
4
|
+
import { type PrerenderOptions } from './vite/prerender.js';
|
|
5
|
+
export { PAGES_DIR, type PrerenderOptions } from './vite/prerender.js';
|
|
6
|
+
export type { Logo } from './vite/logo.js';
|
|
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
|
+
router?: boolean;
|
|
11
|
+
/** Additional Nuxt UI settings of the tool, applied on top of the Emberbox defaults. */
|
|
12
|
+
ui?: NuxtUIOptions['ui'];
|
|
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
|
+
logo?: Logo;
|
|
17
|
+
/** Which public pages are prerendered at build time; needs `url`. */
|
|
18
|
+
prerender?: PrerenderOptions;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
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
|
+
*/
|
|
24
|
+
export declare const OWN_ICONS: string[];
|
|
25
|
+
/**
|
|
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
|
+
*/
|
|
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
|
+
/**
|
|
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
|
+
*
|
|
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
|
+
*/
|
|
39
|
+
export declare function emberbox(options?: EmberboxOptions): PluginOption[];
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import ui from '@nuxt/ui/vite';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { logoPlugin } from './vite/logo.js';
|
|
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
|
+
/**
|
|
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
|
+
*/
|
|
12
|
+
const DEFAULTS = {
|
|
13
|
+
colors: {
|
|
14
|
+
primary: 'steel',
|
|
15
|
+
signal: 'signal',
|
|
16
|
+
success: 'green',
|
|
17
|
+
info: 'blue',
|
|
18
|
+
warning: 'amber',
|
|
19
|
+
error: 'signal',
|
|
20
|
+
neutral: 'slate',
|
|
21
|
+
},
|
|
22
|
+
formField: {
|
|
23
|
+
slots: {
|
|
24
|
+
label: 'field-label',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
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
|
+
*/
|
|
32
|
+
const ICON_SCAN = {
|
|
33
|
+
globInclude: ['**/*.{vue,ts,tsx,js,jsx}'],
|
|
34
|
+
globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*', '**/*.d.ts'],
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
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
|
+
*/
|
|
40
|
+
export const OWN_ICONS = [
|
|
41
|
+
'i-lucide-check',
|
|
42
|
+
'i-lucide-copy',
|
|
43
|
+
'i-lucide-github',
|
|
44
|
+
'i-lucide-layout-grid',
|
|
45
|
+
'i-lucide-link',
|
|
46
|
+
'i-lucide-qr-code',
|
|
47
|
+
'i-lucide-rotate-cw',
|
|
48
|
+
'i-lucide-x',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
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
|
+
*/
|
|
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
|
+
/**
|
|
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
|
+
*/
|
|
59
|
+
function commit() {
|
|
60
|
+
if (process.env.COMMIT)
|
|
61
|
+
return process.env.COMMIT;
|
|
62
|
+
try {
|
|
63
|
+
return execSync('git rev-parse --short HEAD', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return 'dev';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
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
|
+
*/
|
|
73
|
+
const BUILD_INFO = { commit: commit(), builtAt: process.env.BUILD_TIME || new Date().toISOString() };
|
|
74
|
+
/**
|
|
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
|
+
*
|
|
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
|
+
*/
|
|
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
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
ui({
|
|
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
|
+
scanPackages: ['@emberbox/ui'],
|
|
95
|
+
}),
|
|
96
|
+
{
|
|
97
|
+
name: 'emberbox',
|
|
98
|
+
config: () => ({
|
|
99
|
+
define: {
|
|
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
|
+
},
|
|
105
|
+
optimizeDeps: { exclude: ['@emberbox/ui', '@iconify/vue'] },
|
|
106
|
+
resolve: { dedupe: ['vue', 'vue-router', '@nuxt/ui'] },
|
|
107
|
+
ssr: { noExternal: ['@emberbox/ui', '@nuxt/ui'] },
|
|
108
|
+
}),
|
|
109
|
+
transformIndexHtml: () => [
|
|
110
|
+
{ tag: 'script', children: COLOR_MODE_SCRIPT, injectTo: 'head' },
|
|
111
|
+
],
|
|
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
|
+
}
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
options.logo ? logoPlugin(options.logo) : false,
|
|
119
|
+
options.prerender && url ? prerenderPlugin(options.prerender, url) : false,
|
|
120
|
+
];
|
|
121
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2m4 7h4m-4 5h4m-8-5h.01M8 16h.01"/></g></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2z"/><path d="M21 16v2a4 4 0 0 1-4 4h-5"/></g></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12v4m0-10V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2m9 0a2 2 0 0 1 1.414.586l3 3A2 2 0 0 1 22 11v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 .586-1.414l3-3A2 2 0 0 1 7 6zM2 14h20M8 12v4"/></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M4.9 16.1C1 12.2 1 5.8 4.9 1.9m2.9 2.8a6.14 6.14 0 0 0-.8 7.5"/><circle cx="12" cy="9" r="2"/><path d="M16.2 4.8c2 2 2.26 5.11.8 7.47M19.1 1.9a9.96 9.96 0 0 1 0 14.1m-9.6 2h5M8 22l4-11l4 11"/></g></g></svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emberbox/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shared look and building blocks of the Emberbox tools, built on Nuxt UI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/rainbowdashlabs/emberbox.git",
|
|
10
|
+
"directory": "packages/ui"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"dist",
|
|
15
|
+
"logos"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/index.ts",
|
|
19
|
+
"./prerender": "./src/prerender.ts",
|
|
20
|
+
"./vite": {
|
|
21
|
+
"types": "./dist/vite.d.ts",
|
|
22
|
+
"import": "./dist/vite.js"
|
|
23
|
+
},
|
|
24
|
+
"./style.css": "./src/style.css",
|
|
25
|
+
"./logos/*": "./logos/*"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.vite.json",
|
|
29
|
+
"typecheck": "vue-tsc -b",
|
|
30
|
+
"icons": "node scripts/check-icons.mjs",
|
|
31
|
+
"logos": "node scripts/build-logos.mjs",
|
|
32
|
+
"prepack": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@fontsource/barlow": "^5.3.0",
|
|
36
|
+
"@fontsource/barlow-condensed": "^5.3.0",
|
|
37
|
+
"@fontsource/ibm-plex-mono": "^5.3.0",
|
|
38
|
+
"@iconify-json/lucide": "^1.2.159",
|
|
39
|
+
"@iconify/vue": "^5.0.5",
|
|
40
|
+
"@internationalized/date": "^3.12.4",
|
|
41
|
+
"@nuxt/ui": "^4.13.1",
|
|
42
|
+
"@unhead/vue": "^3.4.3",
|
|
43
|
+
"@vueuse/core": "^14.4.0",
|
|
44
|
+
"defu": "^6.1.7",
|
|
45
|
+
"tailwindcss": "^4.3.5",
|
|
46
|
+
"uqr": "^0.1.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"vite": "^7.0.0 || ^8.0.0",
|
|
50
|
+
"vue": "^3.5.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^24.0.0",
|
|
54
|
+
"@vue/tsconfig": "^0.9.1",
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"vite": "^8.3.8",
|
|
57
|
+
"vue": "^3.5.46",
|
|
58
|
+
"vue-tsc": "^3.3.14"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"provenance": true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -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>
|
|
@@ -0,0 +1,45 @@
|
|
|
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 UColorModeButton from '@nuxt/ui/components/color-mode/ColorModeButton.vue'
|
|
5
|
+
import {HUB_URL} from '../urls'
|
|
6
|
+
|
|
7
|
+
/**
|
|
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
|
+
*/
|
|
12
|
+
withDefaults(defineProps<{
|
|
13
|
+
name: string
|
|
14
|
+
subtitle?: string
|
|
15
|
+
home?: string
|
|
16
|
+
logo?: string
|
|
17
|
+
}>(), {home: '/'})
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<header class="bg-default">
|
|
22
|
+
<div class="mx-auto flex w-full max-w-[1560px] flex-wrap items-center gap-x-6 gap-y-2 px-4 py-2 md:h-15 md:px-6">
|
|
23
|
+
<div class="flex shrink-0 items-center gap-3">
|
|
24
|
+
<ULink :to="HUB_URL" class="flex size-8 items-center justify-center rounded-sm text-muted hover:text-highlighted"
|
|
25
|
+
aria-label="Alle Werkzeuge auf emberbox.app">
|
|
26
|
+
<img v-if="logo" :src="logo" alt="" class="size-8 rounded-sm">
|
|
27
|
+
<UIcon v-else name="i-lucide-layout-grid" class="size-5"/>
|
|
28
|
+
</ULink>
|
|
29
|
+
<ULink :to="home" class="flex items-baseline gap-2 text-highlighted hover:text-highlighted">
|
|
30
|
+
<span class="font-condensed text-xl font-bold uppercase tracking-wide">{{ name }}</span>
|
|
31
|
+
<span v-if="subtitle" class="eyebrow hidden sm:inline">{{ subtitle }}</span>
|
|
32
|
+
</ULink>
|
|
33
|
+
</div>
|
|
34
|
+
<nav v-if="$slots.nav" class="flex grow flex-wrap gap-x-5 gap-y-1">
|
|
35
|
+
<slot name="nav"/>
|
|
36
|
+
</nav>
|
|
37
|
+
<div class="ml-auto flex shrink-0 items-center gap-2">
|
|
38
|
+
<slot name="actions"/>
|
|
39
|
+
<UColorModeButton/>
|
|
40
|
+
<slot name="account"/>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="h-[3px] bg-signal"/>
|
|
44
|
+
</header>
|
|
45
|
+
</template>
|