@mondarth/ui 0.0.0-stage → 0.0.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/dist/AppShell.svelte +107 -0
  3. package/dist/AppShell.svelte.d.ts +14 -0
  4. package/dist/Badge.svelte +54 -0
  5. package/dist/Badge.svelte.d.ts +9 -0
  6. package/dist/Brand.svelte +62 -0
  7. package/dist/Brand.svelte.d.ts +14 -0
  8. package/dist/Button.svelte +73 -0
  9. package/dist/Button.svelte.d.ts +10 -0
  10. package/dist/Callout.svelte +40 -0
  11. package/dist/Callout.svelte.d.ts +9 -0
  12. package/dist/CalloutMark.svelte +104 -0
  13. package/dist/CalloutMark.svelte.d.ts +14 -0
  14. package/dist/Checkbox.svelte +60 -0
  15. package/dist/Checkbox.svelte.d.ts +15 -0
  16. package/dist/ContextMenu.svelte +151 -0
  17. package/dist/ContextMenu.svelte.d.ts +15 -0
  18. package/dist/Dialog.svelte +73 -0
  19. package/dist/Dialog.svelte.d.ts +14 -0
  20. package/dist/DrawerLayout.svelte +182 -0
  21. package/dist/DrawerLayout.svelte.d.ts +26 -0
  22. package/dist/DrawerToggle.svelte +66 -0
  23. package/dist/DrawerToggle.svelte.d.ts +11 -0
  24. package/dist/ExpandableList.svelte +164 -0
  25. package/dist/ExpandableList.svelte.d.ts +46 -0
  26. package/dist/Field.svelte +109 -0
  27. package/dist/Field.svelte.d.ts +28 -0
  28. package/dist/FooterLinks.svelte +54 -0
  29. package/dist/FooterLinks.svelte.d.ts +15 -0
  30. package/dist/LanguagePicker.svelte +48 -0
  31. package/dist/LanguagePicker.svelte.d.ts +33 -0
  32. package/dist/Logo.svelte +36 -0
  33. package/dist/Logo.svelte.d.ts +12 -0
  34. package/dist/Notice.svelte +116 -0
  35. package/dist/Notice.svelte.d.ts +13 -0
  36. package/dist/Panel.svelte +41 -0
  37. package/dist/Panel.svelte.d.ts +11 -0
  38. package/dist/Prose.svelte +23 -0
  39. package/dist/Prose.svelte.d.ts +8 -0
  40. package/dist/ReturnLink.svelte +50 -0
  41. package/dist/ReturnLink.svelte.d.ts +12 -0
  42. package/dist/SplitPanes.svelte +92 -0
  43. package/dist/SplitPanes.svelte.d.ts +21 -0
  44. package/dist/Splitter.svelte +160 -0
  45. package/dist/Splitter.svelte.d.ts +20 -0
  46. package/dist/Table.svelte +65 -0
  47. package/dist/Table.svelte.d.ts +12 -0
  48. package/dist/Toast.svelte +143 -0
  49. package/dist/Toast.svelte.d.ts +18 -0
  50. package/dist/TopBar.svelte +68 -0
  51. package/dist/TopBar.svelte.d.ts +19 -0
  52. package/dist/Tree.svelte +367 -0
  53. package/dist/Tree.svelte.d.ts +27 -0
  54. package/dist/UserMenu.svelte +209 -0
  55. package/dist/UserMenu.svelte.d.ts +10 -0
  56. package/dist/WarningMark.svelte +33 -0
  57. package/dist/WarningMark.svelte.d.ts +10 -0
  58. package/dist/context-menu.d.ts +41 -0
  59. package/dist/context-menu.js +80 -0
  60. package/dist/dates.d.ts +37 -0
  61. package/dist/dates.js +69 -0
  62. package/dist/index.d.ts +46 -0
  63. package/dist/index.js +42 -0
  64. package/dist/language.d.ts +7 -0
  65. package/dist/language.js +12 -0
  66. package/dist/remembered.d.ts +30 -0
  67. package/dist/remembered.js +50 -0
  68. package/dist/site.d.ts +7 -0
  69. package/dist/site.js +5 -0
  70. package/dist/theme.css +61 -0
  71. package/dist/top-bar.d.ts +29 -0
  72. package/dist/top-bar.js +2 -0
  73. package/dist/tree.d.ts +29 -0
  74. package/dist/tree.js +27 -0
  75. package/package.json +83 -3
  76. package/README.md +0 -3
