tuidroid 0.0.0-stage → 0.1.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.
Files changed (157) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +181 -2
  3. package/dist/arrange/Mover.svelte +42 -0
  4. package/dist/arrange/Mover.svelte.d.ts +29 -0
  5. package/dist/arrange/PutAway.svelte +48 -0
  6. package/dist/arrange/PutAway.svelte.d.ts +30 -0
  7. package/dist/arrange/arrangement.svelte.d.ts +27 -0
  8. package/dist/arrange/arrangement.svelte.js +44 -0
  9. package/dist/arrange/order.d.ts +7 -0
  10. package/dist/arrange/order.js +20 -0
  11. package/dist/calendar/Calendar.svelte +328 -0
  12. package/dist/calendar/Calendar.svelte.d.ts +28 -0
  13. package/dist/calendar/MonthPicker.svelte +41 -0
  14. package/dist/calendar/MonthPicker.svelte.d.ts +10 -0
  15. package/dist/calendar/YearPicker.svelte +61 -0
  16. package/dist/calendar/YearPicker.svelte.d.ts +11 -0
  17. package/dist/calendar/dates.d.ts +23 -0
  18. package/dist/calendar/dates.js +54 -0
  19. package/dist/charts/BarChart.svelte +98 -0
  20. package/dist/charts/BarChart.svelte.d.ts +28 -0
  21. package/dist/charts/ChartFrame.svelte +133 -0
  22. package/dist/charts/ChartFrame.svelte.d.ts +21 -0
  23. package/dist/charts/ColumnChart.svelte +79 -0
  24. package/dist/charts/ColumnChart.svelte.d.ts +20 -0
  25. package/dist/charts/HeatGrid.svelte +110 -0
  26. package/dist/charts/HeatGrid.svelte.d.ts +22 -0
  27. package/dist/charts/LineChart.svelte +132 -0
  28. package/dist/charts/LineChart.svelte.d.ts +29 -0
  29. package/dist/charts/StripChart.svelte +80 -0
  30. package/dist/charts/StripChart.svelte.d.ts +27 -0
  31. package/dist/charts/scale.d.ts +17 -0
  32. package/dist/charts/scale.js +35 -0
  33. package/dist/controls/AccentStepper.svelte +24 -0
  34. package/dist/controls/AccentStepper.svelte.d.ts +8 -0
  35. package/dist/controls/Button.svelte +264 -0
  36. package/dist/controls/Button.svelte.d.ts +26 -0
  37. package/dist/controls/Cycle.svelte +27 -0
  38. package/dist/controls/Cycle.svelte.d.ts +31 -0
  39. package/dist/controls/NumberStepper.svelte +28 -0
  40. package/dist/controls/NumberStepper.svelte.d.ts +12 -0
  41. package/dist/controls/OptionStepper.svelte +42 -0
  42. package/dist/controls/OptionStepper.svelte.d.ts +34 -0
  43. package/dist/controls/Segmented.svelte +72 -0
  44. package/dist/controls/Segmented.svelte.d.ts +35 -0
  45. package/dist/controls/SettingRow.svelte +59 -0
  46. package/dist/controls/SettingRow.svelte.d.ts +11 -0
  47. package/dist/controls/Stepper.svelte +151 -0
  48. package/dist/controls/Stepper.svelte.d.ts +17 -0
  49. package/dist/controls/TextInput.svelte +176 -0
  50. package/dist/controls/TextInput.svelte.d.ts +12 -0
  51. package/dist/controls/Toggle.svelte +22 -0
  52. package/dist/controls/Toggle.svelte.d.ts +9 -0
  53. package/dist/data/BarRows.svelte +75 -0
  54. package/dist/data/BarRows.svelte.d.ts +15 -0
  55. package/dist/data/CellBar.svelte +55 -0
  56. package/dist/data/CellBar.svelte.d.ts +13 -0
  57. package/dist/data/Delta.svelte +28 -0
  58. package/dist/data/Delta.svelte.d.ts +11 -0
  59. package/dist/data/Hatch.svelte +9 -0
  60. package/dist/data/Hatch.svelte.d.ts +8 -0
  61. package/dist/data/KeyValues.svelte +56 -0
  62. package/dist/data/KeyValues.svelte.d.ts +14 -0
  63. package/dist/data/Legend.svelte +64 -0
  64. package/dist/data/Legend.svelte.d.ts +15 -0
  65. package/dist/data/Meter.svelte +46 -0
  66. package/dist/data/Meter.svelte.d.ts +9 -0
  67. package/dist/data/StackedBar.svelte +64 -0
  68. package/dist/data/StackedBar.svelte.d.ts +14 -0
  69. package/dist/data/Swatch.svelte +56 -0
  70. package/dist/data/Swatch.svelte.d.ts +11 -0
  71. package/dist/data/Table.svelte +86 -0
  72. package/dist/data/Table.svelte.d.ts +16 -0
  73. package/dist/data/Value.svelte +32 -0
  74. package/dist/data/Value.svelte.d.ts +12 -0
  75. package/dist/data/cells.d.ts +27 -0
  76. package/dist/data/cells.js +41 -0
  77. package/dist/data/fit.d.ts +10 -0
  78. package/dist/data/fit.js +35 -0
  79. package/dist/gestures/drag.d.ts +28 -0
  80. package/dist/gestures/drag.js +110 -0
  81. package/dist/gestures/hold.d.ts +7 -0
  82. package/dist/gestures/hold.js +59 -0
  83. package/dist/gestures/pick.d.ts +5 -0
  84. package/dist/gestures/pick.js +60 -0
  85. package/dist/haptics.d.ts +5 -0
  86. package/dist/haptics.js +16 -0
  87. package/dist/icons/Icon.svelte +52 -0
  88. package/dist/icons/Icon.svelte.d.ts +17 -0
  89. package/dist/icons/material.d.ts +68 -0
  90. package/dist/icons/material.js +69 -0
  91. package/dist/index.d.ts +75 -0
  92. package/dist/index.js +91 -0
  93. package/dist/layout/Alert.svelte +46 -0
  94. package/dist/layout/Alert.svelte.d.ts +12 -0
  95. package/dist/layout/Block.svelte +166 -0
  96. package/dist/layout/Block.svelte.d.ts +22 -0
  97. package/dist/layout/Panes.svelte +41 -0
  98. package/dist/layout/Panes.svelte.d.ts +9 -0
  99. package/dist/layout/Rows.svelte +37 -0
  100. package/dist/layout/Rows.svelte.d.ts +8 -0
  101. package/dist/layout/Split.svelte +18 -0
  102. package/dist/layout/Split.svelte.d.ts +4 -0
  103. package/dist/layout/Stage.svelte +59 -0
  104. package/dist/layout/Stage.svelte.d.ts +10 -0
  105. package/dist/layout/Unfold.svelte +25 -0
  106. package/dist/layout/Unfold.svelte.d.ts +9 -0
  107. package/dist/lists/ListItem.svelte +75 -0
  108. package/dist/lists/ListItem.svelte.d.ts +13 -0
  109. package/dist/lists/SwipeRow.svelte +158 -0
  110. package/dist/lists/SwipeRow.svelte.d.ts +21 -0
  111. package/dist/lists/UndoRow.svelte +37 -0
  112. package/dist/lists/UndoRow.svelte.d.ts +10 -0
  113. package/dist/motion/FlipCard.svelte +197 -0
  114. package/dist/motion/FlipCard.svelte.d.ts +34 -0
  115. package/dist/motion/Hero.svelte +59 -0
  116. package/dist/motion/Hero.svelte.d.ts +9 -0
  117. package/dist/motion/ShuffleText.svelte +42 -0
  118. package/dist/motion/ShuffleText.svelte.d.ts +13 -0
  119. package/dist/motion/TypeText.svelte +68 -0
  120. package/dist/motion/TypeText.svelte.d.ts +11 -0
  121. package/dist/motion/shuffle.d.ts +24 -0
  122. package/dist/motion/shuffle.js +58 -0
  123. package/dist/motion/still.d.ts +2 -0
  124. package/dist/motion/still.js +7 -0
  125. package/dist/motion/sweep.d.ts +14 -0
  126. package/dist/motion/sweep.js +59 -0
  127. package/dist/motion/typing.d.ts +9 -0
  128. package/dist/motion/typing.js +19 -0
  129. package/dist/motion/unfold.d.ts +4 -0
  130. package/dist/motion/unfold.js +13 -0
  131. package/dist/nav/Hang.svelte +194 -0
  132. package/dist/nav/Hang.svelte.d.ts +15 -0
  133. package/dist/nav/Pager.svelte +89 -0
  134. package/dist/nav/Pager.svelte.d.ts +43 -0
  135. package/dist/nav/Pane.svelte +93 -0
  136. package/dist/nav/Pane.svelte.d.ts +15 -0
  137. package/dist/nav/Shell.svelte +40 -0
  138. package/dist/nav/Shell.svelte.d.ts +34 -0
  139. package/dist/nav/TabBar.svelte +139 -0
  140. package/dist/nav/TabBar.svelte.d.ts +15 -0
  141. package/dist/styles/base.css +87 -0
  142. package/dist/styles/tokens.css +253 -0
  143. package/dist/text/Fields.svelte +28 -0
  144. package/dist/text/Fields.svelte.d.ts +8 -0
  145. package/dist/text/fields.d.ts +6 -0
  146. package/dist/text/fields.js +16 -0
  147. package/dist/theme/FlavourButton.svelte +55 -0
  148. package/dist/theme/FlavourButton.svelte.d.ts +13 -0
  149. package/dist/theme/Theme.svelte +48 -0
  150. package/dist/theme/Theme.svelte.d.ts +15 -0
  151. package/dist/theme/palette.d.ts +23 -0
  152. package/dist/theme/palette.js +55 -0
  153. package/dist/theme/reveal.d.ts +10 -0
  154. package/dist/theme/reveal.js +92 -0
  155. package/dist/theme/theme.d.ts +15 -0
  156. package/dist/theme/theme.js +21 -0
  157. package/package.json +72 -4
