tuidroid 0.0.0-stage → 0.1.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 (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,13 @@
1
+ import { type ButtonProps } from '../controls/Button.svelte';
2
+ import { type Flavour } from './palette';
3
+ import { type ThemeChoice } from './theme';
4
+ interface Props extends Omit<ButtonProps, 'variant' | 'value' | 'onchange' | 'children'> {
5
+ value: ThemeChoice;
6
+ choices?: readonly ThemeChoice[];
7
+ light?: Flavour;
8
+ dark?: Flavour;
9
+ onchange?: (choice: ThemeChoice) => void;
10
+ }
11
+ declare const FlavourButton: import("svelte").Component<Props, {}, "value">;
12
+ type FlavourButton = ReturnType<typeof FlavourButton>;
13
+ export default FlavourButton;
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+ import { MediaQuery } from 'svelte/reactivity'
5
+ import { ctp, type Accent, type Flavour } from './palette'
6
+ import { DARK_QUERY, shownFlavour, SYSTEM_FLAVOURS, type ThemeChoice } from './theme'
7
+
8
+ // A subtree in its own flavour and accent, on that flavour's background in the grid's
9
+ // font. System follows the device's light or dark mode. `motion` holds the motion in it
10
+ // still ("off") or lets it move whatever the system asks ("on").
11
+ interface Props extends HTMLAttributes<HTMLDivElement> {
12
+ flavour?: ThemeChoice
13
+ light?: Flavour // what System shows in light mode
14
+ dark?: Flavour // and in dark mode
15
+ accent?: Accent
16
+ motion?: 'on' | 'off'
17
+ children: Snippet
18
+ }
19
+
20
+ let {
21
+ flavour = 'mocha',
22
+ light = SYSTEM_FLAVOURS.light,
23
+ dark = SYSTEM_FLAVOURS.dark,
24
+ accent,
25
+ motion,
26
+ children,
27
+ class: className,
28
+ ...rest
29
+ }: Props = $props()
30
+
31
+ const deviceDark = new MediaQuery(DARK_QUERY, true)
32
+ const shown = $derived(shownFlavour(flavour, deviceDark.current, { light, dark }))
33
+ </script>
34
+
35
+ <div {...rest} class={['tui-theme', className]} data-theme={shown} data-motion={motion} style:--tui-accent={accent && ctp(accent)}>
36
+ {@render children()}
37
+ </div>
38
+
39
+ <style>
40
+ @layer tuidroid {
41
+ .tui-theme {
42
+ background: var(--tui-bg);
43
+ color: var(--tui-fg);
44
+ font-family: var(--tui-font);
45
+ line-height: 1.3;
46
+ }
47
+ }
48
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Accent, type Flavour } from './palette';
4
+ import { type ThemeChoice } from './theme';
5
+ interface Props extends HTMLAttributes<HTMLDivElement> {
6
+ flavour?: ThemeChoice;
7
+ light?: Flavour;
8
+ dark?: Flavour;
9
+ accent?: Accent;
10
+ motion?: 'on' | 'off';
11
+ children: Snippet;
12
+ }
13
+ declare const Theme: import("svelte").Component<Props, {}, "">;
14
+ type Theme = ReturnType<typeof Theme>;
15
+ export default Theme;
@@ -0,0 +1,23 @@
1
+ export declare const FLAVOURS: readonly ["latte", "frappe", "macchiato", "mocha"];
2
+ export type Flavour = (typeof FLAVOURS)[number];
3
+ export declare const FLAVOUR_NAMES: Record<Flavour, string>;
4
+ /** Latte is the one light flavour. */
5
+ export declare const isDark: (flavour: Flavour) => boolean;
6
+ /** The fourteen colours an accent can be. */
7
+ export declare const ACCENTS: readonly ["rosewater", "flamingo", "pink", "mauve", "red", "maroon", "peach", "yellow", "green", "teal", "sky", "sapphire", "blue", "lavender"];
8
+ export type Accent = (typeof ACCENTS)[number];
9
+ /** Text, overlays, surfaces and backgrounds, lightest to darkest in a dark flavour. */
10
+ export declare const NEUTRALS: readonly ["text", "subtext1", "subtext0", "overlay2", "overlay1", "overlay0", "surface2", "surface1", "surface0", "base", "mantle", "crust"];
11
+ export type Neutral = (typeof NEUTRALS)[number];
12
+ export type PaletteColour = Accent | Neutral;
13
+ export declare const isAccent: (value: unknown) => value is Accent;
14
+ /** A palette colour as CSS: "blue" → "var(--ctp-blue)". */
15
+ export declare const ctp: (colour: PaletteColour) => string;
16
+ /** "sapphire" → "Sapphire". */
17
+ export declare const colourName: (colour: PaletteColour) => string;
18
+ /** The accent `direction` steps to from `accent`, round the ends. */
19
+ export declare function stepAccent(accent: Accent, direction: -1 | 1): Accent;
20
+ /** Good, middling and bad: a live value's colour, a block's border. */
21
+ export type Tone = 'ok' | 'warn' | 'bad';
22
+ /** A tone as CSS: "ok" → "var(--tui-ok)". */
23
+ export declare const tone: (t: Tone) => string;
@@ -0,0 +1,55 @@
1
+ // Catppuccin's flavours and colours by name (catppuccin.com/palette). The colours
2
+ // themselves are CSS (styles/tokens.css): a name resolves to the flavour of wherever it
3
+ // is drawn, so one choice of "peach" reads right in Latte and in Mocha.
4
+ export const FLAVOURS = ['latte', 'frappe', 'macchiato', 'mocha'];
5
+ export const FLAVOUR_NAMES = {
6
+ latte: 'Latte',
7
+ frappe: 'Frappé',
8
+ macchiato: 'Macchiato',
9
+ mocha: 'Mocha',
10
+ };
11
+ /** Latte is the one light flavour. */
12
+ export const isDark = (flavour) => flavour !== 'latte';
13
+ /** The fourteen colours an accent can be. */
14
+ export const ACCENTS = [
15
+ 'rosewater',
16
+ 'flamingo',
17
+ 'pink',
18
+ 'mauve',
19
+ 'red',
20
+ 'maroon',
21
+ 'peach',
22
+ 'yellow',
23
+ 'green',
24
+ 'teal',
25
+ 'sky',
26
+ 'sapphire',
27
+ 'blue',
28
+ 'lavender',
29
+ ];
30
+ /** Text, overlays, surfaces and backgrounds, lightest to darkest in a dark flavour. */
31
+ export const NEUTRALS = [
32
+ 'text',
33
+ 'subtext1',
34
+ 'subtext0',
35
+ 'overlay2',
36
+ 'overlay1',
37
+ 'overlay0',
38
+ 'surface2',
39
+ 'surface1',
40
+ 'surface0',
41
+ 'base',
42
+ 'mantle',
43
+ 'crust',
44
+ ];
45
+ export const isAccent = (value) => ACCENTS.includes(value);
46
+ /** A palette colour as CSS: "blue" → "var(--ctp-blue)". */
47
+ export const ctp = (colour) => `var(--ctp-${colour})`;
48
+ /** "sapphire" → "Sapphire". */
49
+ export const colourName = (colour) => colour[0].toUpperCase() + colour.slice(1);
50
+ /** The accent `direction` steps to from `accent`, round the ends. */
51
+ export function stepAccent(accent, direction) {
52
+ return ACCENTS[(ACCENTS.indexOf(accent) + direction + ACCENTS.length) % ACCENTS.length];
53
+ }
54
+ /** A tone as CSS: "ok" → "var(--tui-ok)". */
55
+ export const tone = (t) => `var(--tui-${t})`;
@@ -0,0 +1,10 @@
1
+ import type { Flavour } from './palette';
2
+ /** The reveal's keyframes, sampled along its cubic-bezier easing (offsets from the curve's x,
3
+ * progress from its y): the circle's scale, and its inverse for the view inside it. */
4
+ export declare function revealFrames(grow: boolean): {
5
+ circle: Keyframe[];
6
+ view: Keyframe[];
7
+ };
8
+ /** Switches the page to `flavour` with the circle from `origin`. Without view transitions,
9
+ * or with motion held still, it switches at once. */
10
+ export declare function revealFlavour(flavour: Flavour, origin: HTMLElement): Promise<void>;
@@ -0,0 +1,92 @@
1
+ // Switching flavours with a circle from the button that asked: a view transition
2
+ // (developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). The lighter of the two
3
+ // flavours is the circle: going lighter, it grows out of the button over the old view;
4
+ // going darker, the old view shrinks into the button. The button takes the new flavour
5
+ // a beat before the page does. The circle and the view inside it are scaled in opposite
6
+ // directions on the compositor, so the view stays put. tokens.css has the styles.
7
+ import { still } from '../motion/still';
8
+ import { applyFlavour, paintThemeColor } from './theme';
9
+ /** Darkest to lightest. */
10
+ const LIGHTNESS = { mocha: 0, macchiato: 1, frappe: 2, latte: 3 };
11
+ const LEAD_MS = 150; // the button shows the new flavour this long before the page follows
12
+ const GROW_MS = 650;
13
+ const SHRINK_MS = 650;
14
+ const GROW_EASING = [0.4, 0, 0.2, 1]; // cubic-bezier() control points
15
+ const SHRINK_EASING = [0.4, 0, 1, 1];
16
+ const STEPS = 100; // keyframes a reveal
17
+ const MIN_SCALE = 0.001; // the circle is a pixel or two across; the view stops scaling with it here
18
+ /** The reveal's keyframes, sampled along its cubic-bezier easing (offsets from the curve's x,
19
+ * progress from its y): the circle's scale, and its inverse for the view inside it. */
20
+ export function revealFrames(grow) {
21
+ const [x1, y1, x2, y2] = grow ? GROW_EASING : SHRINK_EASING;
22
+ const bezier = (p1, p2, u) => 3 * (1 - u) ** 2 * u * p1 + 3 * (1 - u) * u ** 2 * p2 + u ** 3;
23
+ const circle = [];
24
+ const view = [];
25
+ for (let i = 0; i <= STEPS; i++) {
26
+ const u = i / STEPS;
27
+ const offset = bezier(x1, x2, u);
28
+ const scale = grow ? bezier(y1, y2, u) : 1 - bezier(y1, y2, u);
29
+ circle.push({ offset, transform: `scale(${scale})` });
30
+ view.push({ offset, transform: `scale(${1 / Math.max(scale, MIN_SCALE)})` });
31
+ }
32
+ return { circle, view };
33
+ }
34
+ /** Switches the page to `flavour` with the circle from `origin`. Without view transitions,
35
+ * or with motion held still, it switches at once. */
36
+ export async function revealFlavour(flavour, origin) {
37
+ const root = document.documentElement;
38
+ const from = root.dataset.theme ?? 'mocha';
39
+ if (from === flavour)
40
+ return;
41
+ if (!document.startViewTransition || still(root)) {
42
+ applyFlavour(flavour);
43
+ return paintThemeColor();
44
+ }
45
+ const start = performance.now();
46
+ const grow = LIGHTNESS[flavour] > LIGHTNESS[from];
47
+ const page = document.body.getBoundingClientRect();
48
+ const box = origin.getBoundingClientRect();
49
+ const x = box.left + box.width / 2 - page.left;
50
+ const y = box.top + box.height / 2 - page.top;
51
+ const r = Math.hypot(Math.max(x, page.width - x), Math.max(y, page.height - y));
52
+ const geometry = { x, y, r, w: page.width, h: page.height };
53
+ for (const [name, px] of Object.entries(geometry))
54
+ root.style.setProperty(`--tui-reveal-${name}`, `${px}px`);
55
+ root.dataset.tuiReveal = grow ? 'grow' : 'shrink';
56
+ origin.dataset.theme = flavour;
57
+ const animations = [];
58
+ try {
59
+ // The old view is captured at the next frame, the button already in the new flavour; it
60
+ // stands in for the page through the lead while the new flavour is painted behind it.
61
+ const transition = document.startViewTransition(() => {
62
+ applyFlavour(flavour);
63
+ root.dataset.tuiRevealPhase = 'to';
64
+ delete origin.dataset.theme;
65
+ });
66
+ await transition.ready;
67
+ const delay = Math.max(0, LEAD_MS - (performance.now() - start));
68
+ const frames = revealFrames(grow);
69
+ const circle = grow ? 'tui-to' : 'tui-from';
70
+ // fill holds the first keyframe through the delay and the last until the transition is
71
+ // torn down; cancelled afterwards, or they would scale the next switch's views too.
72
+ const timing = { duration: grow ? GROW_MS : SHRINK_MS, delay, fill: 'both' };
73
+ animations.push(root.animate(frames.circle, { ...timing, pseudoElement: `::view-transition-image-pair(${circle})` }), root.animate(frames.view, { ...timing, pseudoElement: `::view-transition-${grow ? 'new' : 'old'}(${circle})` }));
74
+ // The top of the screen uncovers first when shrinking, last when growing.
75
+ if (!grow) {
76
+ await new Promise((resolve) => setTimeout(resolve, delay));
77
+ paintThemeColor();
78
+ }
79
+ await transition.finished;
80
+ }
81
+ finally {
82
+ for (const animation of animations)
83
+ animation.cancel();
84
+ applyFlavour(flavour);
85
+ delete origin.dataset.theme;
86
+ paintThemeColor();
87
+ delete root.dataset.tuiReveal;
88
+ delete root.dataset.tuiRevealPhase;
89
+ for (const name of Object.keys(geometry))
90
+ root.style.removeProperty(`--tui-reveal-${name}`);
91
+ }
92
+ }
@@ -0,0 +1,15 @@
1
+ import type { Flavour } from './palette';
2
+ export type ThemeChoice = Flavour | 'system';
3
+ /** What System shows in light mode and in dark mode. */
4
+ export interface SystemFlavours {
5
+ light: Flavour;
6
+ dark: Flavour;
7
+ }
8
+ export declare const SYSTEM_FLAVOURS: SystemFlavours;
9
+ export declare const DARK_QUERY = "(prefers-color-scheme: dark)";
10
+ /** The flavour a choice shows, `dark` being whether the device is in dark mode. */
11
+ export declare function shownFlavour(choice: ThemeChoice, dark: boolean, system?: SystemFlavours): Flavour;
12
+ /** Shows `flavour` on `root` (the page, by default) at once. */
13
+ export declare function applyFlavour(flavour: Flavour, root?: HTMLElement): void;
14
+ /** Points the browser's theme-color (a phone's status bar) at the page's background. */
15
+ export declare function paintThemeColor(): void;
@@ -0,0 +1,21 @@
1
+ // Choosing a flavour: one of the four, or System, which shows a light or a dark flavour
2
+ // as the device is. The page carries it as data-theme on the root (tokens.css); any
3
+ // element can carry its own (Theme.svelte).
4
+ export const SYSTEM_FLAVOURS = { light: 'latte', dark: 'mocha' };
5
+ export const DARK_QUERY = '(prefers-color-scheme: dark)';
6
+ /** The flavour a choice shows, `dark` being whether the device is in dark mode. */
7
+ export function shownFlavour(choice, dark, system = SYSTEM_FLAVOURS) {
8
+ if (choice !== 'system')
9
+ return choice;
10
+ return dark ? system.dark : system.light;
11
+ }
12
+ /** Shows `flavour` on `root` (the page, by default) at once. */
13
+ export function applyFlavour(flavour, root = document.documentElement) {
14
+ root.dataset.theme = flavour;
15
+ }
16
+ /** Points the browser's theme-color (a phone's status bar) at the page's background. */
17
+ export function paintThemeColor() {
18
+ const meta = document.querySelector('meta[name="theme-color"]');
19
+ if (meta)
20
+ meta.content = getComputedStyle(document.documentElement).backgroundColor;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,74 @@
1
1
  {
2
2
  "name": "tuidroid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Svelte components drawn like a terminal: line boxes, word buttons and text-cell charts in Catppuccin",
5
+ "keywords": [
6
+ "svelte",
7
+ "components",
8
+ "tui",
9
+ "catppuccin",
10
+ "monospace"
11
+ ],
12
+ "license": "GPL-3.0-or-later",
13
+ "homepage": "https://nouritsu.codeberg.page/tuidroid/",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://codeberg.org/nouritsu/tuidroid.git"
17
+ },
18
+ "bugs": "https://codeberg.org/nouritsu/tuidroid/issues",
19
+ "type": "module",
20
+ "scripts": {
21
+ "dev": "vite dev",
22
+ "build": "vite build && npm run package",
23
+ "package": "svelte-kit sync && svelte-package",
24
+ "preview": "vite preview",
25
+ "prepare": "svelte-kit sync || echo ''",
26
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
27
+ "test": "vitest run",
28
+ "test:unit": "vitest run --project unit",
29
+ "test:browser": "vitest run --project browser",
30
+ "format": "prettier --write ."
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "!dist/**/*.test.*"
35
+ ],
36
+ "sideEffects": [
37
+ "**/*.css"
38
+ ],
39
+ "svelte": "./dist/index.js",
40
+ "types": "./dist/index.d.ts",
41
+ "imports": {
42
+ "#lib": "./src/lib/index.js",
43
+ "#lib/*": "./src/lib/*"
44
+ },
45
+ "exports": {
46
+ ".": {
47
+ "types": "./dist/index.d.ts",
48
+ "svelte": "./dist/index.js"
49
+ },
50
+ "./tokens.css": "./dist/styles/tokens.css",
51
+ "./base.css": "./dist/styles/base.css"
52
+ },
53
+ "peerDependencies": {
54
+ "svelte": "^5.59.0"
55
+ },
56
+ "devDependencies": {
57
+ "@fontsource/iosevka": "^5.3.0",
58
+ "@sveltejs/adapter-static": "^4.0.1",
59
+ "@sveltejs/kit": "^3.4.0",
60
+ "@sveltejs/package": "^3.0.3",
61
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
62
+ "@types/node": "^24.19.2",
63
+ "@vitest/browser-playwright": "^5.1.1",
64
+ "playwright": "1.64.1",
65
+ "prettier": "^3.10.1",
66
+ "prettier-plugin-svelte": "^4.2.0",
67
+ "svelte": "^5.59.1",
68
+ "svelte-check": "^4.7.8",
69
+ "typescript": "^6.0.3",
70
+ "vite": "^8.3.8",
71
+ "vitest": "^5.1.1",
72
+ "vitest-browser-svelte": "^3.1.0"
73
+ }
74
+ }