@firetail/finchly-ux 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.
- package/README.md +267 -2
- package/dist/components/action-button.d.ts +12 -0
- package/dist/components/action-button.js +34 -0
- package/dist/components/action-button.js.map +1 -0
- package/dist/components/app-shell.d.ts +18 -0
- package/dist/components/app-shell.js +56 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/ask.d.ts +37 -0
- package/dist/components/ask.js +73 -0
- package/dist/components/ask.js.map +1 -0
- package/dist/components/bar.d.ts +11 -0
- package/dist/components/bar.js +187 -0
- package/dist/components/bar.js.map +1 -0
- package/dist/components/choosing.d.ts +18 -0
- package/dist/components/choosing.js +68 -0
- package/dist/components/choosing.js.map +1 -0
- package/dist/components/column-chart.d.ts +50 -0
- package/dist/components/column-chart.js +181 -0
- package/dist/components/column-chart.js.map +1 -0
- package/dist/components/composing.d.ts +40 -0
- package/dist/components/composing.js +101 -0
- package/dist/components/composing.js.map +1 -0
- package/dist/components/conversation.d.ts +50 -0
- package/dist/components/conversation.js +116 -0
- package/dist/components/conversation.js.map +1 -0
- package/dist/components/data-table.d.ts +43 -0
- package/dist/components/data-table.js +212 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/fields.d.ts +61 -0
- package/dist/components/fields.js +144 -0
- package/dist/components/fields.js.map +1 -0
- package/dist/components/file-button.d.ts +16 -0
- package/dist/components/file-button.js +39 -0
- package/dist/components/file-button.js.map +1 -0
- package/dist/components/form-dialog.d.ts +51 -0
- package/dist/components/form-dialog.js +113 -0
- package/dist/components/form-dialog.js.map +1 -0
- package/dist/components/link-button.d.ts +5 -0
- package/dist/components/link-button.js +24 -0
- package/dist/components/link-button.js.map +1 -0
- package/dist/components/link-tabs.d.ts +13 -0
- package/dist/components/link-tabs.js +26 -0
- package/dist/components/link-tabs.js.map +1 -0
- package/dist/components/markdown.d.ts +13 -0
- package/dist/components/markdown.js +132 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page.d.ts +18 -0
- package/dist/components/page.js +45 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/palette.d.ts +16 -0
- package/dist/components/palette.js +27 -0
- package/dist/components/palette.js.map +1 -0
- package/dist/components/panel.d.ts +12 -0
- package/dist/components/panel.js +30 -0
- package/dist/components/panel.js.map +1 -0
- package/dist/components/pick-tile.d.ts +21 -0
- package/dist/components/pick-tile.js +40 -0
- package/dist/components/pick-tile.js.map +1 -0
- package/dist/components/provider-mark.d.ts +33 -0
- package/dist/components/provider-mark.js +58 -0
- package/dist/components/provider-mark.js.map +1 -0
- package/dist/components/provider.d.ts +17 -0
- package/dist/components/provider.js +39 -0
- package/dist/components/provider.js.map +1 -0
- package/dist/components/rows.d.ts +48 -0
- package/dist/components/rows.js +112 -0
- package/dist/components/rows.js.map +1 -0
- package/dist/components/side-nav.d.ts +23 -0
- package/dist/components/side-nav.js +41 -0
- package/dist/components/side-nav.js.map +1 -0
- package/dist/components/states.d.ts +19 -0
- package/dist/components/states.js +45 -0
- package/dist/components/states.js.map +1 -0
- package/dist/components/suggest-field.d.ts +19 -0
- package/dist/components/suggest-field.js +124 -0
- package/dist/components/suggest-field.js.map +1 -0
- package/dist/components/tag.d.ts +27 -0
- package/dist/components/tag.js +38 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/components/text.d.ts +41 -0
- package/dist/components/text.js +97 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/tile.d.ts +30 -0
- package/dist/components/tile.js +68 -0
- package/dist/components/tile.js.map +1 -0
- package/dist/components/toast.d.ts +10 -0
- package/dist/components/toast.js +38 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/button.js +45 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +57 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +20 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +24 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +92 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +65 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +89 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +16 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +14 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +8 -0
- package/dist/components/ui/native-select.js +39 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +27 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +15 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +13 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +16 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +53 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +14 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +41 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +56 -0
- package/dist/lib/api.d.ts +49 -0
- package/dist/lib/api.js +80 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/chart.d.ts +35 -0
- package/dist/lib/chart.js +86 -0
- package/dist/lib/chart.js.map +1 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/events.d.ts +34 -0
- package/dist/lib/events.js +72 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/format.d.ts +16 -0
- package/dist/lib/format.js +71 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/hash.d.ts +2 -0
- package/dist/lib/hash.js +13 -0
- package/dist/lib/hash.js.map +1 -0
- package/dist/lib/launcher.d.ts +54 -0
- package/dist/lib/launcher.js +46 -0
- package/dist/lib/launcher.js.map +1 -0
- package/dist/lib/markdown-inline.d.ts +18 -0
- package/dist/lib/markdown-inline.js +155 -0
- package/dist/lib/markdown-inline.js.map +1 -0
- package/dist/lib/markdown.d.ts +40 -0
- package/dist/lib/markdown.js +198 -0
- package/dist/lib/markdown.js.map +1 -0
- package/dist/lib/marks.d.ts +17 -0
- package/dist/lib/marks.js +56 -0
- package/dist/lib/marks.js.map +1 -0
- package/dist/lib/over.d.ts +26 -0
- package/dist/lib/over.js +38 -0
- package/dist/lib/over.js.map +1 -0
- package/dist/lib/route.d.ts +15 -0
- package/dist/lib/route.js +29 -0
- package/dist/lib/route.js.map +1 -0
- package/dist/lib/table.d.ts +43 -0
- package/dist/lib/table.js +86 -0
- package/dist/lib/table.js.map +1 -0
- package/dist/lib/theme.d.ts +12 -0
- package/dist/lib/theme.js +42 -0
- package/dist/lib/theme.js.map +1 -0
- package/eslint/index.d.ts +8 -0
- package/eslint/index.js +135 -0
- package/eslint/page-imports.js +46 -0
- package/package.json +91 -4
- package/styles/styles.css +221 -0
- package/styles/tokens.css +99 -0
- package/tsconfig.app.json +21 -0
- package/vite/index.d.ts +16 -0
- package/vite/index.js +84 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/* The one stylesheet a page built on finchly-ux has. An app imports it
|
|
2
|
+
once, in its entry, and writes no CSS of its own.
|
|
3
|
+
|
|
4
|
+
What is here: Tailwind, the platform's tokens, and the names Tailwind's
|
|
5
|
+
classes know them by. A page's colours are these names and no others:
|
|
6
|
+
Tailwind's own palette is taken out, so `bg-red-500` is not a class. */
|
|
7
|
+
|
|
8
|
+
@import "tailwindcss";
|
|
9
|
+
@import "tw-animate-css";
|
|
10
|
+
@import "./tokens.css";
|
|
11
|
+
|
|
12
|
+
/* The classes this library's own components use. An app's are found by
|
|
13
|
+
Tailwind where the app is built. */
|
|
14
|
+
@source "../dist";
|
|
15
|
+
|
|
16
|
+
/* A chart's marks have a colour of their own: the accent reads as grey at a
|
|
17
|
+
mark's size in one theme and glares in the other, and a tenant's accent
|
|
18
|
+
may be any colour at all. Light or dark follows the page's own scheme,
|
|
19
|
+
which the tokens say. */
|
|
20
|
+
:root {
|
|
21
|
+
--chart: #1f8a5c;
|
|
22
|
+
--chart: light-dark(#1f8a5c, #2f9e6e);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* --- The names --------------------------------------------------------------
|
|
26
|
+
shadcn's, because that is what its components are written in and what a
|
|
27
|
+
coding agent reaches for. Each is one of the platform's tokens. A tenant's
|
|
28
|
+
theme changes the token (`--accent`), never the name (`primary`). */
|
|
29
|
+
|
|
30
|
+
@theme {
|
|
31
|
+
--color-*: initial;
|
|
32
|
+
--color-black: #000;
|
|
33
|
+
--color-white: #fff;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@theme inline {
|
|
37
|
+
--color-background: var(--paper);
|
|
38
|
+
--color-foreground: var(--ink);
|
|
39
|
+
--color-card: var(--surface);
|
|
40
|
+
--color-card-foreground: var(--ink);
|
|
41
|
+
--color-popover: var(--surface);
|
|
42
|
+
--color-popover-foreground: var(--ink);
|
|
43
|
+
--color-primary: var(--accent);
|
|
44
|
+
--color-primary-foreground: var(--accent-ink);
|
|
45
|
+
--color-secondary: var(--surface-sunk);
|
|
46
|
+
--color-secondary-foreground: var(--ink);
|
|
47
|
+
--color-muted: var(--surface-sunk);
|
|
48
|
+
--color-muted-foreground: var(--ink-soft);
|
|
49
|
+
/* shadcn's "accent" is the ground of what is hovered or chosen: here, the accent's pale ground. */
|
|
50
|
+
--color-accent: var(--accent-soft);
|
|
51
|
+
--color-accent-foreground: var(--ink);
|
|
52
|
+
--color-destructive: var(--danger);
|
|
53
|
+
--color-border: var(--line);
|
|
54
|
+
--color-input: var(--line-strong);
|
|
55
|
+
--color-ring: var(--accent);
|
|
56
|
+
|
|
57
|
+
/* What shadcn has no name for. */
|
|
58
|
+
--color-faint: var(--ink-faint);
|
|
59
|
+
--color-destructive-soft: var(--danger-soft);
|
|
60
|
+
--color-success: var(--ok);
|
|
61
|
+
--color-success-soft: var(--ok-soft);
|
|
62
|
+
--color-warning: var(--warn);
|
|
63
|
+
--color-warning-soft: var(--warn-soft);
|
|
64
|
+
--color-agent: var(--agent);
|
|
65
|
+
--color-agent-soft: var(--agent-soft);
|
|
66
|
+
--color-chart: var(--chart);
|
|
67
|
+
|
|
68
|
+
--font-sans: var(--font);
|
|
69
|
+
--font-heading: var(--font);
|
|
70
|
+
--font-mono: var(--mono);
|
|
71
|
+
|
|
72
|
+
/* Controls are drawn at the smaller radius and what holds them at the larger. */
|
|
73
|
+
--radius-sm: calc(var(--radius-small) * 0.5);
|
|
74
|
+
--radius-md: calc(var(--radius-small) * 0.75);
|
|
75
|
+
--radius-lg: var(--radius-small);
|
|
76
|
+
--radius-xl: var(--radius);
|
|
77
|
+
--radius-2xl: calc(var(--radius) * 1.4);
|
|
78
|
+
--radius-3xl: calc(var(--radius) * 1.8);
|
|
79
|
+
--radius-4xl: calc(var(--radius) * 2.2);
|
|
80
|
+
|
|
81
|
+
--shadow-xs: var(--shadow);
|
|
82
|
+
--shadow-sm: var(--shadow);
|
|
83
|
+
--shadow-md: var(--shadow-raised);
|
|
84
|
+
--shadow-lg: var(--shadow-raised);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* --- What shadcn's components expect of a stylesheet ---------------------------
|
|
88
|
+
From shadcn's own tailwind.css: the states Base UI marks an element with. */
|
|
89
|
+
|
|
90
|
+
@custom-variant data-open {
|
|
91
|
+
&:where([data-state="open"]),
|
|
92
|
+
&:where([data-open]:not([data-open="false"])) {
|
|
93
|
+
@slot;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
@custom-variant data-closed {
|
|
97
|
+
&:where([data-state="closed"]),
|
|
98
|
+
&:where([data-closed]:not([data-closed="false"])) {
|
|
99
|
+
@slot;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
@custom-variant data-checked {
|
|
103
|
+
&:where([data-state="checked"]),
|
|
104
|
+
&:where([data-checked]:not([data-checked="false"])) {
|
|
105
|
+
@slot;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
@custom-variant data-unchecked {
|
|
109
|
+
&:where([data-state="unchecked"]),
|
|
110
|
+
&:where([data-unchecked]:not([data-unchecked="false"])) {
|
|
111
|
+
@slot;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
@custom-variant data-selected {
|
|
115
|
+
&:where([data-selected="true"]) {
|
|
116
|
+
@slot;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
@custom-variant data-disabled {
|
|
120
|
+
&:where([data-disabled="true"]),
|
|
121
|
+
&:where([data-disabled]:not([data-disabled="false"])) {
|
|
122
|
+
@slot;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
@custom-variant data-active {
|
|
126
|
+
&:where([data-state="active"]),
|
|
127
|
+
&:where([data-active]:not([data-active="false"])) {
|
|
128
|
+
@slot;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
@custom-variant data-horizontal {
|
|
132
|
+
&:where([data-orientation="horizontal"]) {
|
|
133
|
+
@slot;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
@custom-variant data-vertical {
|
|
137
|
+
&:where([data-orientation="vertical"]) {
|
|
138
|
+
@slot;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* --- A window that is not tall ----------------------------------------------------
|
|
143
|
+
For a page that fills the window (`AppShell fill`): on a phone held
|
|
144
|
+
sideways, or with its keyboard up, what matters less gives way so that
|
|
145
|
+
there is still room to read. `short:hidden`, `short:min-h-10`. */
|
|
146
|
+
|
|
147
|
+
@custom-variant short (@media (max-height: 650px));
|
|
148
|
+
|
|
149
|
+
/* --- Light and dark -------------------------------------------------------------
|
|
150
|
+
There is no `dark:` here, and the checks refuse it. A page is dark where
|
|
151
|
+
its tokens are, which a tenant can decide with nothing on the page to
|
|
152
|
+
say so. What must differ between the two is shown with these: an image
|
|
153
|
+
for light pages beside one for dark. */
|
|
154
|
+
|
|
155
|
+
@utility for-light {
|
|
156
|
+
display: var(--for-light);
|
|
157
|
+
}
|
|
158
|
+
@utility for-dark {
|
|
159
|
+
display: var(--for-dark);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* The face of something with no picture of its own: its letters, in a colour
|
|
163
|
+
worked out from its name (`--hue`, which Face sets). Light or dark follows
|
|
164
|
+
the page's own scheme, which the tokens say. */
|
|
165
|
+
@utility hue-face {
|
|
166
|
+
background: hsl(var(--hue, 150) 45% 92%);
|
|
167
|
+
color: hsl(var(--hue, 150) 45% 28%);
|
|
168
|
+
background: light-dark(hsl(var(--hue, 150) 45% 92%), hsl(var(--hue, 150) 30% 20%));
|
|
169
|
+
color: light-dark(hsl(var(--hue, 150) 45% 28%), hsl(var(--hue, 150) 55% 78%));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* The mark of a chart that is being read: a little towards the ink, so that
|
|
173
|
+
it is told from the others without another colour. */
|
|
174
|
+
@utility chart-on {
|
|
175
|
+
fill: color-mix(in srgb, var(--chart) 78%, var(--ink));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* The initials of something with no mark of its own (ProviderMark): on a
|
|
179
|
+
light tile whatever the page's scheme, as a mark is, so that the two
|
|
180
|
+
sit alike in one list. */
|
|
181
|
+
@utility hue-mark {
|
|
182
|
+
background: hsl(var(--hue, 150) 45% 92%);
|
|
183
|
+
color: hsl(var(--hue, 150) 55% 28%);
|
|
184
|
+
border-color: hsl(var(--hue, 150) 35% 82%);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@layer base {
|
|
188
|
+
* {
|
|
189
|
+
@apply border-border outline-ring/50;
|
|
190
|
+
}
|
|
191
|
+
html {
|
|
192
|
+
-webkit-text-size-adjust: 100%;
|
|
193
|
+
/* Going between a short page and a long one does not move the bar. */
|
|
194
|
+
scrollbar-gutter: stable;
|
|
195
|
+
}
|
|
196
|
+
body {
|
|
197
|
+
@apply min-h-screen bg-background font-sans text-foreground;
|
|
198
|
+
font-size: 15px;
|
|
199
|
+
line-height: 1.5;
|
|
200
|
+
}
|
|
201
|
+
a {
|
|
202
|
+
@apply text-primary underline-offset-2;
|
|
203
|
+
}
|
|
204
|
+
code,
|
|
205
|
+
pre {
|
|
206
|
+
@apply font-mono;
|
|
207
|
+
}
|
|
208
|
+
:focus-visible {
|
|
209
|
+
@apply outline-2 outline-offset-2 outline-ring;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Base UI hides a scrollbar with a <style> of its own, which the platform's
|
|
214
|
+
content security policy refuses. FinchlyProvider tells it not to, and
|
|
215
|
+
this is that style. */
|
|
216
|
+
.base-ui-disable-scrollbar {
|
|
217
|
+
scrollbar-width: none;
|
|
218
|
+
}
|
|
219
|
+
.base-ui-disable-scrollbar::-webkit-scrollbar {
|
|
220
|
+
display: none;
|
|
221
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* The platform's tokens: every colour, shadow and radius a page is drawn
|
|
2
|
+
in, for a light page and a dark one.
|
|
3
|
+
|
|
4
|
+
This is where they are said. The gateway's own pages carry them too
|
|
5
|
+
(gateway/pages.css), word for word, and platform-core's own look
|
|
6
|
+
(core/src/theme.ts) is these colours: a test holds each to this. Their
|
|
7
|
+
names are the contract a tenant's theme is written against:
|
|
8
|
+
`/_gateway/theme.css` says the same variables again, after this, where
|
|
9
|
+
a tenant's look differs. See spec/theme.md.
|
|
10
|
+
|
|
11
|
+
Nothing else belongs in this file. */
|
|
12
|
+
|
|
13
|
+
:root {
|
|
14
|
+
--paper: #f5f4f0;
|
|
15
|
+
--surface: #ffffff;
|
|
16
|
+
--surface-sunk: #efede7;
|
|
17
|
+
--ink: #1b1a17;
|
|
18
|
+
--ink-soft: #55524b;
|
|
19
|
+
--ink-faint: #8a867d;
|
|
20
|
+
--line: #e2dfd7;
|
|
21
|
+
--line-strong: #cfcbc1;
|
|
22
|
+
--accent: #23684a;
|
|
23
|
+
--accent-ink: #ffffff;
|
|
24
|
+
--accent-soft: #e3f0e8;
|
|
25
|
+
--agent: #6b4bc4;
|
|
26
|
+
--agent-soft: #ece7fa;
|
|
27
|
+
--warn: #9a5b00;
|
|
28
|
+
--warn-soft: #fbf0d9;
|
|
29
|
+
--danger: #b3261e;
|
|
30
|
+
--danger-soft: #fbe9e7;
|
|
31
|
+
--ok: #23684a;
|
|
32
|
+
--ok-soft: #e3f0e8;
|
|
33
|
+
--shadow: 0 1px 2px rgba(27, 26, 23, 0.06), 0 4px 14px rgba(27, 26, 23, 0.05);
|
|
34
|
+
--shadow-raised: 0 2px 6px rgba(27, 26, 23, 0.08), 0 14px 40px rgba(27, 26, 23, 0.14);
|
|
35
|
+
--radius: 12px;
|
|
36
|
+
--radius-small: 8px;
|
|
37
|
+
--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
38
|
+
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
39
|
+
/* Which of a tenant's two logos is shown: the one for light pages, or the one for dark. */
|
|
40
|
+
--for-light: inline-block;
|
|
41
|
+
--for-dark: none;
|
|
42
|
+
color-scheme: light;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:root[data-theme="dark"] {
|
|
46
|
+
--paper: #131311;
|
|
47
|
+
--surface: #1c1b19;
|
|
48
|
+
--surface-sunk: #171614;
|
|
49
|
+
--ink: #ece9e1;
|
|
50
|
+
--ink-soft: #b3aea3;
|
|
51
|
+
--ink-faint: #7f7b72;
|
|
52
|
+
--line: #2e2c28;
|
|
53
|
+
--line-strong: #423f39;
|
|
54
|
+
--accent: #6cc79a;
|
|
55
|
+
--accent-ink: #0d2318;
|
|
56
|
+
--accent-soft: #1a2e24;
|
|
57
|
+
--agent: #b19cf3;
|
|
58
|
+
--agent-soft: #262040;
|
|
59
|
+
--warn: #e4b45c;
|
|
60
|
+
--warn-soft: #33290f;
|
|
61
|
+
--danger: #f08a80;
|
|
62
|
+
--danger-soft: #3a1b18;
|
|
63
|
+
--ok: #6cc79a;
|
|
64
|
+
--ok-soft: #1a2e24;
|
|
65
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.25);
|
|
66
|
+
--shadow-raised: 0 2px 6px rgba(0, 0, 0, 0.5), 0 14px 40px rgba(0, 0, 0, 0.5);
|
|
67
|
+
--for-light: none;
|
|
68
|
+
--for-dark: inline-block;
|
|
69
|
+
color-scheme: dark;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media (prefers-color-scheme: dark) {
|
|
73
|
+
:root:not([data-theme="light"]) {
|
|
74
|
+
--paper: #131311;
|
|
75
|
+
--surface: #1c1b19;
|
|
76
|
+
--surface-sunk: #171614;
|
|
77
|
+
--ink: #ece9e1;
|
|
78
|
+
--ink-soft: #b3aea3;
|
|
79
|
+
--ink-faint: #7f7b72;
|
|
80
|
+
--line: #2e2c28;
|
|
81
|
+
--line-strong: #423f39;
|
|
82
|
+
--accent: #6cc79a;
|
|
83
|
+
--accent-ink: #0d2318;
|
|
84
|
+
--accent-soft: #1a2e24;
|
|
85
|
+
--agent: #b19cf3;
|
|
86
|
+
--agent-soft: #262040;
|
|
87
|
+
--warn: #e4b45c;
|
|
88
|
+
--warn-soft: #33290f;
|
|
89
|
+
--danger: #f08a80;
|
|
90
|
+
--danger-soft: #3a1b18;
|
|
91
|
+
--ok: #6cc79a;
|
|
92
|
+
--ok-soft: #1a2e24;
|
|
93
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.25);
|
|
94
|
+
--shadow-raised: 0 2px 6px rgba(0, 0, 0, 0.5), 0 14px 40px rgba(0, 0, 0, 0.5);
|
|
95
|
+
--for-light: none;
|
|
96
|
+
--for-dark: inline-block;
|
|
97
|
+
color-scheme: dark;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2023",
|
|
4
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"types": [],
|
|
14
|
+
|
|
15
|
+
"strict": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
|
19
|
+
"noUncheckedIndexedAccess": true
|
|
20
|
+
}
|
|
21
|
+
}
|
package/vite/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HtmlTagDescriptor, UserConfig } from "vite";
|
|
2
|
+
|
|
3
|
+
export interface FinchlyAppOptions {
|
|
4
|
+
/** The app's slug: where the gateway serves it, `/<slug>/`. */
|
|
5
|
+
slug: string;
|
|
6
|
+
/** Where under its slug the app serves the built files. `static` unless said. Empty for beside the page. */
|
|
7
|
+
assets?: string;
|
|
8
|
+
/** The HTML files the app has, where there is more than `index.html`. */
|
|
9
|
+
pages?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The Vite configuration of an app's page. An app's vite.config.ts is this and nothing else. */
|
|
13
|
+
export function finchlyApp(options: FinchlyAppOptions): UserConfig;
|
|
14
|
+
|
|
15
|
+
/** What every page's <head> has, beside what the app wrote. */
|
|
16
|
+
export function headTags(base: string): HtmlTagDescriptor[];
|
package/vite/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// How a page built on finchly-ux is built. An app's vite.config.ts is this
|
|
2
|
+
// and nothing else:
|
|
3
|
+
//
|
|
4
|
+
// import { finchlyApp } from "@firetail/finchly-ux/vite";
|
|
5
|
+
// export default finchlyApp({ slug: "my-app" });
|
|
6
|
+
//
|
|
7
|
+
// so that every page is built the same way, and a change to how is made
|
|
8
|
+
// here once.
|
|
9
|
+
|
|
10
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
11
|
+
import react from "@vitejs/plugin-react";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Loaded before the page is drawn, so that someone who chose light or
|
|
15
|
+
* dark here before never sees the other first. A file of its own, because
|
|
16
|
+
* the platform's pages run no inline script.
|
|
17
|
+
*/
|
|
18
|
+
const THEME_SCRIPT = `try {
|
|
19
|
+
var chosen = localStorage.getItem("finchly-theme");
|
|
20
|
+
if (chosen === "light" || chosen === "dark") document.documentElement.dataset.theme = chosen;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// No storage: the person's system decides.
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What every page's <head> has, beside what the app wrote.
|
|
28
|
+
*
|
|
29
|
+
* The tenant's theme is last, after the page's own stylesheet: it says
|
|
30
|
+
* the tokens again where the tenant's look differs, and the later of two
|
|
31
|
+
* wins. See spec/theme.md.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} base where the page's files are served from, with a slash at each end
|
|
34
|
+
*/
|
|
35
|
+
export function headTags(base) {
|
|
36
|
+
return [
|
|
37
|
+
{ tag: "link", attrs: { rel: "icon", href: "/_gateway/theme/icon" }, injectTo: "head-prepend" },
|
|
38
|
+
{ tag: "script", attrs: { src: `${base}theme.js` }, injectTo: "head-prepend" },
|
|
39
|
+
{ tag: "link", attrs: { rel: "stylesheet", href: "/_gateway/theme.css" }, injectTo: "head" },
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @returns {import("vite").Plugin} */
|
|
44
|
+
function finchlyPage() {
|
|
45
|
+
let base = "/";
|
|
46
|
+
return {
|
|
47
|
+
name: "finchly-ux:page",
|
|
48
|
+
configResolved(config) {
|
|
49
|
+
base = config.base;
|
|
50
|
+
},
|
|
51
|
+
// After Vite has put the page's own stylesheet in, so that the theme's link follows it.
|
|
52
|
+
transformIndexHtml: { order: "post", handler: () => headTags(base) },
|
|
53
|
+
generateBundle() {
|
|
54
|
+
this.emitFile({ type: "asset", fileName: "theme.js", source: THEME_SCRIPT });
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The Vite configuration of an app's page.
|
|
61
|
+
*
|
|
62
|
+
* @param {object} options
|
|
63
|
+
* @param {string} options.slug the app's slug: where the gateway serves it, `/<slug>/`
|
|
64
|
+
* @param {string} [options.assets] where under its slug the app serves the built files. A service built on the SDK
|
|
65
|
+
* serves them under `static`. Empty for an app that serves them beside the page.
|
|
66
|
+
* @param {string[]} [options.pages] the HTML files the app has, where there is more than `index.html`
|
|
67
|
+
* @returns {import("vite").UserConfig}
|
|
68
|
+
*/
|
|
69
|
+
export function finchlyApp({ slug, assets = "static", pages = ["index.html"] }) {
|
|
70
|
+
if (typeof slug !== "string" || !/^[a-z0-9][a-z0-9-]*$/.test(slug)) throw new Error("finchlyApp needs the app's slug, as its manifest has it");
|
|
71
|
+
return {
|
|
72
|
+
base: `/${slug}/${assets === "" ? "" : `${assets}/`}`,
|
|
73
|
+
publicDir: false,
|
|
74
|
+
plugins: [react(), tailwindcss(), finchlyPage()],
|
|
75
|
+
build: {
|
|
76
|
+
outDir: "dist",
|
|
77
|
+
emptyOutDir: true,
|
|
78
|
+
target: "es2023",
|
|
79
|
+
rolldownOptions: { input: pages },
|
|
80
|
+
},
|
|
81
|
+
// An app's tests: `vitest run`. What needs a page is tested in one.
|
|
82
|
+
test: { environment: "jsdom", include: ["src/**/*.test.{ts,tsx}"] },
|
|
83
|
+
};
|
|
84
|
+
}
|