@monster-orange/den-ui 0.0.0-stage → 0.5.1
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 +21 -0
- package/README.md +75 -2
- package/package.json +21 -4
- package/src/base.css +80 -0
- package/src/busy-words.js +65 -0
- package/src/busy.js +592 -0
- package/src/dialog.js +217 -0
- package/src/fonts/OFL.txt +97 -0
- package/src/fonts/rubik-latin-400-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-500-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-ext-400-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-ext-500-normal.woff2 +0 -0
- package/src/fonts/space-mono-latin-400-normal.woff2 +0 -0
- package/src/fonts/space-mono-latin-ext-400-normal.woff2 +0 -0
- package/src/fonts.css +71 -0
- package/src/time.js +242 -0
- package/src/tokens.css +150 -0
- package/src/update-pill.css +32 -0
- package/src/update-pill.js +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Monster Orange
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# den-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The UI kit Den is built from: design tokens, self-hosted fonts and, over
|
|
4
|
+
time, the components more than one product needs. It is framework-free:
|
|
5
|
+
plain CSS custom properties, ES modules and custom elements, with no build
|
|
6
|
+
step at runtime.
|
|
7
|
+
|
|
8
|
+
It lives in Den's repository as a workspace package and ships inside Den.
|
|
9
|
+
Another product consumes it by pinning an exact version and bundling its
|
|
10
|
+
own copy, so a page never mixes two versions.
|
|
11
|
+
|
|
12
|
+
## What's in it
|
|
13
|
+
|
|
14
|
+
- `src/tokens.css`: colour (light and dark), type, radius, shadow,
|
|
15
|
+
spacing, motion, layers and touch targets, as CSS custom properties.
|
|
16
|
+
Light is the default. `data-mode="light"` or `"dark"` on `<html>` picks a
|
|
17
|
+
mode; with none set, the kit follows `prefers-color-scheme`. Every rule
|
|
18
|
+
has zero specificity (`:where()`), so a theme laid on top always wins.
|
|
19
|
+
- `src/fonts.css`: Rubik (400, 500) and Space Mono (400), latin and
|
|
20
|
+
latin-ext, as woff2, `font-display: swap`. Nothing is fetched from a
|
|
21
|
+
third party. Japanese uses the system's fonts.
|
|
22
|
+
- `src/base.css`: one reduced-motion rule (every duration token goes to 0) and Japanese line breaking.
|
|
23
|
+
- `src/time.js` (export `./time`): date-times for people, in their own
|
|
24
|
+
time zone. `formatTime(iso, opts)` gives the text, `timeHtml(iso, opts)`
|
|
25
|
+
a `<time>` with the UTC stamp in `datetime` and the full local time and
|
|
26
|
+
zone in `title`. `opts`: `style` (`datetime`, `date`, `time`,
|
|
27
|
+
`relative`), `seconds`, `zone`, `locale`, `now`. The zone is `opts.zone`,
|
|
28
|
+
else `<html data-den-tz>`, else `setTimeZone`'s pick, else the browser's.
|
|
29
|
+
`upgradeTimes(root)` draws every `time[data-den-time]` again after a
|
|
30
|
+
change. The year shows only when it isn't this year. Pure: it runs in
|
|
31
|
+
Node too.
|
|
32
|
+
- `src/update-pill.js` and `src/update-pill.css` (exports `./update-pill`,
|
|
33
|
+
`./update-pill.css`): the shared update pill, a see-through pill over the
|
|
34
|
+
top bar that says a new version is available, with Reload and a dismiss.
|
|
35
|
+
|
|
36
|
+
import { showUpdate } from "/kit/update-pill.js"; // and update-pill.css
|
|
37
|
+
const pill = showUpdate({
|
|
38
|
+
message: "A new version of Den is available.",
|
|
39
|
+
reloadLabel: "Reload", dismissLabel: "Not now", cancelLabel: "Cancel",
|
|
40
|
+
askFirst: () => (hasUnsavedText()
|
|
41
|
+
? { message: "You have unsaved text on this page. Reload anyway?" }
|
|
42
|
+
: null),
|
|
43
|
+
onReload: () => location.reload(),
|
|
44
|
+
onDismiss: () => rememberDismissed(version),
|
|
45
|
+
});
|
|
46
|
+
pill.hide();
|
|
47
|
+
|
|
48
|
+
No full-width strip: the pill's own fill is the surface at 20% with
|
|
49
|
+
`blur(3px) saturate(1.4)`, so the bar shows through it, and the bar
|
|
50
|
+
beside it stays clickable. When `askFirst` returns a message (unsaved
|
|
51
|
+
text, say), Reload asks once and the × reads Cancel. A text past one line
|
|
52
|
+
turns the pill into a card. Knobs, set on `.den-upd`: `--upd-pad-y`
|
|
53
|
+
(default 8px) and `--upd-top` (default: a 50px pill centred on a 48px
|
|
54
|
+
bar, top -1px; for a 56px bar,
|
|
55
|
+
`calc(env(safe-area-inset-top, 0px) + 3px)`). It reads `--surface`,
|
|
56
|
+
`--text`, `--muted`, `--border-strong`, `--accent`, `--accent-text` and
|
|
57
|
+
`--upd-shadow`.
|
|
58
|
+
|
|
59
|
+
## Themes
|
|
60
|
+
|
|
61
|
+
A theme may override every colour in both modes, the shadow, the bar,
|
|
62
|
+
type, radius, radius-button, density and fonts. It never overrides
|
|
63
|
+
spacing, motion or layers, so layouts stay the same.
|
|
64
|
+
|
|
65
|
+
## Rules
|
|
66
|
+
|
|
67
|
+
- Components use tokens only: a test fails on a raw colour outside
|
|
68
|
+
`tokens.css`.
|
|
69
|
+
- Every text and background pair passes WCAG AA in both modes (4.5:1 for
|
|
70
|
+
text, 3:1 for marks); status pills are checked on their own tint.
|
|
71
|
+
- The fonts stay within 120 KB.
|
|
72
|
+
|
|
73
|
+
## Licence
|
|
74
|
+
|
|
75
|
+
MIT (`LICENSE`). The fonts are under the SIL Open Font License 1.1
|
|
76
|
+
(`src/fonts/OFL.txt`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monster-orange/den-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Den's UI kit: tokens, fonts and shared components, framework-free",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./tokens.css": "./src/tokens.css",
|
|
9
|
+
"./fonts.css": "./src/fonts.css",
|
|
10
|
+
"./base.css": "./src/base.css",
|
|
11
|
+
"./time": "./src/time.js",
|
|
12
|
+
"./update-pill": "./src/update-pill.js",
|
|
13
|
+
"./update-pill.css": "./src/update-pill.css",
|
|
14
|
+
"./busy": "./src/busy.js",
|
|
15
|
+
"./busy-words": "./src/busy-words.js",
|
|
16
|
+
"./dialog": "./src/dialog.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"src/",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/src/base.css
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* den-ui base: what every page using the kit gets. Load after tokens.css.
|
|
3
|
+
* Zero specificity (:where), so a product's own rules win.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* Motion: every animation and transition uses the duration tokens, so
|
|
7
|
+
one rule stops them all when the person asks for less motion. */
|
|
8
|
+
@media (prefers-reduced-motion: reduce) {
|
|
9
|
+
:where(:root) {
|
|
10
|
+
--dur-fast: 0ms;
|
|
11
|
+
--dur: 0ms;
|
|
12
|
+
--dur-cue: 0ms;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Japanese: keep words whole, break a run only where it would overflow,
|
|
17
|
+
strict kinsoku. Chromium keeps phrases whole (auto-phrase); WebKit has
|
|
18
|
+
keep-all. break-word, not anywhere: anywhere lets a table column shrink
|
|
19
|
+
to one character, so a short header breaks inside its word. */
|
|
20
|
+
:where(:lang(ja)) {
|
|
21
|
+
word-break: keep-all;
|
|
22
|
+
overflow-wrap: break-word;
|
|
23
|
+
line-break: strict;
|
|
24
|
+
}
|
|
25
|
+
@supports (word-break: auto-phrase) {
|
|
26
|
+
:where(:lang(ja)) {
|
|
27
|
+
word-break: auto-phrase;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* An open modal dialog is as tall as its content, and centred. The
|
|
32
|
+
browser's own box (inset-block 0, height fit-content) is not enough: on
|
|
33
|
+
an iPad a pop-up still ran the window's full height, even with height:
|
|
34
|
+
fit-content. So the box is placed by hand and owes nothing to the
|
|
35
|
+
browser's inset or height:
|
|
36
|
+
- fixed, top 50%, moved up by half its own height; bottom auto, so no
|
|
37
|
+
inset pair can stretch it;
|
|
38
|
+
- height auto, capped at the window less 32 px (vh first, for an older
|
|
39
|
+
iPad without dvh), and it scrolls inside.
|
|
40
|
+
Each dialog keeps its own width and its own smaller max-height. Zero
|
|
41
|
+
specificity, so a sheet's own rules win; a bottom sheet sets
|
|
42
|
+
transform: none (Report at phone width). A dialog placed by its anchor
|
|
43
|
+
(.den-pop, .den-toplayer: the admin-password prompt) is left alone. */
|
|
44
|
+
:where(dialog:modal:not(.den-pop):not(.den-toplayer)) {
|
|
45
|
+
position: fixed;
|
|
46
|
+
inset-block: auto;
|
|
47
|
+
inset-inline: 0;
|
|
48
|
+
top: 50%;
|
|
49
|
+
transform: translateY(-50%);
|
|
50
|
+
margin: 0 auto;
|
|
51
|
+
height: auto;
|
|
52
|
+
max-height: calc(100vh - 32px);
|
|
53
|
+
max-height: calc(100dvh - 32px);
|
|
54
|
+
overflow: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* UK-3, one placement for Report (issue 94). Where it sits is the kit's,
|
|
58
|
+
for every page and pop-up, in Den and in any product on the kit:
|
|
59
|
+
- top bar: right group, in the order Report, bell, account, at every
|
|
60
|
+
width; the shortcut shows beside the word only where there is room
|
|
61
|
+
(the tooltip always has it);
|
|
62
|
+
- dialog, drawer and popover: first in the footer, on the left, and
|
|
63
|
+
the pop-up's other buttons follow;
|
|
64
|
+
- never only in a menu. */
|
|
65
|
+
:where(.den-rb-top) {
|
|
66
|
+
flex: none;
|
|
67
|
+
margin: 0;
|
|
68
|
+
}
|
|
69
|
+
@media (max-width: 720px) {
|
|
70
|
+
:where(.den-rb-top kbd) {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
:where(.den-rb-in) {
|
|
75
|
+
order: -1;
|
|
76
|
+
margin-right: auto;
|
|
77
|
+
}
|
|
78
|
+
:where(.den-rb-foot) {
|
|
79
|
+
justify-content: flex-start;
|
|
80
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UK-2: the working pop-up's shared words (Settled 9), in every language
|
|
3
|
+
* the kit speaks. Each product registers its own actions' words (working,
|
|
4
|
+
* success, failure) with registerActions; a product may add or override a
|
|
5
|
+
* shared key through configureBusy({ words }).
|
|
6
|
+
*/
|
|
7
|
+
export const BUSY_WORDS = {
|
|
8
|
+
en: {
|
|
9
|
+
wait: "Waiting for {who}…",
|
|
10
|
+
still: "Still working ({s} s). You can leave this open.",
|
|
11
|
+
still_running: "Still running. Check the page, then check again.",
|
|
12
|
+
done: "Done",
|
|
13
|
+
close: "Close",
|
|
14
|
+
retry: "Try again",
|
|
15
|
+
check: "Check again",
|
|
16
|
+
report: "Report",
|
|
17
|
+
details: "Details",
|
|
18
|
+
log: "Open the log",
|
|
19
|
+
noans_t: "No answer from {who} yet.",
|
|
20
|
+
noans_b: "It may still finish. Check the page before you try again.",
|
|
21
|
+
noans_unknown:
|
|
22
|
+
"{who} has no record of this request any more. Check the page before you try again.",
|
|
23
|
+
err_code: "{who} answered with an error ({code}).",
|
|
24
|
+
network: "Couldn't reach {who}.",
|
|
25
|
+
},
|
|
26
|
+
es: {
|
|
27
|
+
wait: "Esperando a {who}…",
|
|
28
|
+
still: "Sigue trabajando ({s} s). Puedes dejar esto abierto.",
|
|
29
|
+
still_running: "Sigue en curso. Revisa la página y vuelve a comprobar.",
|
|
30
|
+
done: "Listo",
|
|
31
|
+
close: "Cerrar",
|
|
32
|
+
retry: "Intentar de nuevo",
|
|
33
|
+
check: "Volver a comprobar",
|
|
34
|
+
report: "Informar",
|
|
35
|
+
details: "Detalles",
|
|
36
|
+
log: "Abrir el registro",
|
|
37
|
+
noans_t: "{who} aún no responde.",
|
|
38
|
+
noans_b:
|
|
39
|
+
"Puede que aún termine. Revisa la página antes de intentarlo de nuevo.",
|
|
40
|
+
noans_unknown:
|
|
41
|
+
"{who} ya no tiene registro de esta solicitud. Revisa la página antes de intentarlo de nuevo.",
|
|
42
|
+
err_code: "{who} respondió con un error ({code}).",
|
|
43
|
+
network: "No se pudo contactar con {who}.",
|
|
44
|
+
},
|
|
45
|
+
ja: {
|
|
46
|
+
wait: "{who} の応答を待っています…",
|
|
47
|
+
still: "処理中です({s} 秒)。このまま開いておけます。",
|
|
48
|
+
still_running:
|
|
49
|
+
"まだ処理中です。ページを確認してから、もう一度確認してください。",
|
|
50
|
+
done: "完了",
|
|
51
|
+
close: "閉じる",
|
|
52
|
+
retry: "もう一度試す",
|
|
53
|
+
check: "もう一度確認",
|
|
54
|
+
report: "報告",
|
|
55
|
+
details: "詳細",
|
|
56
|
+
log: "ログを開く",
|
|
57
|
+
noans_t: "{who} からまだ応答がありません。",
|
|
58
|
+
noans_b:
|
|
59
|
+
"まだ完了する可能性があります。もう一度試す前にページを確認してください。",
|
|
60
|
+
noans_unknown:
|
|
61
|
+
"{who} にこのリクエストの記録がもうありません。もう一度試す前にページを確認してください。",
|
|
62
|
+
err_code: "{who} がエラーを返しました({code})。",
|
|
63
|
+
network: "{who} に接続できませんでした。",
|
|
64
|
+
},
|
|
65
|
+
};
|