@happyvertical/smrt-ui 0.55.15 → 0.55.17

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 (138) hide show
  1. package/AGENTS.md +14 -0
  2. package/README.md +68 -0
  3. package/dist/components/calendar/Calendar.svelte +59 -56
  4. package/dist/components/calendar/CalendarView.svelte +79 -76
  5. package/dist/components/calendar/DayView.svelte +39 -36
  6. package/dist/components/chat/MessageBubble.svelte +26 -23
  7. package/dist/components/chat/ReactionPicker.svelte +10 -7
  8. package/dist/components/chat/TypingIndicator.svelte +12 -9
  9. package/dist/components/data/CollectionList.svelte +10 -7
  10. package/dist/components/data/CollectionToolbar.svelte +5 -2
  11. package/dist/components/data/DataTable.svelte +51 -48
  12. package/dist/components/data/ListSortSelect.svelte +8 -5
  13. package/dist/components/data/SortableHeader.svelte +9 -6
  14. package/dist/components/display/ConfidenceBadge.svelte +11 -8
  15. package/dist/components/display/CurrencyDisplay.svelte +7 -4
  16. package/dist/components/display/DateDisplay.svelte +6 -3
  17. package/dist/components/display/Icon.svelte +4 -1
  18. package/dist/components/display/StatusBadge.svelte +9 -6
  19. package/dist/components/feedback/Alert.svelte +9 -6
  20. package/dist/components/feedback/ConfirmDialog.svelte +13 -10
  21. package/dist/components/feedback/LoadingOverlay.svelte +35 -32
  22. package/dist/components/feedback/Meter.svelte +4 -1
  23. package/dist/components/feedback/Modal.svelte +20 -17
  24. package/dist/components/feedback/PhoneSheet.svelte +4 -1
  25. package/dist/components/feedback/Progress.svelte +8 -5
  26. package/dist/components/feedback/ProgressBar.svelte +13 -10
  27. package/dist/components/feedback/Spinner.svelte +4 -1
  28. package/dist/components/feedback/ToastViewport.svelte +17 -14
  29. package/dist/components/feedback/WorkingStrip.svelte +6 -3
  30. package/dist/components/forms/CameraCapture.svelte +6 -3
  31. package/dist/components/forms/Checkbox.svelte +10 -7
  32. package/dist/components/forms/Combobox.svelte +4 -1
  33. package/dist/components/forms/DatePicker.svelte +7 -2
  34. package/dist/components/forms/DictationButton.svelte +17 -14
  35. package/dist/components/forms/DictationStatus.svelte +12 -9
  36. package/dist/components/forms/ErrorSummary.svelte +4 -1
  37. package/dist/components/forms/FieldLabel.svelte +9 -6
  38. package/dist/components/forms/Fieldset.svelte +4 -1
  39. package/dist/components/forms/FilePicker.svelte +4 -1
  40. package/dist/components/forms/Form.svelte +1 -1
  41. package/dist/components/forms/FormActionBar.svelte +4 -1
  42. package/dist/components/forms/FormGroup.svelte +6 -3
  43. package/dist/components/forms/Input.svelte +14 -11
  44. package/dist/components/forms/InputGroup.svelte +5 -2
  45. package/dist/components/forms/Listbox.svelte +4 -1
  46. package/dist/components/forms/MultiSelect.svelte +4 -1
  47. package/dist/components/forms/Radio.svelte +8 -5
  48. package/dist/components/forms/RadioGroup.svelte +5 -2
  49. package/dist/components/forms/RangeSlider.svelte +4 -1
  50. package/dist/components/forms/RelationInput.svelte +7 -4
  51. package/dist/components/forms/SearchInput.svelte +5 -2
  52. package/dist/components/forms/SegmentedControl.svelte +5 -2
  53. package/dist/components/forms/Select.svelte +12 -9
  54. package/dist/components/forms/SignaturePad.svelte +6 -3
  55. package/dist/components/forms/Slider.svelte +4 -1
  56. package/dist/components/forms/StagedControlReview.svelte +15 -12
  57. package/dist/components/forms/Switch.svelte +7 -4
  58. package/dist/components/forms/TagsInput.svelte +4 -1
  59. package/dist/components/forms/Textarea.svelte +13 -10
  60. package/dist/components/forms/TimePicker.svelte +7 -2
  61. package/dist/components/forms/Toggle.svelte +13 -10
  62. package/dist/components/forms/ToggleButton.svelte +4 -1
  63. package/dist/components/layout/ActionGroup.svelte +4 -1
  64. package/dist/components/layout/Container.svelte +4 -1
  65. package/dist/components/layout/EmptyState.svelte +11 -8
  66. package/dist/components/layout/Footer.svelte +4 -1
  67. package/dist/components/layout/Grid.svelte +13 -10
  68. package/dist/components/layout/Header.svelte +4 -1
  69. package/dist/components/layout/Masthead.svelte +4 -1
  70. package/dist/components/layout/PageHeader.svelte +10 -7
  71. package/dist/components/layout/PageLayout.svelte +3 -0
  72. package/dist/components/layout/SummaryCard.svelte +9 -6
  73. package/dist/components/memberships/MembershipCard.svelte +5 -2
  74. package/dist/components/memberships/MembershipList.svelte +5 -2
  75. package/dist/components/nav/FilterChips.svelte +13 -10
  76. package/dist/components/nav/Tabs.svelte +28 -24
  77. package/dist/components/permissions/PermissionPicker.svelte +4 -1
  78. package/dist/components/roles/RoleBadge.svelte +8 -5
  79. package/dist/components/roles/RoleSelector.svelte +21 -18
  80. package/dist/components/theme/ThemeProvider.svelte +7 -4
  81. package/dist/components/ui/Accordion.svelte +4 -1
  82. package/dist/components/ui/AccordionItem.svelte +4 -1
  83. package/dist/components/ui/Avatar.svelte +10 -7
  84. package/dist/components/ui/Badge.svelte +4 -1
  85. package/dist/components/ui/Button.svelte +11 -8
  86. package/dist/components/ui/Card.svelte +7 -4
  87. package/dist/components/ui/Chip.svelte +12 -9
  88. package/dist/components/ui/Disclosure.svelte +4 -1
  89. package/dist/components/ui/Dropdown.svelte +17 -14
  90. package/dist/components/ui/IconToggle.svelte +10 -7
  91. package/dist/components/ui/IconToggle.svelte.d.ts +1 -1
  92. package/dist/components/ui/IconToggle.svelte.d.ts.map +1 -1
  93. package/dist/components/ui/IconToggleGroup.svelte +8 -5
  94. package/dist/components/ui/Pagination.svelte +11 -8
  95. package/dist/components/ui/Popover.svelte +5 -2
  96. package/dist/components/ui/Skeleton.svelte +10 -7
  97. package/dist/components/ui/Tooltip.svelte +12 -9
  98. package/dist/components/ui/Tree.svelte +10 -7
  99. package/dist/styles/layers.css +8 -0
  100. package/dist/styles/layers.d.ts +9 -0
  101. package/dist/styles/layers.d.ts.map +1 -0
  102. package/dist/styles/layers.js +8 -0
  103. package/dist/styles/tokens.css +27 -69
  104. package/dist/styles/unstyled.css +65 -0
  105. package/dist/svelte/playground/BaseControlsPreview.svelte +3 -0
  106. package/dist/svelte/playground/CalendarPreview.svelte +5 -2
  107. package/dist/svelte/playground/CapturePreview.svelte +3 -0
  108. package/dist/svelte/playground/CodeSelectorsPreview.svelte +3 -0
  109. package/dist/svelte/playground/CollectionsPreview.svelte +3 -0
  110. package/dist/svelte/playground/DataTablePreview.svelte +3 -0
  111. package/dist/svelte/playground/FeedbackPreview.svelte +3 -0
  112. package/dist/svelte/playground/InteractiveControlsPreview.svelte +3 -0
  113. package/dist/svelte/playground/StylelessPreview.svelte +110 -0
  114. package/dist/svelte/playground/StylelessPreview.svelte.d.ts +4 -0
  115. package/dist/svelte/playground/StylelessPreview.svelte.d.ts.map +1 -0
  116. package/dist/svelte/playground.d.ts.map +1 -1
  117. package/dist/svelte/playground.js +10 -0
  118. package/dist/test-support/setup.js +9 -0
  119. package/dist/theme/ThemeProvider.svelte +3 -0
  120. package/dist/themes/CUSTOM_THEME_GUIDE.md +25 -0
  121. package/dist/themes/README.md +25 -0
  122. package/dist/themes/ThemeProvider.svelte +11 -2
  123. package/dist/themes/ThemeProvider.svelte.d.ts.map +1 -1
  124. package/dist/themes/components/ColorSchemeToggle.svelte +17 -14
  125. package/dist/themes/components/ThemeSwitcher.svelte +14 -11
  126. package/dist/themes/create-theme.d.ts.map +1 -1
  127. package/dist/themes/create-theme.js +8 -5
  128. package/dist/themes/css-generator.d.ts.map +1 -1
  129. package/dist/themes/css-generator.js +5 -4
  130. package/dist/themes/required-tokens.generated.json +172 -0
  131. package/dist/themes/styles/base.css +4 -1
  132. package/dist/themes/styles/glass.css +4 -1
  133. package/dist/themes/styles/happyvertical.css +7 -3
  134. package/dist/themes/styles/smrt.css +4 -1
  135. package/dist/themes/styles/studio.css +4 -1
  136. package/dist/utils/theme/typography.d.ts +21 -21
  137. package/dist/utils/theme/typography.js +21 -21
  138. package/package.json +8 -2
