@kodentuzo/spotstrap 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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -2
  3. package/dist/js/index.d.ts +17 -0
  4. package/dist/js/spotstrap.js +3 -0
  5. package/dist/js/spotstrap.js.map +7 -0
  6. package/dist/recipes/index.d.ts +86 -0
  7. package/dist/recipes/index.js +211 -0
  8. package/dist/recipes/sizes.d.ts +21 -0
  9. package/dist/spotstrap.css +1694 -0
  10. package/dist/themes/kodentuzo.css +128 -0
  11. package/dist/themes/librelifts.css +128 -0
  12. package/dist/themes/librevitalis.css +128 -0
  13. package/dist/themes/neutral.css +128 -0
  14. package/dist/themes/sokobanko.css +135 -0
  15. package/dist/themes/spotcraft.css +128 -0
  16. package/dist/themes/tagtape.css +128 -0
  17. package/dist/themes/vinskiano.css +128 -0
  18. package/dist/tokens.json +2473 -0
  19. package/package.json +81 -4
  20. package/src/components/button.css +168 -0
  21. package/src/components/disclosure.css +235 -0
  22. package/src/components/field.css +173 -0
  23. package/src/components/menu.css +129 -0
  24. package/src/components/overlay.css +160 -0
  25. package/src/components/toggle.css +219 -0
  26. package/src/dark-class.css +19 -0
  27. package/src/js/index.ts +246 -0
  28. package/src/native.css +17 -0
  29. package/src/recipes/index.ts +262 -0
  30. package/src/recipes/sizes.ts +20 -0
  31. package/src/tailwind.css +67 -0
  32. package/src/themes/kodentuzo.css +136 -0
  33. package/src/themes/librelifts.css +136 -0
  34. package/src/themes/librevitalis.css +136 -0
  35. package/src/themes/neutral.css +137 -0
  36. package/src/themes/sokobanko.css +144 -0
  37. package/src/themes/spotcraft.css +136 -0
  38. package/src/themes/tagtape.css +136 -0
  39. package/src/themes/vinskiano.css +136 -0
  40. package/src/tokens.css +42 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @kodentuzo/spotstrap/recipes: the components as Uniwind class strings for React Native, built from the