@@ -0,0 +1,164 @@
1
+ <!--
2
+ A list that shows its first few entries, and the rest on asking: below them, a light bar with a caret, a button,
3
+ shows the whole list, and stays, to show the first few again. A short list has no bar. The entries hidden are only
4
+ hidden: in a form, their controls are still sent. What the bar says to a screen reader is the application's, in its
5
+ own words, such as "Show all 21 tags". Made `scrollable`, every entry is in the list, which scrolls: collapsed, it is
6
+ as tall as its first few entries, the rest scrolled to; shown in full, it grows no taller than `maxHeight`, so that
7
+ showing them never pushes what comes after it out of sight. Its entries should then hold what the keyboard reaches,
8
+ such as a form's controls, so that the keyboard can scroll it too.
9
+ -->
10
+ <script lang="ts" generics="T">
11
+ import type { Snippet } from 'svelte';
12
+
13
+ interface Props {
14
+ /** The entries, in order. */
15
+ items: readonly T[];
16
+ /** An entry's key, unique among them. */
17
+ key: (item: T) => string;
18
+ /** How many show while it is collapsed. */
19
+ shown?: number;
20
+ /** Whether the whole list shows. */
21
+ open?: boolean;
22
+ /** What the bar says while it would show the rest, such as "Show all 21 tags". */
23
+ moreLabel: string;
24
+ /** What the bar says while it would show fewer, such as "Show fewer tags". */
25
+ lessLabel: string;
26
+ /** Whether the list scrolls: collapsed, within its first few entries' height; in full, within `maxHeight`. */
27
+ scrollable?: boolean;
28
+ /** How tall a scrollable list grows, as a CSS length. */
29
+ maxHeight?: string;
30
+ /** What the list is, for assistive technology, if what is around it does not say. */
31
+ label?: string | undefined;
32
+ /** An entry. */
33
+ item: Snippet<[T]>;
34
+ }
35
+
36
+ let {
37
+ items,
38
+ key,
39
+ shown = 5,
40
+ open = $bindable(false),
41
+ scrollable = false,
42
+ maxHeight = '16rem',
43
+ moreLabel,
44
+ lessLabel,
45
+ label,
46
+ item,
47
+ }: Props = $props();
48
+
49
+ const listId = $props.id();
50
+ const barLabel = $derived(open ? lessLabel : moreLabel);
51
+
52
+ let list: HTMLUListElement | undefined = $state();
53
+ /** How tall the first few entries are, in pixels, which a scrollable list is while collapsed. */
54
+ let collapsedHeight: number | undefined = $state();
55
+
56
+ $effect(() => {
57
+ // Measured again as the entries, how many show, or their sizes, as with the list's width, change.
58
+ const count = Math.min(shown, items.length);
59
+ if (!scrollable || list === undefined) return;
60
+ const element = list;
61
+ const measure = () => {
62
+ const last = element.children[count - 1];
63
+ collapsedHeight = last instanceof HTMLElement ? last.offsetTop + last.offsetHeight : undefined;
64
+ };
65
+ measure();
66
+ // The entries measured, not the list: its height is what is set from them, and watching what one sets loops.
67
+ const observer = new ResizeObserver(measure);
68
+ for (const entry of [...element.children].slice(0, count)) observer.observe(entry);
69
+ return () => {
70
+ observer.disconnect();
71
+ };
72
+ });
73
+
74
+ /** How tall the list may grow, if it scrolls. */
75
+ const height = $derived(
76
+ !scrollable ? undefined : open || collapsedHeight === undefined ? maxHeight : `${String(collapsedHeight)}px`,
77
+ );
78
+ </script>
79
+
80
+ <div class="expandable">
81
+ <ul id={listId} class={['items', { scrollable }]} style:max-height={height} aria-label={label} bind:this={list}>
82
+ {#each items as entry, index (key(entry))}
83
+ <!-- Scrollable, every entry is there, scrolled to; else those past the first few are hidden until asked for. -->
84
+ <li hidden={!scrollable && !open && index >= shown}>{@render item(entry)}</li>
85
+ {/each}
86
+ </ul>
87
+ {#if items.length > shown}
88
+ <button
89
+ type="button"
90
+ class="bar"
91
+ aria-controls={listId}
92
+ aria-expanded={open}
93
+ aria-label={barLabel}
94
+ title={barLabel}
95
+ onclick={() => {
96
+ open = !open;
97
+ }}>
98
+ <svg class="caret" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
99
+ <path d="M3.5 6 8 10.5 12.5 6" fill="none" stroke="currentColor" stroke-width="1.75" />
100
+ </svg>
101
+ </button>
102
+ {/if}
103
+ </div>
104
+
105
+ <style>
106
+ .items {
107
+ display: grid;
108
+ gap: var(--mdr-space-1);
109
+ margin: 0;
110
+ padding: 0;
111
+ list-style: none;
112
+ }
113
+
114
+ /* Its entries measured from its own top. */
115
+ .scrollable {
116
+ position: relative;
117
+ overflow-y: auto;
118
+ overscroll-behavior: contain;
119
+ }
120
+
121
+ .items li[hidden] {
122
+ display: none;
123
+ }
124
+
125
+ /* A light bar the list's width, its caret pointing to where the list goes: down to show more, up to show fewer. */
126
+ .bar {
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ box-sizing: border-box;
131
+ width: 100%;
132
+ margin-block-start: var(--mdr-space-1);
133
+ padding: 0;
134
+ border: none;
135
+ border-radius: var(--mdr-radius-small);
136
+ background: var(--mdr-color-subtle);
137
+ color: var(--mdr-color-text-muted);
138
+ cursor: pointer;
139
+ }
140
+
141
+ .bar:hover {
142
+ color: var(--mdr-color-text);
143
+ background: var(--mdr-color-border);
144
+ }
145
+
146
+ .bar:focus-visible {
147
+ outline: var(--mdr-border-width-focus) solid var(--mdr-color-focus);
148
+ outline-offset: var(--mdr-border-width-thin);
149
+ }
150
+
151
+ .caret {
152
+ transition: transform var(--mdr-duration-fast);
153
+ }
154
+
155
+ [aria-expanded='true'] .caret {
156
+ transform: rotate(180deg);
157
+ }
158
+
159
+ @media (prefers-reduced-motion: reduce) {
160
+ .caret {
161
+ transition: none;
162
+ }
163
+ }
164
+ </style>
@@ -0,0 +1,46 @@
1
+ import type { Snippet } from 'svelte';
2
+ declare function $$render<T>(): {
3
+ props: {
4
+ /** The entries, in order. */
5
+ items: readonly T[];
6
+ /** An entry's key, unique among them. */
7
+ key: (item: T) => string;
8
+ /** How many show while it is collapsed. */
9
+ shown?: number;
10
+ /** Whether the whole list shows. */
11
+ open?: boolean;
12
+ /** What the bar says while it would show the rest, such as "Show all 21 tags". */
13
+ moreLabel: string;
14
+ /** What the bar says while it would show fewer, such as "Show fewer tags". */
15
+ lessLabel: string;
16
+ /** Whether the list scrolls: collapsed, within its first few entries' height; in full, within `maxHeight`. */
17
+ scrollable?: boolean;
18
+ /** How tall a scrollable list grows, as a CSS length. */
19
+ maxHeight?: string;
20
+ /** What the list is, for assistive technology, if what is around it does not say. */
21
+ label?: string | undefined;
22
+ /** An entry. */
23
+ item: Snippet<[T]>;
24
+ };
25
+ exports: {};
26
+ bindings: "open";
27
+ slots: {};
28
+ events: {};
29
+ };
30
+ declare class __sveltets_Render<T> {
31
+ props(): ReturnType<typeof $$render<T>>['props'];
32
+ events(): ReturnType<typeof $$render<T>>['events'];
33
+ slots(): ReturnType<typeof $$render<T>>['slots'];
34
+ bindings(): "open";
35
+ exports(): {};
36
+ }
37
+ interface $$IsomorphicComponent {
38
+ new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
39
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
40
+ } & ReturnType<__sveltets_Render<T>['exports']>;
41
+ <T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
42
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
43
+ }
44
+ declare const ExpandableList: $$IsomorphicComponent;
45
+ type ExpandableList<T> = InstanceType<typeof ExpandableList<T>>;
46
+ export default ExpandableList;
@@ -0,0 +1,109 @@
1
+ <!--
2
+ A field: its label, the control the page gives it, a hint, and the problem with what was entered, each tied to the
3
+ control as a screen reader needs (`for`, `aria-describedby`, `aria-invalid`), the problem announced as an alert. The
4
+ page renders its own control, a native one, so that its form posts as the page's form would, and spreads `field` onto
5
+ it. A required field says so apart from its hint: a mark by its label, and `required` and `aria-required` on its
6
+ control. A wide one's control fills the field's width.
7
+ -->
8
+ <script module lang="ts">
9
+ /** What the field gives its control. */
10
+ export interface FieldControl {
11
+ readonly id: string;
12
+ readonly 'aria-describedby': string | undefined;
13
+ readonly 'aria-invalid': boolean;
14
+ readonly required: boolean;
15
+ readonly 'aria-required': boolean | undefined;
16
+ }
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import type { Snippet } from 'svelte';
21
+
22
+ interface Props {
23
+ /** The control's id, which the label names. */
24
+ id: string;
25
+ /** What the field is. */
26
+ label: string;
27
+ /** What helps to fill it in. */
28
+ hint?: string | undefined;
29
+ /** What is wrong with what was entered, if anything. */
30
+ problem?: string | undefined;
31
+ /** Whether it must be filled in. */
32
+ required?: boolean;
33
+ /** Whether its control fills its width, as in a dialog. */
34
+ wide?: boolean;
35
+ /** The control, given what ties it to the field. */
36
+ children: Snippet<[FieldControl]>;
37
+ }
38
+
39
+ let { id, label, hint, problem, required = false, wide = false, children }: Props = $props();
40
+
41
+ const hintId = $derived(`${id}-hint`);
42
+ const problemId = $derived(`${id}-problem`);
43
+ const field: FieldControl = $derived({
44
+ id,
45
+ 'aria-describedby':
46
+ [hint === undefined ? undefined : hintId, problem === undefined ? undefined : problemId]
47
+ .filter(Boolean)
48
+ .join(' ') || undefined,
49
+ 'aria-invalid': problem !== undefined,
50
+ required,
51
+ 'aria-required': required || undefined,
52
+ });
53
+ </script>
54
+
55
+ <div class="field" class:invalid={problem !== undefined} class:wide>
56
+ <label for={id}>
57
+ {label}{#if required}<span class="required" aria-hidden="true">*</span>{/if}
58
+ </label>
59
+ {@render children(field)}
60
+ {#if hint !== undefined}<p class="hint" id={hintId}>{hint}</p>{/if}
61
+ {#if problem !== undefined}<p class="problem" id={problemId} role="alert">{problem}</p>{/if}
62
+ </div>
63
+
64
+ <style>
65
+ .field {
66
+ display: grid;
67
+ gap: var(--mdr-space-1);
68
+ justify-items: start;
69
+ }
70
+
71
+ label {
72
+ font-weight: var(--mdr-font-weight-strong);
73
+ }
74
+
75
+ /* Said to a screen reader by the control's own required state, not read out. */
76
+ .required {
77
+ margin-inline-start: var(--mdr-space-1);
78
+ color: var(--mdr-color-danger);
79
+ }
80
+
81
+ .wide {
82
+ justify-items: stretch;
83
+ }
84
+
85
+ .wide :global(:is(input, select, textarea)) {
86
+ box-sizing: border-box;
87
+ width: 100%;
88
+ }
89
+
90
+ /* The control is the theme's (theme.css), its edge the danger colour while what was entered is wrong. */
91
+ .invalid :global(:is(input, select, textarea)) {
92
+ border-color: var(--mdr-color-danger);
93
+ }
94
+
95
+ .hint,
96
+ .problem {
97
+ margin: 0;
98
+ font-size: var(--mdr-font-size-small);
99
+ }
100
+
101
+ .hint {
102
+ color: var(--mdr-color-text-muted);
103
+ }
104
+
105
+ .problem {
106
+ color: var(--mdr-color-danger);
107
+ font-weight: var(--mdr-font-weight-strong);
108
+ }
109
+ </style>
@@ -0,0 +1,28 @@
1
+ /** What the field gives its control. */
2
+ export interface FieldControl {
3
+ readonly id: string;
4
+ readonly 'aria-describedby': string | undefined;
5
+ readonly 'aria-invalid': boolean;
6
+ readonly required: boolean;
7
+ readonly 'aria-required': boolean | undefined;
8
+ }
9
+ import type { Snippet } from 'svelte';
10
+ interface Props {
11
+ /** The control's id, which the label names. */
12
+ id: string;
13
+ /** What the field is. */
14
+ label: string;
15
+ /** What helps to fill it in. */
16
+ hint?: string | undefined;
17
+ /** What is wrong with what was entered, if anything. */
18
+ problem?: string | undefined;
19
+ /** Whether it must be filled in. */
20
+ required?: boolean;
21
+ /** Whether its control fills its width, as in a dialog. */
22
+ wide?: boolean;
23
+ /** The control, given what ties it to the field. */
24
+ children: Snippet<[FieldControl]>;
25
+ }
26
+ declare const Field: import("svelte").Component<Props, {}, "">;
27
+ type Field = ReturnType<typeof Field>;
28
+ export default Field;
@@ -0,0 +1,54 @@
1
+ <!--
2
+ The links at the foot of every page, the same on every Mondarth site: the Terms, and what is stored. Each site gives
3
+ their addresses and words; they wrap onto more lines on a narrow page. At the far right, the site's version, as
4
+ `v1.2.3`, which a screen reader hears in the site's own words, such as "Version 1.2.3".
5
+ -->
6
+ <script lang="ts">
7
+ interface Props {
8
+ /** The links, in order. */
9
+ links: readonly { readonly href: string; readonly label: string }[];
10
+ /** The site's version, and what it is said as; none, and none is shown. */
11
+ version?: { readonly number: string; readonly label: string } | undefined;
12
+ }
13
+
14
+ let { links, version }: Props = $props();
15
+ </script>
16
+
17
+ <div class="foot">
18
+ <ul class="links">
19
+ {#each links as link (link.href)}
20
+ <li><a href={link.href}>{link.label}</a></li>
21
+ {/each}
22
+ </ul>
23
+ {#if version}
24
+ <p class="version">
25
+ <span aria-hidden="true">v{version.number}</span>
26
+ <span class="mdr-visually-hidden">{version.label}</span>
27
+ </p>
28
+ {/if}
29
+ </div>
30
+
31
+ <style>
32
+ .foot {
33
+ display: flex;
34
+ flex-wrap: wrap;
35
+ gap: var(--mdr-space-2) var(--mdr-space-5);
36
+ align-items: baseline;
37
+ }
38
+
39
+ .links {
40
+ display: flex;
41
+ flex-wrap: wrap;
42
+ gap: var(--mdr-space-2) var(--mdr-space-5);
43
+ margin: 0;
44
+ padding: 0;
45
+ list-style: none;
46
+ }
47
+
48
+ /* At the far right, however the links wrap. */
49
+ .version {
50
+ margin: 0 0 0 auto;
51
+ font-family: var(--mdr-font-family-mono);
52
+ font-variant-numeric: tabular-nums;
53
+ }
54
+ </style>
@@ -0,0 +1,15 @@
1
+ interface Props {
2
+ /** The links, in order. */
3
+ links: readonly {
4
+ readonly href: string;
5
+ readonly label: string;
6
+ }[];
7
+ /** The site's version, and what it is said as; none, and none is shown. */
8
+ version?: {
9
+ readonly number: string;
10
+ readonly label: string;
11
+ } | undefined;
12
+ }
13
+ declare const FooterLinks: import("svelte").Component<Props, {}, "">;
14
+ type FooterLinks = ReturnType<typeof FooterLinks>;
15
+ export default FooterLinks;
@@ -0,0 +1,48 @@
1
+ <!--
2
+ The language picker: every language the application is in, each named in itself, the one the page is in chosen.
3
+ -->
4
+ <script lang="ts" generics="L extends string">
5
+ import { languageName } from './language.js';
6
+
7
+ interface Props {
8
+ /** What the picker is labelled, in the page's language. */
9
+ label: string;
10
+ /** The languages the application is in. */
11
+ locales: readonly L[];
12
+ /** The one the page is in. */
13
+ current: L;
14
+ /** Switches to another language. */
15
+ choose: (locale: L) => void;
16
+ }
17
+
18
+ let { label, locales, current, choose }: Props = $props();
19
+
20
+ const isLocale = (value: string): value is L => locales.some(locale => locale === value);
21
+
22
+ function onchange(event: Event & { currentTarget: HTMLSelectElement }): void {
23
+ const { value } = event.currentTarget;
24
+ if (isLocale(value) && value !== current) choose(value);
25
+ }
26
+ </script>
27
+
28
+ <label>
29
+ <span>{label}</span>
30
+ <select value={current} {onchange}>
31
+ {#each locales as locale (locale)}
32
+ <option value={locale} lang={locale}>{languageName(locale)}</option>
33
+ {/each}
34
+ </select>
35
+ </label>
36
+
37
+ <style>
38
+ label {
39
+ display: inline-flex;
40
+ gap: var(--mdr-space-2);
41
+ align-items: center;
42
+ color: var(--mdr-color-text-muted);
43
+ }
44
+
45
+ select {
46
+ font: inherit;
47
+ }
48
+ </style>
@@ -0,0 +1,33 @@
1
+ declare function $$render<L extends string>(): {
2
+ props: {
3
+ /** What the picker is labelled, in the page's language. */
4
+ label: string;
5
+ /** The languages the application is in. */
6
+ locales: readonly L[];
7
+ /** The one the page is in. */
8
+ current: L;
9
+ /** Switches to another language. */
10
+ choose: (locale: L) => void;
11
+ };
12
+ exports: {};
13
+ bindings: "";
14
+ slots: {};
15
+ events: {};
16
+ };
17
+ declare class __sveltets_Render<L extends string> {
18
+ props(): ReturnType<typeof $$render<L>>['props'];
19
+ events(): ReturnType<typeof $$render<L>>['events'];
20
+ slots(): ReturnType<typeof $$render<L>>['slots'];
21
+ bindings(): "";
22
+ exports(): {};
23
+ }
24
+ interface $$IsomorphicComponent {
25
+ new <L extends string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<L>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<L>['props']>, ReturnType<__sveltets_Render<L>['events']>, ReturnType<__sveltets_Render<L>['slots']>> & {
26
+ $$bindings?: ReturnType<__sveltets_Render<L>['bindings']>;
27
+ } & ReturnType<__sveltets_Render<L>['exports']>;
28
+ <L extends string>(internal: unknown, props: ReturnType<__sveltets_Render<L>['props']> & {}): ReturnType<__sveltets_Render<L>['exports']>;
29
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
30
+ }
31
+ declare const LanguagePicker: $$IsomorphicComponent;
32
+ type LanguagePicker<L extends string> = InstanceType<typeof LanguagePicker<L>>;
33
+ export default LanguagePicker;
@@ -0,0 +1,36 @@
1
+ <!--
2
+ A Mondarth website's logo: the crescent and the gear, around the site's emblem. The same in either colour scheme, as
3
+ its colours read on both. Its width follows its height.
4
+ -->
5
+ <script lang="ts">
6
+ import accounts from '@mondarth/design-tokens/brand/accounts.svg';
7
+ import aide from '@mondarth/design-tokens/brand/aide.svg';
8
+ import catalogue from '@mondarth/design-tokens/brand/catalogue.svg';
9
+ import docs from '@mondarth/design-tokens/brand/docs.svg';
10
+ import mondarth from '@mondarth/design-tokens/brand/mondarth.svg';
11
+
12
+ import type { Site } from './site.js';
13
+
14
+ /** Each site's logo, by the name the design tokens give it (`data-site`). */
15
+ const LOGOS: Record<Site, string> = { mondarth, catalogue, aide, accounts, docs };
16
+
17
+ interface Props {
18
+ /** Its height, in CSS units; its width follows. */
19
+ height: string;
20
+ /** Whose logo: mondarth.com's unless given. */
21
+ site?: Site;
22
+ /** What it says to a screen reader; nothing, where the page says it already. */
23
+ alt?: string;
24
+ }
25
+
26
+ let { height, site = 'mondarth', alt = '' }: Props = $props();
27
+ </script>
28
+
29
+ <img src={LOGOS[site]} {alt} style:height />
30
+
31
+ <style>
32
+ img {
33
+ display: block;
34
+ width: auto;
35
+ }
36
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { Site } from './site.js';
2
+ interface Props {
3
+ /** Its height, in CSS units; its width follows. */
4
+ height: string;
5
+ /** Whose logo: mondarth.com's unless given. */
6
+ site?: Site;
7
+ /** What it says to a screen reader; nothing, where the page says it already. */
8
+ alt?: string;
9
+ }
10
+ declare const Logo: import("svelte").Component<Props, {}, "">;
11
+ type Logo = ReturnType<typeof Logo>;
12
+ export default Logo;
@@ -0,0 +1,116 @@
1
+ <!--
2
+ A note set apart from the text around it, announced as a note, not an alert: by default, as at the top of a page that
3
+ was translated by machine, in the accent. Wherever it is, it may say what it is for, in the colour the tokens give
4
+ that purpose (note, tip, important, warning or caution), and with an icon for it. The words are the application's.
5
+ -->
6
+ <script lang="ts">
7
+ import type { Snippet } from 'svelte';
8
+
9
+ /** What a notice is for. */
10
+ type NoticeType = 'note' | 'tip' | 'important' | 'warning' | 'caution';
11
+
12
+ interface Props {
13
+ /** What it is for, which colours it; none, and it is in the accent, as a plain note. */
14
+ type?: NoticeType | undefined;
15
+ /** Whether it shows an icon for what it is for; a plain note's is a note's. */
16
+ icon?: boolean;
17
+ children: Snippet;
18
+ }
19
+
20
+ let { type, icon = false, children }: Props = $props();
21
+
22
+ /**
23
+ * Each purpose's icon, drawn as mondarth.com's are, in strokes on a 24 by 24 grid: a circled `i`, a light bulb, a
24
+ * speech bubble with `!`, a triangle with `!`, an octagon with `!`.
25
+ */
26
+ const ICONS: Readonly<Record<NoticeType, string>> = {
27
+ note: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z M12 11v5 M12 8h.01',
28
+ tip: 'M9 18h6 M10 21h4 M12 3a6 6 0 0 0-4 10.5c.8.8 1 1.6 1 2.5h6c0-.9.2-1.7 1-2.5A6 6 0 0 0 12 3z',
29
+ important: 'M4 4h16v12H8l-4 4z M12 7v4 M12 14h.01',
30
+ warning: 'M12 3 2 20h20z M12 10v4 M12 17h.01',
31
+ caution: 'M8 3h8l5 5v8l-5 5H8l-5-5V8z M12 8v4 M12 16h.01',
32
+ };
33
+ </script>
34
+
35
+ <div class={['notice', type !== undefined && `notice-${type}`, { 'notice-with-icon': icon }]} role="note">
36
+ {#if icon}
37
+ <svg
38
+ class="notice-icon"
39
+ viewBox="0 0 24 24"
40
+ width="20"
41
+ height="20"
42
+ fill="none"
43
+ stroke="currentColor"
44
+ stroke-width="2"
45
+ stroke-linecap="round"
46
+ stroke-linejoin="round"
47
+ aria-hidden="true"
48
+ data-icon={type ?? 'note'}>
49
+ <path d={ICONS[type ?? 'note']} />
50
+ </svg>
51
+ {/if}
52
+ <div class="notice-body">{@render children()}</div>
53
+ </div>
54
+
55
+ <style>
56
+ .notice {
57
+ --notice-colour: var(--mdr-color-accent);
58
+ margin: 0 0 var(--mdr-space-5);
59
+ padding: var(--mdr-space-3) var(--mdr-space-4);
60
+ border-inline-start: var(--mdr-border-width-rule) solid var(--notice-colour);
61
+ background: var(--mdr-color-subtle);
62
+ }
63
+
64
+ /* Each purpose in its status colour, light or dark with the page, its background a breath of the same. */
65
+ .notice-note {
66
+ --notice-colour: var(--mdr-color-info);
67
+ }
68
+
69
+ .notice-tip {
70
+ --notice-colour: var(--mdr-color-success);
71
+ }
72
+
73
+ .notice-important {
74
+ --notice-colour: var(--mdr-color-accent);
75
+ }
76
+
77
+ .notice-warning {
78
+ --notice-colour: var(--mdr-color-warning);
79
+ }
80
+
81
+ .notice-caution {
82
+ --notice-colour: var(--mdr-color-danger);
83
+ }
84
+
85
+ .notice-note,
86
+ .notice-tip,
87
+ .notice-important,
88
+ .notice-warning,
89
+ .notice-caution {
90
+ background: color-mix(in srgb, var(--notice-colour) 8%, var(--mdr-color-subtle));
91
+ }
92
+
93
+ .notice-with-icon {
94
+ display: flex;
95
+ gap: var(--mdr-space-3);
96
+ align-items: flex-start;
97
+ }
98
+
99
+ .notice-icon {
100
+ flex: none;
101
+ margin-block-start: 0.15em;
102
+ color: var(--notice-colour);
103
+ }
104
+
105
+ .notice-body {
106
+ min-width: 0;
107
+ }
108
+
109
+ .notice-body > :global(:first-child) {
110
+ margin-block-start: 0;
111
+ }
112
+
113
+ .notice-body > :global(:last-child) {
114
+ margin-block-end: 0;
115
+ }
116
+ </style>
@@ -0,0 +1,13 @@
1
+ import type { Snippet } from 'svelte';
2
+ /** What a notice is for. */
3
+ type NoticeType = 'note' | 'tip' | 'important' | 'warning' | 'caution';
4
+ interface Props {
5
+ /** What it is for, which colours it; none, and it is in the accent, as a plain note. */
6
+ type?: NoticeType | undefined;
7
+ /** Whether it shows an icon for what it is for; a plain note's is a note's. */
8
+ icon?: boolean;
9
+ children: Snippet;
10
+ }
11
+ declare const Notice: import("svelte").Component<Props, {}, "">;
12
+ type Notice = ReturnType<typeof Notice>;
13
+ export default Notice;