@@ -1,78 +1,36 @@
1
1
  /**
2
- * SMRT Svelte Design Tokens
3
- * CSS custom properties for consistent theming across components
2
+ * SMRT design tokens: the baseline for the `--smrt-*` vocabulary (issue #3822).
3
+ *
4
+ * Only `--smrt-*` custom properties are defined here, and only the theme-invariant
5
+ * scales (spacing, radius, duration, touch targets). Colours and typography belong
6
+ * to the theme (`themes/styles/*.css`, `css-generator.ts`), so this file never
7
+ * defines a colour that a dark or branded theme would then be overridden by.
8
+ *
9
+ * Values match the default `smrt` theme, so importing this file alone does not
10
+ * change the default look. Component code consumes `--smrt-*` tokens only; see
11
+ * `scripts/check-smrt-token-vocabulary.mjs` for the lint gate.
4
12
  */
5
13
 
6
14
  :root {
7
15
  --smrt-touch-target-min: 48px;
8
16
  --smrt-control-target-min: 0px;
9
- /* Colors - Primary */
10
- --color-primary-main: #1976d2;
11
- --color-primary-light: #e3f2fd;
12
- --color-primary-dark: #1565c0;
13
-
14
- /* Colors - Neutral */
15
- --color-neutral-white: #ffffff;
16
- --color-neutral-gray100: #f5f5f5;
17
- --color-neutral-gray200: #eeeeee;
18
- --color-neutral-gray300: #e0e0e0;
19
- --color-neutral-gray400: #9ca3af;
20
- --color-neutral-black: #000000;
21
-
22
- /* Colors - Text */
23
- --color-text-primary: #212121;
24
- --color-text-secondary: #757575;
25
- --color-text-inverse: #ffffff;
26
-
27
- /* Colors - Semantic */
28
- --color-semantic-error: #f44336;
29
- --color-semantic-success: #4caf50;
30
- --color-semantic-warning: #ff9800;
31
- --color-semantic-info: #2196f3;
32
17
 
33
18
  /* Spacing */
34
- --spacing-xs: 0.25rem;
35
- --spacing-sm: 0.5rem;
36
- --spacing-md: 1rem;
37
- --spacing-lg: 1.5rem;
38
- --spacing-xl: 2rem;
39
- --spacing-2xl: 3rem;
40
- --spacing-3xl: 4rem;
41
-
42
- /* Font Sizes */
43
- --font-size-xs: 0.75rem;
44
- --font-size-sm: 0.875rem;
45
- --font-size-base: 1rem;
46
- --font-size-md: 1rem;
47
- --font-size-lg: 1.125rem;
48
- --font-size-xl: 1.25rem;
49
- --font-size-2xl: 1.5rem;
50
- --font-size-3xl: 2rem;
51
-
52
- /* Font Weights */
53
- --font-weight-normal: 400;
54
- --font-weight-medium: 500;
55
- --font-weight-semibold: 600;
56
- --font-weight-bold: 700;
57
-
58
- /* Border Radius */
59
- --radius-sm: 0.25rem;
60
- --radius-md: 0.5rem;
61
- --radius-lg: 0.75rem;
62
- --radius-xl: 1rem;
63
- --radius-full: 9999px;
64
- --border-radius-sm: 0.25rem;
65
- --border-radius-md: 0.5rem;
66
- --border-radius-lg: 0.75rem;
67
-
68
- /* Shadows */
69
- --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
70
- --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
71
- --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
72
- --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
73
-
74
- /* Transitions */
75
- --transition-base: 150ms cubic-bezier(0.4, 0, 0.2, 1);
76
- --transition-fast: 150ms;
77
- --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
19
+ --smrt-spacing-xs: 0.25rem;
20
+ --smrt-spacing-sm: 0.5rem;
21
+ --smrt-spacing-md: 1rem;
22
+ --smrt-spacing-lg: 1.5rem;
23
+ --smrt-spacing-xl: 2rem;
24
+ --smrt-spacing-2xl: 3rem;
25
+ --smrt-spacing-3xl: 4rem;
26
+
27
+ /* Radius */
28
+ --smrt-radius-sm: 0.25rem;
29
+ --smrt-radius-md: 0.5rem;
30
+ --smrt-radius-lg: 0.75rem;
31
+ --smrt-radius-xl: 1rem;
32
+ --smrt-radius-full: 9999px;
33
+
34
+ /* Motion */
35
+ --smrt-duration-fast: 100ms;
78
36
  }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Styleless mode for smrt components (#3825).
3
+ *
4
+ * import '@happyvertical/smrt-ui/styles/unstyled.css';
5
+ *
6
+ * Components keep their layout (display, flex/grid, gap, padding, position,
7
+ * sizing) and lose their look (colour, background, border, radius, shadow,
8
+ * font, outline, filter). Every rule here lives in a smrt layer, so unlayered
9
+ * consumer CSS still wins, whatever the import order. Restyle with unlayered
10
+ * CSS, the --smrt-* tokens, or the data-smrt-component / data-smrt-part hooks.
11
+ *
12
+ * The reverted property list is explicit on purpose. `all: revert-layer` would
13
+ * also drop layout declarations, because until per-package structure/theme
14
+ * sorting lands every component rule sits in smrt.theme. Keep this list in
15
+ * step with the "Styleless mode" section of agents/styling.md.
16
+ */
17
+ @layer smrt.reset, smrt.structure, smrt.theme;
18
+
19
+ /*
20
+ * Reset: once the look is stripped, text inherits the page typography instead
21
+ * of the browser's serif default, and form controls drop their UA chrome.
22
+ */
23
+ @layer smrt.reset {
24
+ :is([data-smrt-component], [data-smrt-component] *) {
25
+ font: inherit;
26
+ }
27
+
28
+ :is([data-smrt-component], [data-smrt-component] *):is(
29
+ button,
30
+ input,
31
+ select,
32
+ textarea
33
+ ) {
34
+ margin: 0;
35
+ padding: 0;
36
+ border: 0;
37
+ border-radius: 0;
38
+ background: transparent;
39
+ color: inherit;
40
+ font: inherit;
41
+ }
42
+ }
43
+
44
+ /*
45
+ * Revert the look back to smrt.structure (and then the reset). The :not(#\#)
46
+ * x3 boost gives specificity (3,1,0), which beats Svelte's hashed .svelte-*
47
+ * class selectors without !important.
48
+ */
49
+ @layer smrt.theme {
50
+ :is([data-smrt-component], [data-smrt-component] *):not(#\#):not(#\#):not(#\#) {
51
+ background: revert-layer;
52
+ border: revert-layer;
53
+ border-radius: revert-layer;
54
+ box-shadow: revert-layer;
55
+ color: revert-layer;
56
+ font: revert-layer;
57
+ letter-spacing: revert-layer;
58
+ text-decoration: revert-layer;
59
+ text-transform: revert-layer;
60
+ text-shadow: revert-layer;
61
+ outline: revert-layer;
62
+ filter: revert-layer;
63
+ backdrop-filter: revert-layer;
64
+ }
65
+ }
@@ -108,6 +108,8 @@ function handleSubmit() {
108
108
  </div>
109
109
 
110
110
  <style>
111
+ @layer smrt.reset, smrt.structure, smrt.theme;
112
+ @layer smrt.theme {
111
113
  .workbench {
112
114
  display: grid;
113
115
  gap: var(--smrt-spacing-6);
@@ -230,4 +232,5 @@ function handleSubmit() {
230
232
  text-align: left;
231
233
  }
232
234
  }
235
+ }
233
236
  </style>
@@ -109,6 +109,8 @@ const items: CalendarItem[] = [
109
109
  </div>
110
110
 
111
111
  <style>
112
+ @layer smrt.reset, smrt.structure, smrt.theme;
113
+ @layer smrt.theme {
112
114
  .workbench {
113
115
  display: grid;
114
116
  gap: var(--smrt-spacing-4, 1rem);
@@ -123,7 +125,7 @@ const items: CalendarItem[] = [
123
125
 
124
126
  .eyebrow {
125
127
  margin: 0;
126
- color: var(--smrt-color-on-surface-variant, #44474e);
128
+ color: var(--smrt-color-on-surface-variant);
127
129
  font-size: var(--smrt-typography-label-medium-size, 0.75rem);
128
130
  text-transform: uppercase;
129
131
  }
@@ -136,6 +138,7 @@ const items: CalendarItem[] = [
136
138
  .picked {
137
139
  margin: 0;
138
140
  min-height: 1.5rem;
139
- color: var(--smrt-color-on-surface-variant, #44474e);
141
+ color: var(--smrt-color-on-surface-variant);
140
142
  }
143
+ }
141
144
  </style>
@@ -46,6 +46,8 @@ function describeSubmission(
46
46
  </div>
47
47
 
48
48
  <style>
49
+ @layer smrt.reset, smrt.structure, smrt.theme;
50
+ @layer smrt.theme {
49
51
  .workbench { display: grid; gap: var(--smrt-spacing-5); color: var(--smrt-color-on-surface); }
50
52
  header { display: grid; gap: var(--smrt-spacing-2); }
51
53
  h4, p { margin: 0; } h4 { font: var(--smrt-typography-headline-small-font); }
@@ -53,4 +55,5 @@ function describeSubmission(
53
55
  .eyebrow { color: var(--smrt-color-primary); font: var(--smrt-typography-label-small-font); letter-spacing: .1em; text-transform: uppercase; }
54
56
  form { display: grid; gap: var(--smrt-spacing-6); }
55
57
  section { display: grid; gap: var(--smrt-spacing-3); min-width: 0; }
58
+ }
56
59
  </style>
@@ -24,6 +24,9 @@ let submitted = $state('');
24
24
  <output aria-label="Submitted codes">{submitted}</output>
25
25
  </div>
26
26
  <style>
27
+ @layer smrt.reset, smrt.structure, smrt.theme;
28
+ @layer smrt.theme {
27
29
  .selectors { display: grid; gap: 1rem; max-width: 40rem; color: var(--smrt-color-on-surface); }
28
30
  output { overflow-wrap: anywhere; }
31
+ }
29
32
  </style>
@@ -52,8 +52,11 @@ const filtered = $derived(
52
52
  </div>
53
53
 
54
54
  <style>
55
+ @layer smrt.reset, smrt.structure, smrt.theme;
56
+ @layer smrt.theme {
55
57
  .workbench { display: grid; gap: var(--smrt-spacing-4); color: var(--smrt-color-on-surface); }
56
58
  header { padding-bottom: var(--smrt-spacing-4); border-bottom: 1px solid var(--smrt-color-outline-variant); } h4, p { margin: 0; } h4 { font: var(--smrt-typography-headline-small-font); } header > p:last-child { max-width: 48rem; margin-top: var(--smrt-spacing-1); color: var(--smrt-color-on-surface-variant); }
57
59
  .eyebrow { color: var(--smrt-color-primary); font: var(--smrt-typography-label-small-font); letter-spacing: .1em; text-transform: uppercase; }
58
60
  .status { padding: var(--smrt-spacing-1) var(--smrt-spacing-2); border-radius: var(--smrt-radius-full); background: var(--smrt-color-secondary-container); color: var(--smrt-color-on-secondary-container); font: var(--smrt-typography-label-small-font); }
61
+ }
59
62
  </style>
@@ -494,6 +494,8 @@ function selectAllMatching() {
494
494
  </div>
495
495
 
496
496
  <style>
497
+ @layer smrt.reset, smrt.structure, smrt.theme;
498
+ @layer smrt.theme {
497
499
  .workbench {
498
500
  display: grid;
499
501
  gap: var(--smrt-spacing-5);
@@ -634,4 +636,5 @@ function selectAllMatching() {
634
636
  margin-left: 0;
635
637
  }
636
638
  }
639
+ }
637
640
  </style>
@@ -38,6 +38,8 @@ const menu = [
38
38
  </div>
39
39
 
40
40
  <style>
41
+ @layer smrt.reset, smrt.structure, smrt.theme;
42
+ @layer smrt.theme {
41
43
  .workbench { display: grid; gap: var(--smrt-spacing-6); color: var(--smrt-color-on-surface); }
42
44
  header, .actions, .interaction-row { display: flex; align-items: center; gap: var(--smrt-spacing-3); } header { justify-content: space-between; padding-bottom: var(--smrt-spacing-4); border-bottom: 1px solid var(--smrt-color-outline-variant); }
43
45
  h4, h5, p { margin: 0; } h4 { font: var(--smrt-typography-headline-small-font); } h5 { margin-bottom: var(--smrt-spacing-3); font: var(--smrt-typography-title-medium-font); }
@@ -48,4 +50,5 @@ const menu = [
48
50
  .interaction-row { flex-wrap: wrap; align-items: flex-start; margin-bottom: var(--smrt-spacing-3); }
49
51
  .slider { display: grid; max-width: 24rem; gap: var(--smrt-spacing-2); } .slider label { display: flex; justify-content: space-between; } input { accent-color: var(--smrt-color-primary); }
50
52
  @media (max-width: 760px) { header { align-items: flex-start; flex-direction: column; } .progress-grid { grid-template-columns: 1fr; } }
53
+ }
51
54
  </style>
@@ -115,6 +115,8 @@ const identity = (controlId: string) => ({
115
115
  </div>
116
116
 
117
117
  <style>
118
+ @layer smrt.reset, smrt.structure, smrt.theme;
119
+ @layer smrt.theme {
118
120
  .workbench { display: grid; gap: var(--smrt-spacing-5); color: var(--smrt-color-on-surface); }
119
121
  header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--smrt-spacing-5); padding-bottom: var(--smrt-spacing-4); border-bottom: 1px solid var(--smrt-color-outline-variant); }
120
122
  h4, h5, p { margin: 0; } h4 { font: var(--smrt-typography-headline-small-font); } h5 { margin-bottom: var(--smrt-spacing-3); font: var(--smrt-typography-title-medium-font); }
@@ -127,4 +129,5 @@ const identity = (controlId: string) => ({
127
129
  .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--smrt-spacing-5); align-items: start; }
128
130
  .grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
129
131
  @media (max-width: 900px) { header { flex-direction: column; } .agent-actions { justify-content: flex-start; } .grid, .grid.compact { grid-template-columns: 1fr; } }
132
+ }
130
133
  </style>
@@ -0,0 +1,110 @@
1
+ <script lang="ts">
2
+ import Alert from '../../components/feedback/Alert.svelte';
3
+ import Input from '../../components/forms/Input.svelte';
4
+ import Select from '../../components/forms/Select.svelte';
5
+ import Tabs from '../../components/nav/Tabs.svelte';
6
+ import Badge from '../../components/ui/Badge.svelte';
7
+ import Button from '../../components/ui/Button.svelte';
8
+ import Card from '../../components/ui/Card.svelte';
9
+ import Chip from '../../components/ui/Chip.svelte';
10
+ import unstyledCss from '../../styles/unstyled.css?inline';
11
+
12
+ // Native checkbox, outside the catalogue, so the toggle itself is never stripped.
13
+ let styleless = $state(false);
14
+ let active = $state('overview');
15
+
16
+ // Svelte does not interpolate text inside a style element, so the stylesheet is
17
+ // appended to the document head imperatively while the toggle is on.
18
+ $effect(() => {
19
+ if (!styleless) return;
20
+ const style = document.createElement('style');
21
+ style.setAttribute('data-smrt-styleless', '');
22
+ style.textContent = unstyledCss;
23
+ document.head.appendChild(style);
24
+ return () => style.remove();
25
+ });
26
+ const tabs = [
27
+ { id: 'overview', label: 'Overview' },
28
+ { id: 'activity', label: 'Activity' },
29
+ { id: 'settings', label: 'Settings' },
30
+ ];
31
+ </script>
32
+
33
+
34
+
35
+ <div class="workbench">
36
+ <header>
37
+ <div>
38
+ <p class="eyebrow">Styleless mode</p>
39
+ <h4>Layout kept, look removed</h4>
40
+ </div>
41
+ <label class="toggle">
42
+ <input type="checkbox" bind:checked={styleless} />
43
+ Apply unstyled.css
44
+ </label>
45
+ </header>
46
+
47
+ <p class="note">
48
+ With the toggle on, every component below keeps its layout and loses its
49
+ themed look. The page chrome is not a smrt component, so it is unaffected.
50
+ </p>
51
+
52
+ <div class="catalogue">
53
+ <section>
54
+ <h5>Buttons and badges</h5>
55
+ <div class="row">
56
+ <Button>Primary</Button>
57
+ <Button variant="secondary">Secondary</Button>
58
+ <Badge>Draft</Badge>
59
+ <Chip label="Filter" />
60
+ </div>
61
+ </section>
62
+
63
+ <section>
64
+ <h5>Card</h5>
65
+ <Card>
66
+ {#snippet header()}<strong>Workspace</strong>{/snippet}
67
+ <p>Card body text keeps its spacing and flow.</p>
68
+ {#snippet footer()}<Button size="sm">Open</Button>{/snippet}
69
+ </Card>
70
+ </section>
71
+
72
+ <section>
73
+ <h5>Alert</h5>
74
+ <Alert title="Information">The index refreshes in the background.</Alert>
75
+ </section>
76
+
77
+ <section>
78
+ <h5>Form controls</h5>
79
+ <div class="row">
80
+ <Input name="styleless-name" placeholder="Name" />
81
+ <Select name="styleless-role">
82
+ <option value="owner">Owner</option>
83
+ <option value="member">Member</option>
84
+ </Select>
85
+ </div>
86
+ </section>
87
+
88
+ <section>
89
+ <h5>Tabs</h5>
90
+ <Tabs {tabs} {active} onchange={(id) => (active = id)} />
91
+ </section>
92
+ </div>
93
+ </div>
94
+
95
+ <style>
96
+ @layer smrt.reset, smrt.structure, smrt.theme;
97
+ @layer smrt.theme {
98
+ .workbench { display: grid; gap: var(--smrt-spacing-6); color: var(--smrt-color-on-surface); }
99
+ header { display: flex; align-items: center; justify-content: space-between; gap: var(--smrt-spacing-3); padding-bottom: var(--smrt-spacing-4); border-bottom: 1px solid var(--smrt-color-outline-variant); }
100
+ h4, h5, p { margin: 0; }
101
+ h4 { font: var(--smrt-typography-headline-small-font); }
102
+ h5 { margin-bottom: var(--smrt-spacing-3); font: var(--smrt-typography-title-medium-font); }
103
+ .eyebrow { color: var(--smrt-color-primary); font: var(--smrt-typography-label-small-font); letter-spacing: .1em; text-transform: uppercase; }
104
+ .note { color: var(--smrt-color-on-surface-variant); font: var(--smrt-typography-body-medium-font); }
105
+ .toggle { display: inline-flex; align-items: center; gap: var(--smrt-spacing-2); }
106
+ .catalogue { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--smrt-spacing-5); }
107
+ .catalogue > section { display: grid; align-content: start; gap: var(--smrt-spacing-2); }
108
+ .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--smrt-spacing-3); }
109
+ }
110
+ </style>
@@ -0,0 +1,4 @@
1
+ declare const StylelessPreview: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type StylelessPreview = ReturnType<typeof StylelessPreview>;
3
+ export default StylelessPreview;
4
+ //# sourceMappingURL=StylelessPreview.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StylelessPreview.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/playground/StylelessPreview.svelte.ts"],"names":[],"mappings":"AA+GA,QAAA,MAAM,gBAAgB,2DAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../src/svelte/playground.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wBAyGE"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../src/svelte/playground.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,wBAmHE"}
@@ -6,6 +6,7 @@ const loadCollections = () => import('./playground/CollectionsPreview.svelte');
6
6
  const loadCalendar = () => import('./playground/CalendarPreview.svelte');
7
7
  const loadCapture = () => import('./playground/CapturePreview.svelte');
8
8
  const loadPermissionPicker = () => import('./playground/PermissionPickerPreview.svelte');
9
+ const loadStyleless = () => import('./playground/StylelessPreview.svelte');
9
10
  export default {
10
11
  packageName: '@happyvertical/smrt-ui',
11
12
  displayName: 'UI Foundation',
@@ -100,5 +101,14 @@ export default {
100
101
  tags: ['forms', 'camera', 'signature', 'files'],
101
102
  modes: { mock: { label: 'Interactive' } },
102
103
  },
104
+ {
105
+ id: 'styleless-mode',
106
+ title: 'Styleless Mode',
107
+ description: 'Toggle unstyled.css across the catalogue: components keep layout and drop their themed look, so consumer CSS can restyle them.',
108
+ loadComponent: loadStyleless,
109
+ order: 10,
110
+ tags: ['styling', 'styleless', 'layers', 'restyling'],
111
+ modes: { mock: { label: 'Interactive' } },
112
+ },
103
113
  ],
104
114
  };
@@ -40,3 +40,12 @@ if (typeof HTMLDialogElement !== 'undefined') {
40
40
  };
41
41
  }
42
42
  }
43
+ // jsdom has no Web Animations API. Svelte's `animate:` directive (list FLIP)
44
+ // and transitions call `element.getAnimations()`; an empty list is accurate
45
+ // here because jsdom never runs CSS animations.
46
+ if (typeof Element !== 'undefined' &&
47
+ typeof Element.prototype.getAnimations !== 'function') {
48
+ Element.prototype.getAnimations = function getAnimations() {
49
+ return [];
50
+ };
51
+ }
@@ -200,8 +200,11 @@ $effect(() => {
200
200
  </div>
201
201
 
202
202
  <style>
203
+ @layer smrt.reset, smrt.structure, smrt.theme;
204
+ @layer smrt.theme {
203
205
  .smrt-theme-root {
204
206
  /* Ensure theme variables cascade to all children */
205
207
  display: contents;
206
208
  }
209
+ }
207
210
  </style>
@@ -318,6 +318,31 @@ npm install ./packages/my-brand-theme
318
318
  <ThemeSwitcher variant="segmented" />
319
319
  ```
320
320
 
321
+ ## Required Tokens
322
+
323
+ A theme is complete only when it defines every token the components consume. The list below is generated from the `var(--smrt-*)` references in the packages' `.svelte` files; `src/themes/__tests__/required-tokens.test.ts` asserts every preset and `createTheme()` output defines each one.
324
+
325
+ <!-- smrt-required-tokens:start -->
326
+
327
+ ### Required tokens (generated)
328
+
329
+ Every theme (presets and `createTheme()` output) must define these names. Generated by
330
+ `scripts/generate-smrt-required-tokens.mjs`; do not edit by hand. Component-private
331
+ `--smrt-<component>-*` knobs are excluded.
332
+
333
+ - **color** (40): `--smrt-color-background`, `--smrt-color-error`, `--smrt-color-error-container`, `--smrt-color-inverse-on-surface`, `--smrt-color-inverse-surface`, `--smrt-color-on-background`, `--smrt-color-on-error`, `--smrt-color-on-error-container`, `--smrt-color-on-primary`, `--smrt-color-on-primary-container`, `--smrt-color-on-secondary`, `--smrt-color-on-secondary-container`, `--smrt-color-on-success-container`, `--smrt-color-on-surface`, `--smrt-color-on-surface-variant`, `--smrt-color-on-tertiary`, `--smrt-color-on-tertiary-container`, `--smrt-color-on-warning-container`, `--smrt-color-outline`, `--smrt-color-outline-variant`, `--smrt-color-primary`, `--smrt-color-primary-container`, `--smrt-color-scrim`, `--smrt-color-secondary`, `--smrt-color-secondary-container`, `--smrt-color-shadow`, `--smrt-color-success`, `--smrt-color-success-container`, `--smrt-color-surface`, `--smrt-color-surface-container`, `--smrt-color-surface-container-high`, `--smrt-color-surface-container-highest`, `--smrt-color-surface-container-low`, `--smrt-color-surface-container-lowest`, `--smrt-color-surface-dim`, `--smrt-color-surface-variant`, `--smrt-color-tertiary`, `--smrt-color-tertiary-container`, `--smrt-color-warning`, `--smrt-color-warning-container`
334
+ - **duration** (6): `--smrt-duration-fast`, `--smrt-duration-medium1`, `--smrt-duration-normal`, `--smrt-duration-short2`, `--smrt-duration-short3`, `--smrt-duration-short4`
335
+ - **easing** (3): `--smrt-easing-emphasized`, `--smrt-easing-emphasized-decelerate`, `--smrt-easing-standard`
336
+ - **elevation** (5): `--smrt-elevation-1`, `--smrt-elevation-2`, `--smrt-elevation-3`, `--smrt-elevation-4`, `--smrt-elevation-5`
337
+ - **font** (2): `--smrt-font-family`, `--smrt-font-family-mono`
338
+ - **radius** (11): `--smrt-radius-2xl`, `--smrt-radius-extra-large`, `--smrt-radius-extra-small`, `--smrt-radius-full`, `--smrt-radius-large`, `--smrt-radius-lg`, `--smrt-radius-md`, `--smrt-radius-medium`, `--smrt-radius-sm`, `--smrt-radius-small`, `--smrt-radius-xl`
339
+ - **spacing** (19): `--smrt-spacing-0_5`, `--smrt-spacing-1`, `--smrt-spacing-10`, `--smrt-spacing-11`, `--smrt-spacing-12`, `--smrt-spacing-1_5`, `--smrt-spacing-2`, `--smrt-spacing-2xl`, `--smrt-spacing-3`, `--smrt-spacing-3xl`, `--smrt-spacing-4`, `--smrt-spacing-5`, `--smrt-spacing-6`, `--smrt-spacing-8`, `--smrt-spacing-lg`, `--smrt-spacing-md`, `--smrt-spacing-sm`, `--smrt-spacing-xl`, `--smrt-spacing-xs`
340
+ - **touch** (1): `--smrt-touch-target-min`
341
+ - **typography** (56): `--smrt-typography-body-large-font`, `--smrt-typography-body-large-line-height`, `--smrt-typography-body-large-size`, `--smrt-typography-body-large-tracking`, `--smrt-typography-body-medium-font`, `--smrt-typography-body-medium-line-height`, `--smrt-typography-body-medium-size`, `--smrt-typography-body-medium-tracking`, `--smrt-typography-body-medium-weight`, `--smrt-typography-body-small-font`, `--smrt-typography-body-small-line-height`, `--smrt-typography-body-small-size`, `--smrt-typography-body-small-weight`, `--smrt-typography-display-medium-line-height`, `--smrt-typography-display-medium-size`, `--smrt-typography-display-small-size`, `--smrt-typography-headline-large-line-height`, `--smrt-typography-headline-large-size`, `--smrt-typography-headline-large-weight`, `--smrt-typography-headline-medium-line-height`, `--smrt-typography-headline-medium-size`, `--smrt-typography-headline-medium-weight`, `--smrt-typography-headline-small-font`, `--smrt-typography-headline-small-line-height`, `--smrt-typography-headline-small-size`, `--smrt-typography-headline-small-weight`, `--smrt-typography-label-large-font`, `--smrt-typography-label-large-size`, `--smrt-typography-label-large-tracking`, `--smrt-typography-label-large-weight`, `--smrt-typography-label-medium-font`, `--smrt-typography-label-medium-size`, `--smrt-typography-label-medium-tracking`, `--smrt-typography-label-medium-weight`, `--smrt-typography-label-small-font`, `--smrt-typography-label-small-line-height`, `--smrt-typography-label-small-size`, `--smrt-typography-label-small-tracking`, `--smrt-typography-label-small-weight`, `--smrt-typography-title-large-font`, `--smrt-typography-title-large-line-height`, `--smrt-typography-title-large-size`, `--smrt-typography-title-medium-font`, `--smrt-typography-title-medium-font-family`, `--smrt-typography-title-medium-line-height`, `--smrt-typography-title-medium-size`, `--smrt-typography-title-medium-tracking`, `--smrt-typography-title-medium-weight`, `--smrt-typography-title-small-font`, `--smrt-typography-title-small-size`, `--smrt-typography-title-small-tracking`, `--smrt-typography-title-small-weight`, `--smrt-typography-weight-bold`, `--smrt-typography-weight-medium`, `--smrt-typography-weight-normal`, `--smrt-typography-weight-semibold`
342
+ - **z** (7): `--smrt-z-index-dialog`, `--smrt-z-index-dropdown`, `--smrt-z-index-modal`, `--smrt-z-index-overlay`, `--smrt-z-index-sticky`, `--smrt-z-index-toast`, `--smrt-z-index-tooltip`
343
+
344
+ <!-- smrt-required-tokens:end -->
345
+
321
346
  ## Best Practices
322
347
 
323
348
  1. **Extend a base theme**: Start with `extend: 'material'` or another base to get sensible defaults
@@ -74,6 +74,9 @@ const autoTheme = createThemeFromColor('#6366f1', 'indigo', 'Indigo Theme');
74
74
  registerTheme(autoTheme);
75
75
  ```
76
76
 
77
+ Generated dark themes use tonal primary colors so primary text and icon
78
+ containers remain readable even when the brand seed is very dark.
79
+
77
80
  ### Full Custom Theme with All Options
78
81
 
79
82
  ```typescript
@@ -605,6 +608,28 @@ All themes expose CSS custom properties:
605
608
  --smrt-easing-standard
606
609
  ```
607
610
 
611
+ ### One vocabulary: `--smrt-*` only
612
+
613
+ `--smrt-*` is the only token namespace. Component CSS consumes these tokens and
614
+ nothing else; the legacy `--color-*`, `--spacing-*`, `--radius-*`, `--md-sys-*`
615
+ families were removed (issue #3822). Three rules follow:
616
+
617
+ - **Consume a token, don't invent one.** Use `var(--smrt-color-primary)` etc. Hard
618
+ colour or spacing literals belong in a theme, not a component.
619
+ - **A component-private variable is `--smrt-<component>-<name>`**, declared on the
620
+ component root (for example `--smrt-toast-viewport-inset`). A parent or app may set
621
+ it. It is not a theme token and should not be read from outside the component.
622
+ - **Overrides go through a theme or a documented hook**, never a `:global` rule or
623
+ `!important`. Unlayered app CSS still wins over the component's own styles.
624
+
625
+ `packages/smrt-ui/src/styles/tokens.css` defines the theme-invariant baseline only
626
+ (spacing, radius, duration, touch targets). Colour and typography come from a theme.
627
+
628
+ The lint gate `scripts/check-smrt-token-vocabulary.mjs` runs in `pnpm lint` and fails
629
+ on any custom property outside `--smrt-*` in `packages/*/src`. The one-time rewrite
630
+ was `scripts/codemod-smrt-tokens.mjs`; it is idempotent, so re-run it after a rebase
631
+ instead of hand-merging renamed names.
632
+
608
633
  ## Advanced Usage
609
634
 
610
635
  ### Build-Time Theming
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import { onMount, untrack } from 'svelte';
4
+ import { SMRT_CASCADE_LAYERS_CSS } from '../styles/layers.js';
4
5
  import { setThemeContext, type ThemeContext } from './context.svelte.js';
5
6
  import { generateThemeVariables } from './css-generator.js';
6
7
  import { availablePresets, getTheme, isValidPreset } from './registry.js';
@@ -130,7 +131,7 @@ const styleString = $derived.by(() => {
130
131
 
131
132
  if (density !== undefined) {
132
133
  declarations.push(
133
- `--smrt-control-target-min: ${density === 'touch' ? 'var(--smrt-touch-target-min, 48px)' : '0px'}`,
134
+ `--smrt-control-target-min: ${density === 'touch' ? 'var(--smrt-touch-target-min)' : '0px'}`,
134
135
  );
135
136
  }
136
137
 
@@ -341,6 +342,11 @@ $effect(() => {
341
342
  });
342
343
  </script>
343
344
 
345
+ <svelte:head>
346
+ <!-- Declares the smrt cascade layer order before any layered component rule (#3823). -->
347
+ <svelte:element this={'style'} id="smrt-cascade-layers">{SMRT_CASCADE_LAYERS_CSS}</svelte:element>
348
+ </svelte:head>
349
+
344
350
  <div
345
351
  class="smrt-theme-root"
346
352
  class:dark={isDark}
@@ -348,12 +354,14 @@ $effect(() => {
348
354
  class:smrt-theme-glass={config.preset === 'glass'}
349
355
  style={styleString || undefined}
350
356
  data-theme={config.preset}
351
- data-color-scheme={resolvedScheme}
357
+ data-color-scheme={resolvedScheme} data-smrt-component="ThemeProvider"
352
358
  >
353
359
  {@render children()}
354
360
  </div>
355
361
 
356
362
  <style>
363
+ @layer smrt.reset, smrt.structure, smrt.theme;
364
+ @layer smrt.theme {
357
365
  .smrt-theme-root {
358
366
  /* Ensure theme variables cascade properly */
359
367
  /* Note: Using block display instead of contents so styles apply correctly */
@@ -385,4 +393,5 @@ $effect(() => {
385
393
  outline: 2px solid var(--smrt-color-primary);
386
394
  outline-offset: 2px;
387
395
  }
396
+ }
388
397
  </style>
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/themes/ThemeProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKtC,OAAO,KAAK,EACV,WAAW,EAEX,WAAW,EACX,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,UAAU,KAAK;IACb,wFAAwF;IACxF,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IAClC,0BAA0B;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAC3C,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB;AAsTD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/themes/ThemeProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAMtC,OAAO,KAAK,EACV,WAAW,EAEX,WAAW,EACX,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,UAAU,KAAK;IACb,wFAAwF;IACxF,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IAClC,0BAA0B;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAC3C,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB;AA4TD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}