3
+ * same tokens as the web (docs/decisions/0002-package-and-publishing.md).
4
+ *
5
+ * React Native has no :hover, :checked or ::after, so state comes in as options, and small
6
+ * targets get a `hitSlop` instead of an overlay. Every class is written out in full, since
7
+ * Tailwind and Uniwind find classes by scanning source for literal strings; the pixel
8
+ * values match src/tokens.css (a test checks).
9
+ *
10
+ * const b = button({ variant: 'outline', pressed })
11
+ * <Pressable className={b.className} hitSlop={b.hitSlop}>
12
+ * <Text className={b.textClassName}>Export…</Text>
13
+ * </Pressable>
14
+ */
15
+ export * as sizes from './sizes.js';
16
+ export interface Recipe {
17
+ className: string;
18
+ hitSlop?: {
19
+ top: number;
20
+ bottom: number;
21
+ left: number;
22
+ right: number;
23
+ };
24
+ }
25
+ export interface TextRecipe extends Recipe {
26
+ textClassName: string;
27
+ }
28
+ export type ButtonVariant = 'default' | 'secondary' | 'outline' | 'ghost' | 'link' | 'destructive';
29
+ export interface ButtonOptions {
30
+ variant?: ButtonVariant;
31
+ size?: 'default' | 'compact';
32
+ icon?: boolean;
33
+ pressed?: boolean;
34
+ disabled?: boolean;
35
+ }
36
+ export declare function button({ variant, size, icon, pressed, disabled, }?: ButtonOptions): TextRecipe;
37
+ export declare function field(): Recipe;
38
+ export declare function label({ disabled }?: {
39
+ disabled?: boolean | undefined;
40
+ }): Recipe;
41
+ export declare function fieldDescription(): Recipe;
42
+ export declare function fieldError(): Recipe;
43
+ export interface InputOptions {
44
+ focused?: boolean;
45
+ invalid?: boolean;
46
+ disabled?: boolean;
47
+ multiline?: boolean;
48
+ }
49
+ /** For a TextInput. Text is 17pt (body), above the 16 iOS needs not to zoom. */
50
+ export declare function input({ focused, invalid, disabled, multiline, }?: InputOptions): Recipe;
51
+ /** A row holding a control and its label; the whole row is the target. */
52
+ export declare function choice({ disabled }?: {
53
+ disabled?: boolean | undefined;
54
+ }): Recipe;
55
+ export interface ToggleOptions {
56
+ checked?: boolean;
57
+ disabled?: boolean;
58
+ }
59
+ export declare function checkbox({ checked, disabled }?: ToggleOptions): Recipe;
60
+ export declare function radio({ checked, disabled }?: ToggleOptions): Recipe;
61
+ /** The check or dot inside a checked checkbox or radio. */
62
+ export declare function toggleMark(): Recipe;
63
+ /** A switch you draw yourself; React Native's own Switch also fits the size. */
64
+ export declare function switchTrack({ checked, disabled }?: ToggleOptions): Recipe;
65
+ export declare function switchThumb(): Recipe;
66
+ export declare function radioGroup(): Recipe;
67
+ export declare function menu(): Recipe;
68
+ export interface ItemOptions {
69
+ highlighted?: boolean;
70
+ selected?: boolean;
71
+ destructive?: boolean;
72
+ disabled?: boolean;
73
+ compact?: boolean;
74
+ }
75
+ export declare function menuItem({ highlighted, destructive, disabled, compact: isCompact, }?: ItemOptions): TextRecipe;
76
+ export declare function tabList(): Recipe;
77
+ export declare function tab({ selected, disabled }?: {
78
+ selected?: boolean | undefined;
79
+ disabled?: boolean | undefined;
80
+ }): TextRecipe;
81
+ /** The sheet a dialog becomes on a phone: at the bottom, rounded on top. */
82
+ export declare function sheet(): Recipe;
83
+ export declare function sheetTitle(): Recipe;
84
+ export declare function sheetDescription(): Recipe;
85
+ /** Sheet actions stack full width; put the primary action first, Cancel last. */
86
+ export declare function sheetActions(): Recipe;
@@ -0,0 +1,211 @@
1
+ /* spotstrap 0.1.0: React Native recipes. MIT. Built from src/; don't edit. */
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ // src/recipes/sizes.ts
9
+ var sizes_exports = {};
10
+ __export(sizes_exports, {
11
+ box: () => box,
12
+ compact: () => compact,
13
+ control: () => control,
14
+ gap: () => gap,
15
+ slop: () => slop,
16
+ switchSize: () => switchSize
17
+ });
18
+ var control = 44;
19
+ var compact = 36;
20
+ var gap = 12;
21
+ var box = 20;
22
+ var switchSize = { width: 51, height: 31, thumb: 27 };
23
+ function slop(width, height = width) {
24
+ const x = Math.max(0, Math.ceil((control - width) / 2));
25
+ const y = Math.max(0, Math.ceil((control - height) / 2));
26
+ return { top: y, bottom: y, left: x, right: x };
27
+ }
28
+
29
+ // src/recipes/index.ts
30
+ var join = (...parts) => parts.filter(Boolean).join(" ");
31
+ var buttonColors = {
32
+ default: { box: "bg-primary", text: "text-primary-foreground" },
33
+ secondary: { box: "bg-secondary", text: "text-secondary-foreground" },
34
+ outline: { box: "bg-background border border-border", text: "text-foreground" },
35
+ ghost: { box: "bg-transparent", text: "text-foreground" },
36
+ link: { box: "bg-transparent", text: "text-foreground underline" },
37
+ destructive: { box: "bg-destructive", text: "text-destructive-foreground" }
38
+ };
39
+ function button({
40
+ variant = "default",
41
+ size = "default",
42
+ icon = false,
43
+ pressed = false,
44
+ disabled = false
45
+ } = {}) {
46
+ const height = size === "compact" ? compact : control;
47
+ const colors = buttonColors[variant];
48
+ return {
49
+ className: join(
50
+ "flex-row items-center justify-center gap-2 rounded-lg",
51
+ icon ? size === "compact" ? "h-[36px] w-[36px]" : "h-[44px] w-[44px]" : size === "compact" ? "min-h-[36px]" : "min-h-[44px]",
52
+ !icon && (variant === "link" ? "px-1" : size === "compact" ? "px-3" : "px-4"),
53
+ colors.box,
54
+ pressed && "opacity-85 scale-[0.97]",
55
+ disabled && "opacity-50"
56
+ ),
57
+ textClassName: join(
58
+ size === "compact" ? "text-subhead" : "text-body",
59
+ "font-medium",
60
+ colors.text
61
+ ),
62
+ hitSlop: slop(icon ? height : control, height)
63
+ };
64
+ }
65
+ function field() {
66
+ return { className: "gap-1.5" };
67
+ }
68
+ function label({ disabled = false } = {}) {
69
+ return { className: join("text-subhead font-medium text-foreground", disabled && "opacity-50") };
70
+ }
71
+ function fieldDescription() {
72
+ return { className: "text-footnote text-muted-foreground" };
73
+ }
74
+ function fieldError() {
75
+ return { className: "text-footnote text-destructive" };
76
+ }
77
+ function input({
78
+ focused = false,
79
+ invalid = false,
80
+ disabled = false,
81
+ multiline = false
82
+ } = {}) {
83
+ return {
84
+ className: join(
85
+ multiline ? "min-h-[108px]" : "min-h-[44px]",
86
+ "px-3 py-2.5 rounded-lg border",
87
+ "bg-background text-foreground text-body",
88
+ invalid ? "border-destructive" : focused ? "border-ring" : "border-input",
89
+ disabled && "opacity-50"
90
+ )
91
+ };
92
+ }
93
+ function choice({ disabled = false } = {}) {
94
+ return {
95
+ className: join("flex-row items-center gap-3 min-h-[44px]", disabled && "opacity-50")
96
+ };
97
+ }
98
+ function checkbox({ checked = false, disabled = false } = {}) {
99
+ return {
100
+ className: join(
101
+ "h-[20px] w-[20px] items-center justify-center rounded-sm border-[1.5px]",
102
+ checked ? "bg-primary border-primary" : "bg-background border-muted-foreground",
103
+ disabled && "opacity-50"
104
+ ),
105
+ hitSlop: slop(box)
106
+ };
107
+ }
108
+ function radio({ checked = false, disabled = false } = {}) {
109
+ return {
110
+ className: join(
111
+ "h-[20px] w-[20px] items-center justify-center rounded-full border-[1.5px]",
112
+ checked ? "bg-primary border-primary" : "bg-background border-muted-foreground",
113
+ disabled && "opacity-50"
114
+ ),
115
+ hitSlop: slop(box)
116
+ };
117
+ }
118
+ function toggleMark() {
119
+ return { className: "text-primary-foreground" };
120
+ }
121
+ function switchTrack({ checked = false, disabled = false } = {}) {
122
+ return {
123
+ className: join(
124
+ "h-[31px] w-[51px] rounded-full p-0.5",
125
+ checked ? "bg-primary items-end" : "bg-muted items-start",
126
+ disabled && "opacity-50"
127
+ ),
128
+ hitSlop: slop(switchSize.width, switchSize.height)
129
+ };
130
+ }
131
+ function switchThumb() {
132
+ return { className: "h-[27px] w-[27px] rounded-full bg-white shadow-sm" };
133
+ }
134
+ function radioGroup() {
135
+ return { className: "gap-[12px]" };
136
+ }
137
+ function menu() {
138
+ return { className: "p-1 rounded-lg border border-border bg-popover shadow-lg" };
139
+ }
140
+ function menuItem({
141
+ highlighted = false,
142
+ destructive = false,
143
+ disabled = false,
144
+ compact: isCompact = false
145
+ } = {}) {
146
+ return {
147
+ className: join(
148
+ "flex-row items-center gap-3 px-3 rounded-md",
149
+ isCompact ? "min-h-[36px]" : "min-h-[44px]",
150
+ highlighted && "bg-accent",
151
+ disabled && "opacity-50"
152
+ ),
153
+ textClassName: join(
154
+ "text-body",
155
+ destructive ? "text-destructive" : highlighted ? "text-accent-foreground" : "text-popover-foreground"
156
+ ),
157
+ hitSlop: isCompact ? slop(control, compact) : void 0
158
+ };
159
+ }
160
+ function tabList() {
161
+ return { className: "flex-row gap-1 border-b border-border" };
162
+ }
163
+ function tab({ selected = false, disabled = false } = {}) {
164
+ return {
165
+ className: join(
166
+ "min-h-[44px] px-3.5 items-center justify-center border-b-2",
167
+ selected ? "border-foreground" : "border-transparent",
168
+ disabled && "opacity-50"
169
+ ),
170
+ textClassName: join(
171
+ "text-body font-medium",
172
+ selected ? "text-foreground" : "text-muted-foreground"
173
+ )
174
+ };
175
+ }
176
+ function sheet() {
177
+ return { className: "gap-4 p-6 rounded-t-xl border border-b-0 border-border bg-popover" };
178
+ }
179
+ function sheetTitle() {
180
+ return { className: "text-title-3 font-semibold text-popover-foreground" };
181
+ }
182
+ function sheetDescription() {
183
+ return { className: "text-body text-muted-foreground" };
184
+ }
185
+ function sheetActions() {
186
+ return { className: "gap-[12px]" };
187
+ }
188
+ export {
189
+ button,
190
+ checkbox,
191
+ choice,
192
+ field,
193
+ fieldDescription,
194
+ fieldError,
195
+ input,
196
+ label,
197
+ menu,
198
+ menuItem,
199
+ radio,
200
+ radioGroup,
201
+ sheet,
202
+ sheetActions,
203
+ sheetDescription,
204
+ sheetTitle,
205
+ sizes_exports as sizes,
206
+ switchThumb,
207
+ switchTrack,
208
+ tab,
209
+ tabList,
210
+ toggleMark
211
+ };
@@ -0,0 +1,21 @@
1
+ /** A control's height: buttons, inputs, list rows, tabs. */
2
+ export declare const control = 44;
3
+ /** A compact control's height; its hit area is still 44. */
4
+ export declare const compact = 36;
5
+ /** Space between two targets. */
6
+ export declare const gap = 12;
7
+ /** A checkbox or radio box. */
8
+ export declare const box = 20;
9
+ /** Apple's switch. */
10
+ export declare const switchSize: {
11
+ readonly width: 51;
12
+ readonly height: 31;
13
+ readonly thumb: 27;
14
+ };
15
+ /** The hitSlop that grows a `size`-point target to `control` points on every side. */
16
+ export declare function slop(width: number, height?: number): {
17
+ top: number;
18
+ bottom: number;
19
+ left: number;
20
+ right: number;
21
+ };