rei-kit 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -24,9 +24,21 @@ Supabase entry. Hibi moves onto it next.
24
24
  pnpm add rei-kit
25
25
  ```
26
26
 
27
- `vue`, `tailwindcss` and `lucide-vue-next` are peer dependencies the app
28
- supplies them, so there is never a second copy of the Vue runtime.
29
- `vue-i18n` is optional and only needed for the i18n runtime.
27
+ Everything the kit expects from the app is a peer dependency, so the app's copy
28
+ is the only copy:
29
+
30
+ | peer | needed for |
31
+ | ----------------------- | --------------------------------- |
32
+ | `vue` | everything |
33
+ | `tailwindcss` | the tokens and utilities |
34
+ | `lucide-vue-next` | component icons |
35
+ | `vue-router` | `TabBar`, `LocaleLinks` |
36
+ | `vue-i18n` | the i18n runtime only |
37
+ | `@supabase/supabase-js` | the `rei-kit/supabase` entry only |
38
+
39
+ This is not a formality. A second copy of a library that works through
40
+ provide/inject is not a spare copy -- it is a different injection key, so the
41
+ app's own provider becomes invisible and the component throws on mount.
30
42
 
31
43
  ## Use
32
44
 
@@ -45,17 +57,71 @@ downloads it:
45
57
  import { createSupabaseClient } from 'rei-kit/supabase'
46
58
  ```
47
59
 
60
+ ### Wiring the styles
61
+
62
+ Three lines, and all three are load-bearing:
63
+
48
64
  ```css
49
65
  /* your app's main.css */
50
66
  @import 'tailwindcss';
51
- @import 'rei-kit/tokens.css'; /* Tailwind source: tokens and utilities */
67
+ @import 'rei-kit/tokens.css'; /* colour roles, the dark variant, utilities */
52
68
  @import 'rei-kit/styles.css'; /* compiled component styles */
53
69
 
54
- /* the whole rebrand */
70
+ /* Tailwind generates a utility only where it has seen the class, and it does
71
+ not walk node_modules on its own. Without this the kit's components render
72
+ with every class present in the markup and absent from the stylesheet. */
73
+ @source '../../node_modules/rei-kit/dist';
74
+ ```
75
+
76
+ The path is relative to the CSS file, so adjust the `../` depth to where your
77
+ `main.css` sits.
78
+
79
+ Leaving any of the three out fails quietly: the build succeeds, the components
80
+ mount, and they come out unstyled. Nothing type-checks this, so it is worth a
81
+ test -- see _Not breaking the apps that use it_.
82
+
83
+ ### Prerendering
84
+
85
+ The kit imports and renders on a server, so an app can prerender with
86
+ `vite-ssg` or any other SSR build. Two things stay the app's job, because only
87
+ the app knows the answer:
88
+
89
+ - **The theme.** `applyTheme` does nothing without a document, so prerendered
90
+ HTML carries no `.dark`. Set it before hydration with a small synchronous
91
+ script in `index.html`, or the first paint flashes light.
92
+ - **Today's date.** `useToday()` on a server is the *server's* today, a
93
+ different day from the visitor's either side of midnight. Render anything
94
+ derived from it on the client.
95
+
96
+ ### Colours
97
+
98
+ `tokens.css` defines all eleven roles, a `.dark` block for each surface, and the
99
+ `dark` variant. A new app rebrands by overriding values, never by renaming:
100
+
101
+ ```css
55
102
  @theme {
56
- --color-primary: #6b4de6;
103
+ --color-primary: #6b4de6; /* main action */
104
+ --color-accent: #3b2f8f;
57
105
  --color-positive: #2fa36b;
58
106
  --color-negative: #d1453b;
107
+ --color-warning: #d89a3e;
108
+ --color-muted: #efeaff; /* calm surface, empty cell */
109
+ --color-canvas: #faf9ff; /* behind the shell */
110
+ --color-surface: #ffffff; /* card */
111
+ --color-ink: #17132b; /* text */
112
+ --color-ink-soft: #6a6484; /* secondary text */
113
+ --color-hair: #e8e4f2; /* rule */
114
+ }
115
+ ```
116
+
117
+ An app that already has its own palette does not have to rename it. Alias the
118
+ roles onto the names it already uses, and keep them as `var()` references so
119
+ the app's own dark-mode overrides carry into the kit's components:
120
+
121
+ ```css
122
+ @theme {
123
+ --color-primary: var(--color-sea);
124
+ --color-muted: var(--color-mist);
59
125
  }
60
126
  ```
61
127
 
@@ -4,7 +4,13 @@ export type ThemePreference = 'system' | 'light' | 'dark';
4
4
  export declare function isThemePreference(value: unknown): value is ThemePreference;
5
5
  /** Reads the stored preference, falling back to `system`. */
6
6
  export declare function readStoredTheme(): ThemePreference;
7
- /** Adds or removes `.dark` on `<html>`, resolving `system` against the OS. */
7
+ /**
8
+ * Adds or removes `.dark` on `<html>`, resolving `system` against the OS.
9
+ *
10
+ * A no-op without a document. There is no OS preference to read on a server and
11
+ * no `<html>` to write to, so a prerender leaves the class off and the app
12
+ * decides the theme before hydration — see the note in the README.
13
+ */
8
14
  export declare function applyTheme(preference: ThemePreference): void;
9
15
  /**
10
16
  * Sets where the preference is stored.
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * @returns Read-only ref holding today's `YYYY-MM-DD` key.
3
3
  *
4
+ * Rendered on a server this is the *server's* today, which is a different day
5
+ * from the visitor's either side of midnight. Anything prerendered from it
6
+ * would hydrate to a different value; render it on the client.
7
+ *
4
8
  * @example
5
9
  * ```ts
6
10
  * const today = useToday()
@@ -12,7 +12,9 @@ export interface VisualViewportRect {
12
12
  * sized in `dvh` sitting partly underneath the keyboard.
13
13
  *
14
14
  * `null` means the API is unavailable, which callers should read as "trust the
15
- * layout viewport" rather than as zero.
15
+ * layout viewport" rather than as zero. A server has no viewport at all, so it
16
+ * gets that same `null` — this runs during `setup`, and a component using it
17
+ * has to survive being rendered there.
16
18
  *
17
19
  * @example
18
20
  * ```ts