@@ -0,0 +1,40 @@
1
+ <script lang="ts" generics="T extends Tab">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+ import Pager from './Pager.svelte'
5
+ import TabBar, { type Tab } from './TabBar.svelte'
6
+
7
+ // A phone app's frame: its pages side by side (Pager), switched by the tabs along the
8
+ // bottom (TabBar) or a swipe, in a column a phone wide (--tui-column), drawn under the
9
+ // system bars and kept clear of them. bind:index.
10
+ interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onchange'> {
11
+ tabs: readonly T[]
12
+ index: number
13
+ page: Snippet<[T, number]>
14
+ swipe?: boolean
15
+ label?: string
16
+ onchange?: (index: number) => void
17
+ }
18
+
19
+ let { tabs, index = $bindable(0), page, swipe = true, label, onchange, class: className, ...rest }: Props = $props()
20
+ const prefix = $props.id()
21
+ </script>
22
+
23
+ <main {...rest} class={['tui-shell', className]}>
24
+ <Pager pages={tabs} bind:index {page} {swipe} {prefix} {onchange} />
25
+ <TabBar {tabs} bind:index {prefix} {label} onselect={onchange} />
26
+ </main>
27
+
28
+ <style>
29
+ @layer tuidroid {
30
+ .tui-shell {
31
+ height: 100%;
32
+ max-width: var(--tui-column);
33
+ margin-inline: auto;
34
+ display: grid;
35
+ grid-template-rows: minmax(0, 1fr) auto;
36
+ padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
37
+ box-sizing: border-box;
38
+ }
39
+ }
40
+ </style>
@@ -0,0 +1,34 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Tab } from './TabBar.svelte';
4
+ declare function $$render<T extends Tab>(): {
5
+ props: Omit<HTMLAttributes<HTMLElement>, "children" | "onchange"> & {
6
+ tabs: readonly T[];
7
+ index: number;
8
+ page: Snippet<[T, number]>;
9
+ swipe?: boolean;
10
+ label?: string;
11
+ onchange?: (index: number) => void;
12
+ };
13
+ exports: {};
14
+ bindings: "index";
15
+ slots: {};
16
+ events: {};
17
+ };
18
+ declare class __sveltets_Render<T extends Tab> {
19
+ props(): ReturnType<typeof $$render<T>>['props'];
20
+ events(): ReturnType<typeof $$render<T>>['events'];
21
+ slots(): ReturnType<typeof $$render<T>>['slots'];
22
+ bindings(): "index";
23
+ exports(): {};
24
+ }
25
+ interface $$IsomorphicComponent {
26
+ new <T extends Tab>(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']>> & {
27
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
28
+ } & ReturnType<__sveltets_Render<T>['exports']>;
29
+ <T extends Tab>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
30
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
31
+ }
32
+ declare const Shell: $$IsomorphicComponent;
33
+ type Shell<T extends Tab> = InstanceType<typeof Shell<T>>;
34
+ export default Shell;
@@ -0,0 +1,139 @@
1
+ <script lang="ts" module>
2
+ export interface Tab {
3
+ id: string
4
+ label: string
5
+ }
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import type { HTMLAttributes } from 'svelte/elements'
10
+
11
+ // The pages' names along the bottom, ratatui Tabs style: words between bars, the current
12
+ // one in the accent with a line under it that slides to the next as the pages do. Arrow
13
+ // keys move along it. Each tab controls the panel `{prefix}-page-{id}` (Pager's).
14
+ interface Props extends Omit<HTMLAttributes<HTMLElement>, 'onselect'> {
15
+ tabs: readonly Tab[]
16
+ index: number
17
+ label?: string
18
+ prefix?: string
19
+ onselect?: (index: number) => void
20
+ }
21
+
22
+ let { tabs, index = $bindable(0), label = 'Pages', prefix = 'tui', onselect, class: className, ...rest }: Props = $props()
23
+
24
+ let buttons = $state<HTMLButtonElement[]>([])
25
+ let line = $state({ left: 0, width: 0 })
26
+
27
+ // The line spans the word only, not the button's padding, measured on screen against the
28
+ // row: a pressed button's 1px press would otherwise make it the word's offset parent.
29
+ function measure(row: HTMLElement) {
30
+ const button = buttons[index]
31
+ tabs.map((tab) => tab.label) // measure again when the words change
32
+ if (!button) return
33
+ const update = () => {
34
+ const word = (button.firstElementChild as HTMLElement).getBoundingClientRect()
35
+ const box = row.getBoundingClientRect()
36
+ line = { left: word.left - box.left, width: word.width }
37
+ }
38
+ update()
39
+ const observer = new ResizeObserver(update)
40
+ observer.observe(row)
41
+ observer.observe(button.firstElementChild!)
42
+ return () => observer.disconnect()
43
+ }
44
+
45
+ function select(next: number) {
46
+ index = next
47
+ onselect?.(next)
48
+ }
49
+
50
+ function keydown(event: KeyboardEvent) {
51
+ const step = event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0
52
+ if (!step) return
53
+ event.preventDefault()
54
+ const next = (index + step + tabs.length) % tabs.length
55
+ select(next)
56
+ buttons[next]?.focus()
57
+ }
58
+ </script>
59
+
60
+ <nav {...rest} class={['tui-tabs', className]} aria-label={label}>
61
+ <div class="row" role="tablist" tabindex="-1" onkeydown={keydown} {@attach measure}>
62
+ {#each tabs as tab, i (tab.id)}
63
+ {#if i}<span class="bar" aria-hidden="true">│</span>{/if}
64
+ <button
65
+ type="button"
66
+ role="tab"
67
+ id="{prefix}-tab-{tab.id}"
68
+ aria-controls="{prefix}-page-{tab.id}"
69
+ aria-selected={i === index}
70
+ tabindex={i === index ? 0 : -1}
71
+ class:current={i === index}
72
+ bind:this={buttons[i]}
73
+ onclick={() => select(i)}><span>{tab.label}</span></button
74
+ >
75
+ {/each}
76
+ <span class="line" style:transform="translateX({line.left}px)" style:width="{line.width}px" aria-hidden="true"></span>
77
+ </div>
78
+ </nav>
79
+
80
+ <style>
81
+ @layer tuidroid {
82
+ .tui-tabs {
83
+ padding: 0 0.6ch;
84
+ }
85
+
86
+ .row {
87
+ position: relative;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ }
92
+
93
+ button {
94
+ flex: 1 1 auto;
95
+ padding: 0.7em 0 0.8em;
96
+ font: inherit;
97
+ background: none;
98
+ border: none;
99
+ border-radius: 0;
100
+ color: var(--tui-muted);
101
+ white-space: nowrap;
102
+ cursor: pointer;
103
+ touch-action: manipulation;
104
+ -webkit-tap-highlight-color: transparent;
105
+ transition: color var(--tui-fade) ease;
106
+
107
+ &.current {
108
+ color: var(--tui-accent);
109
+ }
110
+
111
+ &:focus-visible {
112
+ outline: none;
113
+
114
+ & span {
115
+ outline: 1px solid var(--tui-accent);
116
+ outline-offset: 2px;
117
+ }
118
+ }
119
+ }
120
+
121
+ .bar {
122
+ flex: none;
123
+ color: var(--tui-border);
124
+ }
125
+
126
+ /* Under the current word, moving with the pages. */
127
+ .line {
128
+ position: absolute;
129
+ left: 0;
130
+ bottom: 0.35em;
131
+ height: 2px;
132
+ border-radius: 1px;
133
+ background: var(--tui-accent);
134
+ transition:
135
+ transform var(--tui-slide),
136
+ width var(--tui-slide);
137
+ }
138
+ }
139
+ </style>
@@ -0,0 +1,15 @@
1
+ export interface Tab {
2
+ id: string;
3
+ label: string;
4
+ }
5
+ import type { HTMLAttributes } from 'svelte/elements';
6
+ interface Props extends Omit<HTMLAttributes<HTMLElement>, 'onselect'> {
7
+ tabs: readonly Tab[];
8
+ index: number;
9
+ label?: string;
10
+ prefix?: string;
11
+ onselect?: (index: number) => void;
12
+ }
13
+ declare const TabBar: import("svelte").Component<Props, {}, "index">;
14
+ type TabBar = ReturnType<typeof TabBar>;
15
+ export default TabBar;
@@ -0,0 +1,87 @@
1
+ /* Optional: the page and plain elements drawn like the components, for an app that is
2
+ tuidroid all the way down. Every selector is wrapped in :where, so it weighs nothing:
3
+ a component's own styles and the page's win over it. Needs tokens.css. */
4
+
5
+ @layer tuidroid {
6
+ :where(html) {
7
+ font-family: var(--tui-font);
8
+ font-size: 16px;
9
+ line-height: 1.3;
10
+ background: var(--tui-bg);
11
+ color: var(--tui-fg);
12
+ -webkit-text-size-adjust: 100%;
13
+ scrollbar-color: var(--tui-button-border) transparent;
14
+ }
15
+
16
+ :where(body) {
17
+ margin: 0;
18
+ overscroll-behavior: none;
19
+ }
20
+
21
+ :where(button, input, select, textarea) {
22
+ font: inherit;
23
+ color: inherit;
24
+ }
25
+
26
+ /* Headings are words in the accent, at the text's size and weight: a terminal has one
27
+ size, and bold is kept for live values. */
28
+ :where(h1, h2, h3, h4) {
29
+ margin: 0 0 0.3em;
30
+ font-size: 1em;
31
+ font-weight: 400;
32
+ color: var(--tui-accent);
33
+ }
34
+
35
+ :where(p) {
36
+ margin: 0.3em 0;
37
+ }
38
+
39
+ /* A link in running text: the accent, dotted underline; a press lights it. */
40
+ :where(a) {
41
+ color: var(--tui-accent);
42
+ text-decoration: underline dotted;
43
+ text-underline-offset: 0.2em;
44
+ -webkit-tap-highlight-color: transparent;
45
+
46
+ &:active {
47
+ background: var(--tui-accent);
48
+ color: var(--tui-bg);
49
+ }
50
+ }
51
+
52
+ /* A rule, like a ratatui split. Inside a Block, Split reaches border to border. */
53
+ :where(hr) {
54
+ border: 0;
55
+ border-top: 1px solid var(--tui-border);
56
+ margin: 0.4em 0;
57
+ }
58
+
59
+ :where(table) {
60
+ border-collapse: collapse;
61
+ }
62
+
63
+ :where(th, td) {
64
+ text-align: left;
65
+ padding: 0.1em 1ch 0.1em 0;
66
+ font-weight: normal;
67
+ vertical-align: top;
68
+ }
69
+
70
+ :where(th) {
71
+ color: var(--tui-muted);
72
+ }
73
+
74
+ :where(code, kbd, samp, pre) {
75
+ font: inherit;
76
+ }
77
+
78
+ /* Keyboard focus only (a tap shows none): a thin accent ring. */
79
+ :where(:focus-visible) {
80
+ outline: 1px solid var(--tui-accent);
81
+ outline-offset: 2px;
82
+ }
83
+
84
+ ::selection {
85
+ background: color-mix(in oklab, var(--tui-accent) 35%, transparent);
86
+ }
87
+ }
@@ -0,0 +1,253 @@
1
+ /* tuidroid's tokens: the Catppuccin palette in four flavours, and the semantic tokens the
2
+ components draw with. Components use --tui-*, never --ctp-* or hex; set any of them
3
+ anywhere to restyle what is inside.
4
+
5
+ Everything sits in the `tuidroid` layer, so a page's own unlayered CSS always wins. */
6
+
7
+ @property --tui-motion {
8
+ syntax: '<number>';
9
+ inherits: true;
10
+ initial-value: 1;
11
+ }
12
+
13
+ @layer tuidroid {
14
+ /* Catppuccin (catppuccin.com/palette). Any element can carry its own flavour with
15
+ data-theme; Mocha is the default. :where keeps the default below an explicit
16
+ data-theme on the root. */
17
+ [data-theme='latte'] {
18
+ color-scheme: light;
19
+ --ctp-rosewater: #dc8a78;
20
+ --ctp-flamingo: #dd7878;
21
+ --ctp-pink: #ea76cb;
22
+ --ctp-mauve: #8839ef;
23
+ --ctp-red: #d20f39;
24
+ --ctp-maroon: #e64553;
25
+ --ctp-peach: #fe640b;
26
+ --ctp-yellow: #df8e1d;
27
+ --ctp-green: #40a02b;
28
+ --ctp-teal: #179299;
29
+ --ctp-sky: #04a5e5;
30
+ --ctp-sapphire: #209fb5;
31
+ --ctp-blue: #1e66f5;
32
+ --ctp-lavender: #7287fd;
33
+ --ctp-text: #4c4f69;
34
+ --ctp-subtext1: #5c5f77;
35
+ --ctp-subtext0: #6c6f85;
36
+ --ctp-overlay2: #7c7f93;
37
+ --ctp-overlay1: #8c8fa1;
38
+ --ctp-overlay0: #9ca0b0;
39
+ --ctp-surface2: #acb0be;
40
+ --ctp-surface1: #bcc0cc;
41
+ --ctp-surface0: #ccd0da;
42
+ --ctp-base: #eff1f5;
43
+ --ctp-mantle: #e6e9ef;
44
+ --ctp-crust: #dce0e8;
45
+ }
46
+
47
+ [data-theme='frappe'] {
48
+ color-scheme: dark;
49
+ --ctp-rosewater: #f2d5cf;
50
+ --ctp-flamingo: #eebebe;
51
+ --ctp-pink: #f4b8e4;
52
+ --ctp-mauve: #ca9ee6;
53
+ --ctp-red: #e78284;
54
+ --ctp-maroon: #ea999c;
55
+ --ctp-peach: #ef9f76;
56
+ --ctp-yellow: #e5c890;
57
+ --ctp-green: #a6d189;
58
+ --ctp-teal: #81c8be;
59
+ --ctp-sky: #99d1db;
60
+ --ctp-sapphire: #85c1dc;
61
+ --ctp-blue: #8caaee;
62
+ --ctp-lavender: #babbf1;
63
+ --ctp-text: #c6d0f5;
64
+ --ctp-subtext1: #b5bfe2;
65
+ --ctp-subtext0: #a5adce;
66
+ --ctp-overlay2: #949cbb;
67
+ --ctp-overlay1: #838ba7;
68
+ --ctp-overlay0: #737994;
69
+ --ctp-surface2: #626880;
70
+ --ctp-surface1: #51576d;
71
+ --ctp-surface0: #414559;
72
+ --ctp-base: #303446;
73
+ --ctp-mantle: #292c3c;
74
+ --ctp-crust: #232634;
75
+ }
76
+
77
+ [data-theme='macchiato'] {
78
+ color-scheme: dark;
79
+ --ctp-rosewater: #f4dbd6;
80
+ --ctp-flamingo: #f0c6c6;
81
+ --ctp-pink: #f5bde6;
82
+ --ctp-mauve: #c6a0f6;
83
+ --ctp-red: #ed8796;
84
+ --ctp-maroon: #ee99a0;
85
+ --ctp-peach: #f5a97f;
86
+ --ctp-yellow: #eed49f;
87
+ --ctp-green: #a6da95;
88
+ --ctp-teal: #8bd5ca;
89
+ --ctp-sky: #91d7e3;
90
+ --ctp-sapphire: #7dc4e4;
91
+ --ctp-blue: #8aadf4;
92
+ --ctp-lavender: #b7bdf8;
93
+ --ctp-text: #cad3f5;
94
+ --ctp-subtext1: #b8c0e0;
95
+ --ctp-subtext0: #a5adcb;
96
+ --ctp-overlay2: #939ab7;
97
+ --ctp-overlay1: #8087a2;
98
+ --ctp-overlay0: #6e738d;
99
+ --ctp-surface2: #5b6078;
100
+ --ctp-surface1: #494d64;
101
+ --ctp-surface0: #363a4f;
102
+ --ctp-base: #24273a;
103
+ --ctp-mantle: #1e2030;
104
+ --ctp-crust: #181926;
105
+ }
106
+
107
+ :where(:root),
108
+ [data-theme='mocha'] {
109
+ color-scheme: dark;
110
+ --ctp-rosewater: #f5e0dc;
111
+ --ctp-flamingo: #f2cdcd;
112
+ --ctp-pink: #f5c2e7;
113
+ --ctp-mauve: #cba6f7;
114
+ --ctp-red: #f38ba8;
115
+ --ctp-maroon: #eba0ac;
116
+ --ctp-peach: #fab387;
117
+ --ctp-yellow: #f9e2af;
118
+ --ctp-green: #a6e3a1;
119
+ --ctp-teal: #94e2d5;
120
+ --ctp-sky: #89dceb;
121
+ --ctp-sapphire: #74c7ec;
122
+ --ctp-blue: #89b4fa;
123
+ --ctp-lavender: #b4befe;
124
+ --ctp-text: #cdd6f4;
125
+ --ctp-subtext1: #bac2de;
126
+ --ctp-subtext0: #a6adc8;
127
+ --ctp-overlay2: #9399b2;
128
+ --ctp-overlay1: #7f849c;
129
+ --ctp-overlay0: #6c7086;
130
+ --ctp-surface2: #585b70;
131
+ --ctp-surface1: #45475a;
132
+ --ctp-surface0: #313244;
133
+ --ctp-base: #1e1e2e;
134
+ --ctp-mantle: #181825;
135
+ --ctp-crust: #11111b;
136
+ }
137
+
138
+ /* What the components draw with. Declared with the palette, so an element with its
139
+ own flavour resolves them in it. --tui-ok, --tui-warn and --tui-bad say good,
140
+ middling and bad: a live value's colour, a block's border. */
141
+ :root,
142
+ [data-theme] {
143
+ --tui-bg: var(--ctp-base);
144
+ --tui-fg: var(--ctp-text);
145
+ --tui-muted: var(--ctp-subtext0);
146
+ --tui-border: var(--ctp-overlay0);
147
+ --tui-button: var(--ctp-surface0);
148
+ --tui-button-border: var(--ctp-surface2);
149
+ --tui-accent: var(--ctp-mauve);
150
+ --tui-ok: var(--ctp-green);
151
+ --tui-warn: var(--ctp-yellow);
152
+ --tui-bad: var(--ctp-red);
153
+ }
154
+
155
+ /* The grid and the motion. Everything is measured in ch across and em down, so it
156
+ all scales with the font size; Iosevka's ch is half an em. */
157
+ :root {
158
+ --tui-font: 'Iosevka', ui-monospace, 'SF Mono', 'Cascadia Mono', 'DejaVu Sans Mono', monospace;
159
+ --tui-radius: 0.6em;
160
+ --tui-gap: 1.6em; /* between the blocks of a column (Panes) */
161
+ --tui-column: 30rem; /* a phone's width, the shell's on wider screens */
162
+
163
+ /* 1 moves, 0 holds still: every duration is scaled by it. It follows the system's
164
+ reduced-motion setting unless data-motion on an ancestor says otherwise. */
165
+ --tui-motion: 1;
166
+ }
167
+
168
+ @media (prefers-reduced-motion: reduce) {
169
+ :root {
170
+ --tui-motion: 0;
171
+ }
172
+ }
173
+
174
+ [data-motion='on'] {
175
+ --tui-motion: 1;
176
+ }
177
+
178
+ [data-motion='off'] {
179
+ --tui-motion: 0;
180
+ }
181
+
182
+ /* The flavour reveal (theme/reveal.ts): the page is captured as tui-from, then as tui-to
183
+ once the new flavour is on. The lighter one is the circle, on top: tui-to growing, or
184
+ tui-from shrinking, scaled with the view inside it by the script. Colour transitions
185
+ are held meanwhile. */
186
+ :root[data-tui-reveal] {
187
+ view-transition-name: none;
188
+
189
+ & body {
190
+ view-transition-name: tui-from;
191
+ background: var(--tui-bg);
192
+ }
193
+
194
+ &[data-tui-reveal-phase='to'] body {
195
+ view-transition-name: tui-to;
196
+ }
197
+
198
+ & *,
199
+ & *::before,
200
+ & *::after {
201
+ transition: none !important;
202
+ }
203
+ }
204
+
205
+ :root[data-tui-reveal]::view-transition-old(*),
206
+ :root[data-tui-reveal]::view-transition-new(*) {
207
+ animation: none;
208
+ }
209
+
210
+ :root[data-tui-reveal='grow']::view-transition-group(tui-to),
211
+ :root[data-tui-reveal='shrink']::view-transition-group(tui-from) {
212
+ z-index: 1;
213
+ }
214
+
215
+ :root[data-tui-reveal='grow']::view-transition-image-pair(tui-to),
216
+ :root[data-tui-reveal='shrink']::view-transition-image-pair(tui-from) {
217
+ inset: auto;
218
+ left: calc(var(--tui-reveal-x) - var(--tui-reveal-r));
219
+ top: calc(var(--tui-reveal-y) - var(--tui-reveal-r));
220
+ width: calc(2 * var(--tui-reveal-r));
221
+ height: calc(2 * var(--tui-reveal-r));
222
+ border-radius: 50%;
223
+ overflow: clip;
224
+ }
225
+
226
+ :root[data-tui-reveal='grow']::view-transition-new(tui-to),
227
+ :root[data-tui-reveal='shrink']::view-transition-old(tui-from) {
228
+ left: calc(var(--tui-reveal-r) - var(--tui-reveal-x));
229
+ top: calc(var(--tui-reveal-r) - var(--tui-reveal-y));
230
+ width: var(--tui-reveal-w);
231
+ height: var(--tui-reveal-h);
232
+ transform-origin: var(--tui-reveal-x) var(--tui-reveal-y);
233
+ }
234
+
235
+ /* Read by screen readers, not drawn: the real text behind a shuffle. */
236
+ .tui-sr {
237
+ position: absolute;
238
+ width: 1px;
239
+ height: 1px;
240
+ overflow: hidden;
241
+ clip-path: inset(50%);
242
+ white-space: nowrap;
243
+ }
244
+
245
+ /* Declared again wherever the motion changes, as a custom property resolves where it
246
+ is declared. */
247
+ :root,
248
+ [data-motion] {
249
+ --tui-fade: calc(0.3s * var(--tui-motion)); /* a press's light, a colour change */
250
+ --tui-tone: calc(0.8s * var(--tui-motion)); /* a value or a border changing tone */
251
+ --tui-slide: calc(0.2s * var(--tui-motion)) cubic-bezier(0.2, 0, 0, 1); /* pages, the tab line */
252
+ }
253
+ }
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+
5
+ // A status line: fixed-width fields, never wrapped, cut off with … at the edge. No
6
+ // ligatures, so a dashed placeholder (dashed()) shows every dash, where Iosevka would
7
+ // join three into one line. Pad its values (pad()) so nothing shifts as they change.
8
+ interface Props extends HTMLAttributes<HTMLParagraphElement> {
9
+ children: Snippet
10
+ }
11
+
12
+ let { children, class: className, ...rest }: Props = $props()
13
+ </script>
14
+
15
+ <p {...rest} class={['tui-fields', className]}>{@render children()}</p>
16
+
17
+ <style>
18
+ @layer tuidroid {
19
+ .tui-fields {
20
+ margin: 0;
21
+ white-space: pre;
22
+ font-variant-ligatures: none;
23
+ overflow: hidden;
24
+ text-overflow: ellipsis;
25
+ line-height: 1.35;
26
+ }
27
+ }
28
+ </style>
@@ -0,0 +1,8 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ interface Props extends HTMLAttributes<HTMLParagraphElement> {
4
+ children: Snippet;
5
+ }
6
+ declare const Fields: import("svelte").Component<Props, {}, "">;
7
+ type Fields = ReturnType<typeof Fields>;
8
+ export default Fields;
@@ -0,0 +1,6 @@
1
+ /** `value` padded to `width` characters: at the start (numbers, by default) or the end. */
2
+ export declare function pad(value: string | number, width: number, align?: 'end' | 'start'): string;
3
+ /** Every character of `text` as a dash but those in `keep`: "#312" → "#---", "04:12" → "--:--". */
4
+ export declare function dashed(text: string, keep?: string): string;
5
+ /** `share` (0 to 1) as `cells` characters: "#####......." for a coverage bar in a field. */
6
+ export declare function cellBar(share: number, cells: number, fill?: string, rest?: string): string;
@@ -0,0 +1,16 @@
1
+ // Fixed-width fields for status lines (Fields.svelte): values padded to their width, and
2
+ // dashes standing in for a value not there yet, at the same width.
3
+ /** `value` padded to `width` characters: at the start (numbers, by default) or the end. */
4
+ export function pad(value, width, align = 'end') {
5
+ const text = String(value);
6
+ return align === 'end' ? text.padStart(width) : text.padEnd(width);
7
+ }
8
+ /** Every character of `text` as a dash but those in `keep`: "#312" → "#---", "04:12" → "--:--". */
9
+ export function dashed(text, keep = '#[]%·:./') {
10
+ return [...text].map((ch) => (keep.includes(ch) ? ch : '-')).join('');
11
+ }
12
+ /** `share` (0 to 1) as `cells` characters: "#####......." for a coverage bar in a field. */
13
+ export function cellBar(share, cells, fill = '#', rest = '.') {
14
+ const filled = Math.round(Math.min(1, Math.max(0, share)) * cells);
15
+ return fill.repeat(filled) + rest.repeat(cells - filled);
16
+ }
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import { untrack } from 'svelte'
3
+ import { MediaQuery } from 'svelte/reactivity'
4
+ import Button, { type ButtonProps } from '../controls/Button.svelte'
5
+ import type { IconName } from '../icons/material'
6
+ import { FLAVOURS, FLAVOUR_NAMES, type Flavour } from './palette'
7
+ import { revealFlavour } from './reveal'
8
+ import { applyFlavour, DARK_QUERY, paintThemeColor, shownFlavour, SYSTEM_FLAVOURS, type ThemeChoice } from './theme'
9
+
10
+ // The page's flavour as a word with its icon: a press steps to the next of `choices` and
11
+ // switches the page with the circle reveal from the button. System shows `light` or
12
+ // `dark` as the device is, and follows it as it changes. bind:value, the choice, to keep
13
+ // it; the page's first flavour is yours to set before it paints.
14
+ interface Props extends Omit<ButtonProps, 'variant' | 'value' | 'onchange' | 'children'> {
15
+ value: ThemeChoice
16
+ choices?: readonly ThemeChoice[]
17
+ light?: Flavour
18
+ dark?: Flavour
19
+ onchange?: (choice: ThemeChoice) => void
20
+ }
21
+
22
+ let {
23
+ value = $bindable(),
24
+ choices = [...FLAVOURS, 'system'],
25
+ light = SYSTEM_FLAVOURS.light,
26
+ dark = SYSTEM_FLAVOURS.dark,
27
+ onchange,
28
+ onclick,
29
+ ...rest
30
+ }: Props = $props()
31
+
32
+ const deviceDark = new MediaQuery(DARK_QUERY, true)
33
+ const name = $derived(value === 'system' ? 'System' : FLAVOUR_NAMES[value])
34
+ const icon = $derived<IconName>(value === 'system' ? 'brightness_auto' : value === 'latte' ? 'light_mode' : 'dark_mode')
35
+
36
+ // System follows the device as it changes, at once.
37
+ $effect(() => {
38
+ const isDark = deviceDark.current
39
+ untrack(() => {
40
+ if (value !== 'system') return
41
+ applyFlavour(shownFlavour('system', isDark, { light, dark }))
42
+ paintThemeColor()
43
+ })
44
+ })
45
+
46
+ async function next(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
47
+ onclick?.(event)
48
+ value = choices[(choices.indexOf(value) + 1) % choices.length]
49
+ onchange?.(value)
50
+ await revealFlavour(shownFlavour(value, deviceDark.current, { light, dark }), event.currentTarget)
51
+ }
52
+ </script>
53
+
54
+ <!-- The word changes at once: the reveal is the motion, and a shuffle over it looks busy. -->
55
+ <Button {...rest} variant="word" {icon} aria-label="Flavour: {name}" onclick={next}>{name}</Button>