@dillingerstaffing/strand-ui 0.1.0 → 0.2.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 (261) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/Alert/Alert.d.ts +16 -0
  3. package/dist/components/Alert/Alert.d.ts.map +1 -0
  4. package/dist/components/Alert/index.d.ts +3 -0
  5. package/dist/components/Alert/index.d.ts.map +1 -0
  6. package/dist/components/Avatar/Avatar.d.ts +16 -0
  7. package/dist/components/Avatar/Avatar.d.ts.map +1 -0
  8. package/dist/components/Avatar/index.d.ts +3 -0
  9. package/dist/components/Avatar/index.d.ts.map +1 -0
  10. package/dist/components/Badge/Badge.d.ts +18 -0
  11. package/dist/components/Badge/Badge.d.ts.map +1 -0
  12. package/dist/components/Badge/index.d.ts +3 -0
  13. package/dist/components/Badge/index.d.ts.map +1 -0
  14. package/dist/components/Breadcrumb/Breadcrumb.d.ts +16 -0
  15. package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
  16. package/dist/components/Breadcrumb/index.d.ts +3 -0
  17. package/dist/components/Breadcrumb/index.d.ts.map +1 -0
  18. package/dist/components/Button/Button.d.ts +22 -0
  19. package/dist/components/Button/Button.d.ts.map +1 -0
  20. package/dist/components/Button/index.d.ts +3 -0
  21. package/dist/components/Button/index.d.ts.map +1 -0
  22. package/dist/components/Card/Card.d.ts +12 -0
  23. package/dist/components/Card/Card.d.ts.map +1 -0
  24. package/dist/components/Card/index.d.ts +3 -0
  25. package/dist/components/Card/index.d.ts.map +1 -0
  26. package/dist/components/Checkbox/Checkbox.d.ts +20 -0
  27. package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
  28. package/dist/components/Checkbox/index.d.ts +3 -0
  29. package/dist/components/Checkbox/index.d.ts.map +1 -0
  30. package/dist/components/Container/Container.d.ts +10 -0
  31. package/dist/components/Container/Container.d.ts.map +1 -0
  32. package/dist/components/Container/index.d.ts +3 -0
  33. package/dist/components/Container/index.d.ts.map +1 -0
  34. package/dist/components/DataReadout/DataReadout.d.ts +12 -0
  35. package/dist/components/DataReadout/DataReadout.d.ts.map +1 -0
  36. package/dist/components/DataReadout/index.d.ts +3 -0
  37. package/dist/components/DataReadout/index.d.ts.map +1 -0
  38. package/dist/components/Dialog/Dialog.d.ts +20 -0
  39. package/dist/components/Dialog/Dialog.d.ts.map +1 -0
  40. package/dist/components/Dialog/index.d.ts +3 -0
  41. package/dist/components/Dialog/index.d.ts.map +1 -0
  42. package/dist/components/Divider/Divider.d.ts +13 -0
  43. package/dist/components/Divider/Divider.d.ts.map +1 -0
  44. package/dist/components/Divider/index.d.ts +3 -0
  45. package/dist/components/Divider/index.d.ts.map +1 -0
  46. package/dist/components/FormField/FormField.d.ts +22 -0
  47. package/dist/components/FormField/FormField.d.ts.map +1 -0
  48. package/dist/components/FormField/index.d.ts +3 -0
  49. package/dist/components/FormField/index.d.ts.map +1 -0
  50. package/dist/components/Grid/Grid.d.ts +12 -0
  51. package/dist/components/Grid/Grid.d.ts.map +1 -0
  52. package/dist/components/Grid/index.d.ts +3 -0
  53. package/dist/components/Grid/index.d.ts.map +1 -0
  54. package/dist/components/Input/Input.d.ts +18 -0
  55. package/dist/components/Input/Input.d.ts.map +1 -0
  56. package/dist/components/Input/index.d.ts +3 -0
  57. package/dist/components/Input/index.d.ts.map +1 -0
  58. package/dist/components/Link/Link.d.ts +12 -0
  59. package/dist/components/Link/Link.d.ts.map +1 -0
  60. package/dist/components/Link/index.d.ts +3 -0
  61. package/dist/components/Link/index.d.ts.map +1 -0
  62. package/dist/components/Nav/Nav.d.ts +19 -0
  63. package/dist/components/Nav/Nav.d.ts.map +1 -0
  64. package/dist/components/Nav/index.d.ts +3 -0
  65. package/dist/components/Nav/index.d.ts.map +1 -0
  66. package/dist/components/Progress/Progress.d.ts +14 -0
  67. package/dist/components/Progress/Progress.d.ts.map +1 -0
  68. package/dist/components/Progress/index.d.ts +3 -0
  69. package/dist/components/Progress/index.d.ts.map +1 -0
  70. package/dist/components/Radio/Radio.d.ts +22 -0
  71. package/dist/components/Radio/Radio.d.ts.map +1 -0
  72. package/dist/components/Radio/index.d.ts +3 -0
  73. package/dist/components/Radio/index.d.ts.map +1 -0
  74. package/dist/components/Section/Section.d.ts +12 -0
  75. package/dist/components/Section/Section.d.ts.map +1 -0
  76. package/dist/components/Section/index.d.ts +3 -0
  77. package/dist/components/Section/index.d.ts.map +1 -0
  78. package/dist/components/Select/Select.d.ts +24 -0
  79. package/dist/components/Select/Select.d.ts.map +1 -0
  80. package/dist/components/Select/index.d.ts +3 -0
  81. package/dist/components/Select/index.d.ts.map +1 -0
  82. package/dist/components/Skeleton/Skeleton.d.ts +14 -0
  83. package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
  84. package/dist/components/Skeleton/index.d.ts +3 -0
  85. package/dist/components/Skeleton/index.d.ts.map +1 -0
  86. package/dist/components/Slider/Slider.d.ts +20 -0
  87. package/dist/components/Slider/Slider.d.ts.map +1 -0
  88. package/dist/components/Slider/index.d.ts +3 -0
  89. package/dist/components/Slider/index.d.ts.map +1 -0
  90. package/dist/components/Spinner/Spinner.d.ts +10 -0
  91. package/dist/components/Spinner/Spinner.d.ts.map +1 -0
  92. package/dist/components/Spinner/index.d.ts +3 -0
  93. package/dist/components/Spinner/index.d.ts.map +1 -0
  94. package/dist/components/Stack/Stack.d.ts +18 -0
  95. package/dist/components/Stack/Stack.d.ts.map +1 -0
  96. package/dist/components/Stack/index.d.ts +3 -0
  97. package/dist/components/Stack/index.d.ts.map +1 -0
  98. package/dist/components/Switch/Switch.d.ts +18 -0
  99. package/dist/components/Switch/Switch.d.ts.map +1 -0
  100. package/dist/components/Switch/index.d.ts +3 -0
  101. package/dist/components/Switch/index.d.ts.map +1 -0
  102. package/dist/components/Table/Table.d.ts +24 -0
  103. package/dist/components/Table/Table.d.ts.map +1 -0
  104. package/dist/components/Table/index.d.ts +3 -0
  105. package/dist/components/Table/index.d.ts.map +1 -0
  106. package/dist/components/Tabs/Tabs.d.ts +19 -0
  107. package/dist/components/Tabs/Tabs.d.ts.map +1 -0
  108. package/dist/components/Tabs/index.d.ts +3 -0
  109. package/dist/components/Tabs/index.d.ts.map +1 -0
  110. package/dist/components/Tag/Tag.d.ts +18 -0
  111. package/dist/components/Tag/Tag.d.ts.map +1 -0
  112. package/dist/components/Tag/index.d.ts +3 -0
  113. package/dist/components/Tag/index.d.ts.map +1 -0
  114. package/dist/components/Textarea/Textarea.d.ts +22 -0
  115. package/dist/components/Textarea/Textarea.d.ts.map +1 -0
  116. package/dist/components/Textarea/index.d.ts +3 -0
  117. package/dist/components/Textarea/index.d.ts.map +1 -0
  118. package/dist/components/Toast/Toast.d.ts +33 -0
  119. package/dist/components/Toast/Toast.d.ts.map +1 -0
  120. package/dist/components/Toast/index.d.ts +3 -0
  121. package/dist/components/Toast/index.d.ts.map +1 -0
  122. package/dist/components/Tooltip/Tooltip.d.ts +16 -0
  123. package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
  124. package/dist/components/Tooltip/index.d.ts +3 -0
  125. package/dist/components/Tooltip/index.d.ts.map +1 -0
  126. package/dist/css/strand-ui.css +2464 -0
  127. package/dist/index.d.ts +64 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/test-setup.d.ts +2 -0
  130. package/dist/test-setup.d.ts.map +1 -0
  131. package/package.json +25 -11
  132. package/src/__tests__/build-output.test.ts +200 -0
  133. package/src/__tests__/design-language.test.ts +137 -0
  134. package/src/__tests__/static.test.tsx +60 -0
  135. package/src/components/Alert/Alert.css +75 -0
  136. package/src/components/Alert/Alert.test.tsx +92 -0
  137. package/src/components/Alert/Alert.tsx +59 -0
  138. package/src/components/Alert/index.ts +2 -0
  139. package/src/components/Avatar/Avatar.css +55 -0
  140. package/src/components/Avatar/Avatar.test.tsx +123 -0
  141. package/src/components/Avatar/Avatar.tsx +67 -0
  142. package/src/components/Avatar/index.ts +2 -0
  143. package/src/components/Badge/Badge.css +72 -0
  144. package/src/components/Badge/Badge.test.tsx +121 -0
  145. package/src/components/Badge/Badge.tsx +92 -0
  146. package/src/components/Badge/index.ts +2 -0
  147. package/src/components/Breadcrumb/Breadcrumb.css +50 -0
  148. package/src/components/Breadcrumb/Breadcrumb.test.tsx +107 -0
  149. package/src/components/Breadcrumb/Breadcrumb.tsx +59 -0
  150. package/src/components/Breadcrumb/index.ts +2 -0
  151. package/src/components/Button/Button.css +195 -0
  152. package/src/components/Button/Button.test.tsx +171 -0
  153. package/src/components/Button/Button.tsx +78 -0
  154. package/src/components/Button/index.ts +2 -0
  155. package/src/components/Card/Card.css +68 -0
  156. package/src/components/Card/Card.test.tsx +90 -0
  157. package/src/components/Card/Card.tsx +41 -0
  158. package/src/components/Card/index.ts +2 -0
  159. package/src/components/Checkbox/Checkbox.css +97 -0
  160. package/src/components/Checkbox/Checkbox.test.tsx +92 -0
  161. package/src/components/Checkbox/Checkbox.tsx +137 -0
  162. package/src/components/Checkbox/index.ts +2 -0
  163. package/src/components/Container/Container.css +25 -0
  164. package/src/components/Container/Container.test.tsx +82 -0
  165. package/src/components/Container/Container.tsx +37 -0
  166. package/src/components/Container/index.ts +2 -0
  167. package/src/components/DataReadout/DataReadout.css +30 -0
  168. package/src/components/DataReadout/DataReadout.test.tsx +105 -0
  169. package/src/components/DataReadout/DataReadout.tsx +29 -0
  170. package/src/components/DataReadout/index.ts +2 -0
  171. package/src/components/Dialog/Dialog.css +81 -0
  172. package/src/components/Dialog/Dialog.test.tsx +203 -0
  173. package/src/components/Dialog/Dialog.tsx +179 -0
  174. package/src/components/Dialog/index.ts +2 -0
  175. package/src/components/Divider/Divider.css +44 -0
  176. package/src/components/Divider/Divider.test.tsx +86 -0
  177. package/src/components/Divider/Divider.tsx +81 -0
  178. package/src/components/Divider/index.ts +2 -0
  179. package/src/components/FormField/FormField.css +47 -0
  180. package/src/components/FormField/FormField.test.tsx +99 -0
  181. package/src/components/FormField/FormField.tsx +79 -0
  182. package/src/components/FormField/index.ts +2 -0
  183. package/src/components/Grid/Grid.css +27 -0
  184. package/src/components/Grid/Grid.test.tsx +86 -0
  185. package/src/components/Grid/Grid.tsx +45 -0
  186. package/src/components/Grid/index.ts +2 -0
  187. package/src/components/Input/Input.css +87 -0
  188. package/src/components/Input/Input.test.tsx +95 -0
  189. package/src/components/Input/Input.tsx +69 -0
  190. package/src/components/Input/index.ts +2 -0
  191. package/src/components/Link/Link.css +30 -0
  192. package/src/components/Link/Link.test.tsx +88 -0
  193. package/src/components/Link/Link.tsx +31 -0
  194. package/src/components/Link/index.ts +2 -0
  195. package/src/components/Nav/Nav.css +179 -0
  196. package/src/components/Nav/Nav.test.tsx +174 -0
  197. package/src/components/Nav/Nav.tsx +101 -0
  198. package/src/components/Nav/index.ts +2 -0
  199. package/src/components/Progress/Progress.css +93 -0
  200. package/src/components/Progress/Progress.test.tsx +93 -0
  201. package/src/components/Progress/Progress.tsx +104 -0
  202. package/src/components/Progress/index.ts +2 -0
  203. package/src/components/Radio/Radio.css +98 -0
  204. package/src/components/Radio/Radio.test.tsx +80 -0
  205. package/src/components/Radio/Radio.tsx +72 -0
  206. package/src/components/Radio/index.ts +2 -0
  207. package/src/components/Section/Section.css +28 -0
  208. package/src/components/Section/Section.test.tsx +100 -0
  209. package/src/components/Section/Section.tsx +41 -0
  210. package/src/components/Section/index.ts +2 -0
  211. package/src/components/Select/Select.css +75 -0
  212. package/src/components/Select/Select.test.tsx +99 -0
  213. package/src/components/Select/Select.tsx +78 -0
  214. package/src/components/Select/index.ts +2 -0
  215. package/src/components/Skeleton/Skeleton.css +52 -0
  216. package/src/components/Skeleton/Skeleton.test.tsx +96 -0
  217. package/src/components/Skeleton/Skeleton.tsx +55 -0
  218. package/src/components/Skeleton/index.ts +2 -0
  219. package/src/components/Slider/Slider.css +107 -0
  220. package/src/components/Slider/Slider.test.tsx +85 -0
  221. package/src/components/Slider/Slider.tsx +66 -0
  222. package/src/components/Slider/index.ts +2 -0
  223. package/src/components/Spinner/Spinner.css +61 -0
  224. package/src/components/Spinner/Spinner.test.tsx +56 -0
  225. package/src/components/Spinner/Spinner.tsx +38 -0
  226. package/src/components/Spinner/index.ts +2 -0
  227. package/src/components/Stack/Stack.css +71 -0
  228. package/src/components/Stack/Stack.test.tsx +130 -0
  229. package/src/components/Stack/Stack.tsx +77 -0
  230. package/src/components/Stack/index.ts +2 -0
  231. package/src/components/Switch/Switch.css +94 -0
  232. package/src/components/Switch/Switch.test.tsx +98 -0
  233. package/src/components/Switch/Switch.tsx +80 -0
  234. package/src/components/Switch/index.ts +2 -0
  235. package/src/components/Table/Table.css +83 -0
  236. package/src/components/Table/Table.test.tsx +134 -0
  237. package/src/components/Table/Table.tsx +102 -0
  238. package/src/components/Table/index.ts +2 -0
  239. package/src/components/Tabs/Tabs.css +51 -0
  240. package/src/components/Tabs/Tabs.test.tsx +164 -0
  241. package/src/components/Tabs/Tabs.tsx +126 -0
  242. package/src/components/Tabs/index.ts +2 -0
  243. package/src/components/Tag/Tag.css +98 -0
  244. package/src/components/Tag/Tag.test.tsx +112 -0
  245. package/src/components/Tag/Tag.tsx +73 -0
  246. package/src/components/Tag/index.ts +2 -0
  247. package/src/components/Textarea/Textarea.css +80 -0
  248. package/src/components/Textarea/Textarea.test.tsx +89 -0
  249. package/src/components/Textarea/Textarea.tsx +102 -0
  250. package/src/components/Textarea/index.ts +2 -0
  251. package/src/components/Toast/Toast.css +103 -0
  252. package/src/components/Toast/Toast.test.tsx +219 -0
  253. package/src/components/Toast/Toast.tsx +177 -0
  254. package/src/components/Toast/index.ts +2 -0
  255. package/src/components/Tooltip/Tooltip.css +63 -0
  256. package/src/components/Tooltip/Tooltip.test.tsx +196 -0
  257. package/src/components/Tooltip/Tooltip.tsx +89 -0
  258. package/src/components/Tooltip/index.ts +2 -0
  259. package/src/index.ts +99 -0
  260. package/src/static.css +47 -0
  261. package/src/test-setup.ts +7 -0
@@ -0,0 +1,50 @@
1
+ /*! Strand UI | MIT License | dillingerstaffing.com */
2
+
3
+ .strand-breadcrumb__list {
4
+ display: flex;
5
+ align-items: center;
6
+ gap: var(--strand-space-2);
7
+ list-style: none;
8
+ margin: 0;
9
+ padding: 0;
10
+ font-family: var(--strand-font-sans);
11
+ font-size: var(--strand-text-sm);
12
+ }
13
+
14
+ .strand-breadcrumb__item {
15
+ display: inline-flex;
16
+ align-items: center;
17
+ gap: var(--strand-space-2);
18
+ }
19
+
20
+ .strand-breadcrumb__separator {
21
+ color: var(--strand-gray-400);
22
+ user-select: none;
23
+ }
24
+
25
+ .strand-breadcrumb__link {
26
+ color: var(--strand-gray-500);
27
+ text-decoration: none;
28
+ transition: color var(--strand-duration-fast) var(--strand-ease-out-quart);
29
+ }
30
+
31
+ .strand-breadcrumb__link:hover {
32
+ color: var(--strand-gray-600);
33
+ }
34
+
35
+ .strand-breadcrumb__link:focus-visible {
36
+ outline: 2px solid var(--strand-blue-primary);
37
+ outline-offset: 2px;
38
+ }
39
+
40
+ .strand-breadcrumb__current {
41
+ color: var(--strand-gray-600);
42
+ font-weight: var(--strand-weight-medium);
43
+ }
44
+
45
+ /* ── Reduced motion ── */
46
+ @media (prefers-reduced-motion: reduce) {
47
+ .strand-breadcrumb__link {
48
+ transition: none;
49
+ }
50
+ }
@@ -0,0 +1,107 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { render } from "@testing-library/preact";
3
+ import { Breadcrumb } from "./Breadcrumb.js";
4
+
5
+ const sampleItems = [
6
+ { label: "Home", href: "/" },
7
+ { label: "Products", href: "/products" },
8
+ { label: "Widget" },
9
+ ];
10
+
11
+ describe("Breadcrumb", () => {
12
+ // ── Structure ──
13
+
14
+ it("renders nav with aria-label Breadcrumb", () => {
15
+ const { getByRole } = render(<Breadcrumb items={sampleItems} />);
16
+ const nav = getByRole("navigation");
17
+ expect(nav).toHaveAttribute("aria-label", "Breadcrumb");
18
+ });
19
+
20
+ it("renders an ol element", () => {
21
+ const { container } = render(<Breadcrumb items={sampleItems} />);
22
+ expect(container.querySelector("ol")).toBeTruthy();
23
+ });
24
+
25
+ it("renders all items", () => {
26
+ const { getAllByRole } = render(<Breadcrumb items={sampleItems} />);
27
+ expect(getAllByRole("listitem")).toHaveLength(3);
28
+ });
29
+
30
+ // ── Current page ──
31
+
32
+ it("last item has aria-current page", () => {
33
+ const { getByText } = render(<Breadcrumb items={sampleItems} />);
34
+ expect(getByText("Widget")).toHaveAttribute("aria-current", "page");
35
+ });
36
+
37
+ it("last item is not a link", () => {
38
+ const { getByText } = render(<Breadcrumb items={sampleItems} />);
39
+ expect(getByText("Widget").tagName).toBe("SPAN");
40
+ });
41
+
42
+ // ── Links ──
43
+
44
+ it("non-last items are rendered as links", () => {
45
+ const { getByText } = render(<Breadcrumb items={sampleItems} />);
46
+ expect(getByText("Home").tagName).toBe("A");
47
+ expect(getByText("Products").tagName).toBe("A");
48
+ });
49
+
50
+ it("link items have correct href", () => {
51
+ const { getByText } = render(<Breadcrumb items={sampleItems} />);
52
+ expect(getByText("Home")).toHaveAttribute("href", "/");
53
+ expect(getByText("Products")).toHaveAttribute("href", "/products");
54
+ });
55
+
56
+ // ── Separator ──
57
+
58
+ it("renders default separator between items", () => {
59
+ const { container } = render(<Breadcrumb items={sampleItems} />);
60
+ const separators = container.querySelectorAll(
61
+ ".strand-breadcrumb__separator",
62
+ );
63
+ expect(separators).toHaveLength(2);
64
+ expect(separators[0].textContent).toBe("/");
65
+ });
66
+
67
+ it("renders custom separator", () => {
68
+ const { container } = render(
69
+ <Breadcrumb items={sampleItems} separator=">" />,
70
+ );
71
+ const separators = container.querySelectorAll(
72
+ ".strand-breadcrumb__separator",
73
+ );
74
+ expect(separators[0].textContent).toBe(">");
75
+ });
76
+
77
+ // ── Custom className ──
78
+
79
+ it("merges custom className", () => {
80
+ const { getByRole } = render(
81
+ <Breadcrumb items={sampleItems} className="custom" />,
82
+ );
83
+ const nav = getByRole("navigation");
84
+ expect(nav.className).toContain("strand-breadcrumb");
85
+ expect(nav.className).toContain("custom");
86
+ });
87
+
88
+ // ── Edge cases ──
89
+
90
+ it("single item renders correctly as current page", () => {
91
+ const { getByText, getAllByRole } = render(
92
+ <Breadcrumb items={[{ label: "Home" }]} />,
93
+ );
94
+ expect(getAllByRole("listitem")).toHaveLength(1);
95
+ expect(getByText("Home")).toHaveAttribute("aria-current", "page");
96
+ });
97
+
98
+ it("separators have aria-hidden true", () => {
99
+ const { container } = render(<Breadcrumb items={sampleItems} />);
100
+ const separators = container.querySelectorAll(
101
+ ".strand-breadcrumb__separator",
102
+ );
103
+ for (const sep of separators) {
104
+ expect(sep).toHaveAttribute("aria-hidden", "true");
105
+ }
106
+ });
107
+ });
@@ -0,0 +1,59 @@
1
+ /*! Strand UI | MIT License | dillingerstaffing.com */
2
+
3
+ import type { JSX } from "preact";
4
+ import { forwardRef } from "preact/compat";
5
+
6
+ export interface BreadcrumbItem {
7
+ label: string;
8
+ href?: string;
9
+ }
10
+
11
+ export interface BreadcrumbProps
12
+ extends Omit<JSX.HTMLAttributes<HTMLElement>, "children"> {
13
+ /** Breadcrumb path items; last item is treated as current page */
14
+ items: BreadcrumbItem[];
15
+ /** Separator character between items */
16
+ separator?: string;
17
+ }
18
+
19
+ export const Breadcrumb = forwardRef<HTMLElement, BreadcrumbProps>(
20
+ ({ items, separator = "/", className = "", ...rest }, ref) => {
21
+ const classes = ["strand-breadcrumb", className]
22
+ .filter(Boolean)
23
+ .join(" ");
24
+
25
+ return (
26
+ <nav ref={ref} aria-label="Breadcrumb" className={classes} {...rest}>
27
+ <ol className="strand-breadcrumb__list">
28
+ {items.map((item, index) => {
29
+ const isLast = index === items.length - 1;
30
+
31
+ return (
32
+ <li key={`${item.label}-${index}`} className="strand-breadcrumb__item">
33
+ {index > 0 && (
34
+ <span className="strand-breadcrumb__separator" aria-hidden="true">
35
+ {separator}
36
+ </span>
37
+ )}
38
+ {isLast ? (
39
+ <span
40
+ className="strand-breadcrumb__current"
41
+ aria-current="page"
42
+ >
43
+ {item.label}
44
+ </span>
45
+ ) : (
46
+ <a href={item.href} className="strand-breadcrumb__link">
47
+ {item.label}
48
+ </a>
49
+ )}
50
+ </li>
51
+ );
52
+ })}
53
+ </ol>
54
+ </nav>
55
+ );
56
+ },
57
+ );
58
+
59
+ Breadcrumb.displayName = "Breadcrumb";
@@ -0,0 +1,2 @@
1
+ export { Breadcrumb } from "./Breadcrumb.js";
2
+ export type { BreadcrumbProps, BreadcrumbItem } from "./Breadcrumb.js";
@@ -0,0 +1,195 @@
1
+ /*! Strand UI | MIT License | dillingerstaffing.com */
2
+
3
+ /* ── Base ── */
4
+ .strand-btn {
5
+ position: relative;
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ gap: var(--strand-space-2);
10
+ border: 1px solid transparent;
11
+ border-radius: var(--strand-radius-md);
12
+ font-family: var(--strand-font-sans);
13
+ font-weight: var(--strand-weight-medium);
14
+ line-height: var(--strand-leading-snug);
15
+ white-space: nowrap;
16
+ cursor: pointer;
17
+ user-select: none;
18
+ transition:
19
+ background var(--strand-duration-fast) var(--strand-ease-out-quart),
20
+ border-color var(--strand-duration-fast) var(--strand-ease-out-quart),
21
+ color var(--strand-duration-fast) var(--strand-ease-out-quart),
22
+ transform var(--strand-duration-fast) var(--strand-ease-out-expo),
23
+ box-shadow var(--strand-duration-fast) var(--strand-ease-out-quart);
24
+ }
25
+
26
+ .strand-btn:active:not(:disabled) {
27
+ transform: translateY(0);
28
+ transition-duration: 75ms;
29
+ }
30
+
31
+ .strand-btn:disabled {
32
+ opacity: 0.4;
33
+ cursor: not-allowed;
34
+ }
35
+
36
+ /* ── Sizes ── */
37
+ .strand-btn--sm {
38
+ padding: var(--strand-space-1) var(--strand-space-3);
39
+ font-size: var(--strand-text-sm);
40
+ min-height: 32px;
41
+ }
42
+
43
+ .strand-btn--md {
44
+ padding: calc(var(--strand-space-2) + var(--strand-space-1) / 2) var(--strand-space-5);
45
+ font-size: var(--strand-text-sm);
46
+ min-height: 40px;
47
+ }
48
+
49
+ .strand-btn--lg {
50
+ padding: var(--strand-space-3) var(--strand-space-6);
51
+ font-size: var(--strand-text-base);
52
+ min-height: 48px;
53
+ }
54
+
55
+ /* ── Icon-only ── */
56
+ .strand-btn--icon-only.strand-btn--sm {
57
+ padding: var(--strand-space-1);
58
+ min-width: 32px;
59
+ }
60
+
61
+ .strand-btn--icon-only.strand-btn--md {
62
+ padding: var(--strand-space-2);
63
+ min-width: 40px;
64
+ }
65
+
66
+ .strand-btn--icon-only.strand-btn--lg {
67
+ padding: var(--strand-space-3);
68
+ min-width: 48px;
69
+ }
70
+
71
+ /* ── Full width ── */
72
+ .strand-btn--full-width {
73
+ width: 100%;
74
+ }
75
+
76
+ /* ── Primary variant ── */
77
+ .strand-btn--primary {
78
+ background: var(--strand-blue-primary);
79
+ color: var(--strand-on-blue-primary);
80
+ }
81
+
82
+ .strand-btn--primary:hover:not(:disabled) {
83
+ background: var(--strand-blue-vivid);
84
+ transform: translateY(-1px);
85
+ box-shadow: var(--strand-hover-shadow-primary);
86
+ }
87
+
88
+ .strand-btn--primary:active:not(:disabled) {
89
+ background: var(--strand-blue-deep);
90
+ }
91
+
92
+ /* ── Secondary variant ── */
93
+ .strand-btn--secondary {
94
+ background: var(--strand-surface-elevated);
95
+ color: var(--strand-blue-midnight);
96
+ border-color: var(--strand-gray-200);
97
+ }
98
+
99
+ .strand-btn--secondary:hover:not(:disabled) {
100
+ background: var(--strand-blue-glow);
101
+ border-color: var(--strand-blue-indicator);
102
+ transform: translateY(-1px);
103
+ box-shadow: var(--strand-elevation-1);
104
+ }
105
+
106
+ .strand-btn--secondary:active:not(:disabled) {
107
+ background: var(--strand-blue-wash);
108
+ }
109
+
110
+ /* ── Ghost variant ── */
111
+ .strand-btn--ghost {
112
+ background: transparent;
113
+ color: var(--strand-blue-primary);
114
+ }
115
+
116
+ .strand-btn--ghost:hover:not(:disabled) {
117
+ background: var(--strand-blue-glow);
118
+ transform: translateY(-1px);
119
+ }
120
+
121
+ .strand-btn--ghost:active:not(:disabled) {
122
+ background: var(--strand-blue-wash);
123
+ }
124
+
125
+ /* ── Danger variant ── */
126
+ .strand-btn--danger {
127
+ background: var(--strand-red-alert);
128
+ color: var(--strand-on-red-alert);
129
+ }
130
+
131
+ .strand-btn--danger:hover:not(:disabled) {
132
+ background: var(--strand-red-alert-vivid);
133
+ transform: translateY(-1px);
134
+ box-shadow: var(--strand-hover-shadow-danger);
135
+ }
136
+
137
+ .strand-btn--danger:active:not(:disabled) {
138
+ background: var(--strand-red-alert-deep);
139
+ }
140
+
141
+ /* ── Loading state ── */
142
+ .strand-btn--loading {
143
+ pointer-events: none;
144
+ }
145
+
146
+ .strand-btn__spinner {
147
+ position: absolute;
148
+ width: 16px;
149
+ height: 16px;
150
+ border: 2px solid currentColor;
151
+ border-top-color: transparent;
152
+ border-radius: var(--strand-radius-full);
153
+ animation: strand-btn-spin 0.8s linear infinite;
154
+ opacity: 0.8;
155
+ }
156
+
157
+ .strand-btn--lg .strand-btn__spinner {
158
+ width: 20px;
159
+ height: 20px;
160
+ }
161
+
162
+ @keyframes strand-btn-spin {
163
+ to {
164
+ transform: rotate(360deg);
165
+ }
166
+ }
167
+
168
+ /* ── Content wrapper ── */
169
+ .strand-btn__content {
170
+ display: inline-flex;
171
+ align-items: center;
172
+ gap: var(--strand-space-2);
173
+ }
174
+
175
+ /* ── Focus ring (Part XII: Accessibility Ring) ── */
176
+ .strand-btn:focus-visible {
177
+ outline: 2px solid var(--strand-blue-primary);
178
+ outline-offset: 2px;
179
+ }
180
+
181
+ /* ── Reduced motion ── */
182
+ @media (prefers-reduced-motion: reduce) {
183
+ .strand-btn {
184
+ transition: none;
185
+ }
186
+
187
+ .strand-btn:hover:not(:disabled) {
188
+ transform: none;
189
+ }
190
+
191
+ .strand-btn__spinner {
192
+ animation: none;
193
+ border-style: dotted;
194
+ }
195
+ }
@@ -0,0 +1,171 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { render, fireEvent } from "@testing-library/preact";
3
+ import { Button } from "./Button.js";
4
+
5
+ describe("Button", () => {
6
+ // ── Rendering ──
7
+
8
+ it("renders with children text", () => {
9
+ const { getByRole } = render(<Button>Click me</Button>);
10
+ expect(getByRole("button")).toHaveTextContent("Click me");
11
+ });
12
+
13
+ it("renders as a button element by default", () => {
14
+ const { getByRole } = render(<Button>Test</Button>);
15
+ expect(getByRole("button").tagName).toBe("BUTTON");
16
+ });
17
+
18
+ it("has type='button' by default to prevent form submission", () => {
19
+ const { getByRole } = render(<Button>Test</Button>);
20
+ expect(getByRole("button")).toHaveAttribute("type", "button");
21
+ });
22
+
23
+ it("allows type override to submit", () => {
24
+ const { getByRole } = render(<Button type="submit">Submit</Button>);
25
+ expect(getByRole("button")).toHaveAttribute("type", "submit");
26
+ });
27
+
28
+ // ── Variants ──
29
+
30
+ it("applies primary variant class by default", () => {
31
+ const { getByRole } = render(<Button>Test</Button>);
32
+ expect(getByRole("button").className).toContain("strand-btn--primary");
33
+ });
34
+
35
+ it("applies secondary variant class", () => {
36
+ const { getByRole } = render(<Button variant="secondary">Test</Button>);
37
+ expect(getByRole("button").className).toContain("strand-btn--secondary");
38
+ });
39
+
40
+ it("applies ghost variant class", () => {
41
+ const { getByRole } = render(<Button variant="ghost">Test</Button>);
42
+ expect(getByRole("button").className).toContain("strand-btn--ghost");
43
+ });
44
+
45
+ it("applies danger variant class", () => {
46
+ const { getByRole } = render(<Button variant="danger">Test</Button>);
47
+ expect(getByRole("button").className).toContain("strand-btn--danger");
48
+ });
49
+
50
+ // ── Sizes ──
51
+
52
+ it("applies md size class by default", () => {
53
+ const { getByRole } = render(<Button>Test</Button>);
54
+ expect(getByRole("button").className).toContain("strand-btn--md");
55
+ });
56
+
57
+ it("applies sm size class", () => {
58
+ const { getByRole } = render(<Button size="sm">Test</Button>);
59
+ expect(getByRole("button").className).toContain("strand-btn--sm");
60
+ });
61
+
62
+ it("applies lg size class", () => {
63
+ const { getByRole } = render(<Button size="lg">Test</Button>);
64
+ expect(getByRole("button").className).toContain("strand-btn--lg");
65
+ });
66
+
67
+ // ── Icon-only ──
68
+
69
+ it("applies icon-only class when iconOnly is true", () => {
70
+ const { getByRole } = render(
71
+ <Button iconOnly aria-label="Close">X</Button>
72
+ );
73
+ expect(getByRole("button").className).toContain("strand-btn--icon-only");
74
+ });
75
+
76
+ // ── Interaction ──
77
+
78
+ it("calls onClick when clicked", () => {
79
+ const onClick = vi.fn();
80
+ const { getByRole } = render(<Button onClick={onClick}>Click</Button>);
81
+ fireEvent.click(getByRole("button"));
82
+ expect(onClick).toHaveBeenCalledTimes(1);
83
+ });
84
+
85
+ it("does not call onClick when disabled", () => {
86
+ const onClick = vi.fn();
87
+ const { getByRole } = render(
88
+ <Button onClick={onClick} disabled>Click</Button>
89
+ );
90
+ fireEvent.click(getByRole("button"));
91
+ expect(onClick).not.toHaveBeenCalled();
92
+ });
93
+
94
+ // ── Disabled state ──
95
+
96
+ it("sets disabled attribute when disabled", () => {
97
+ const { getByRole } = render(<Button disabled>Test</Button>);
98
+ expect(getByRole("button")).toBeDisabled();
99
+ });
100
+
101
+ it("sets aria-disabled when disabled", () => {
102
+ const { getByRole } = render(<Button disabled>Test</Button>);
103
+ expect(getByRole("button")).toHaveAttribute("aria-disabled", "true");
104
+ });
105
+
106
+ // ── Loading state ──
107
+
108
+ it("shows loading state", () => {
109
+ const { getByRole } = render(<Button loading>Test</Button>);
110
+ const btn = getByRole("button");
111
+ expect(btn.className).toContain("strand-btn--loading");
112
+ expect(btn).toHaveAttribute("aria-busy", "true");
113
+ });
114
+
115
+ it("disables interaction when loading", () => {
116
+ const onClick = vi.fn();
117
+ const { getByRole } = render(
118
+ <Button loading onClick={onClick}>Test</Button>
119
+ );
120
+ fireEvent.click(getByRole("button"));
121
+ expect(onClick).not.toHaveBeenCalled();
122
+ });
123
+
124
+ it("renders spinner element when loading", () => {
125
+ const { container } = render(<Button loading>Test</Button>);
126
+ expect(container.querySelector(".strand-btn__spinner")).toBeTruthy();
127
+ });
128
+
129
+ // ── Accessibility ──
130
+
131
+ it("is focusable via keyboard", () => {
132
+ const { getByRole } = render(<Button>Test</Button>);
133
+ const btn = getByRole("button");
134
+ btn.focus();
135
+ expect(document.activeElement).toBe(btn);
136
+ });
137
+
138
+ it("is not focusable when disabled", () => {
139
+ const { getByRole } = render(<Button disabled>Test</Button>);
140
+ const btn = getByRole("button");
141
+ expect(btn).toBeDisabled();
142
+ });
143
+
144
+ it("supports aria-label", () => {
145
+ const { getByRole } = render(<Button aria-label="Close dialog">X</Button>);
146
+ expect(getByRole("button")).toHaveAttribute("aria-label", "Close dialog");
147
+ });
148
+
149
+ it("forwards additional props", () => {
150
+ const { getByRole } = render(
151
+ <Button data-testid="custom" id="my-btn">Test</Button>
152
+ );
153
+ expect(getByRole("button")).toHaveAttribute("id", "my-btn");
154
+ });
155
+
156
+ // ── Custom className ──
157
+
158
+ it("merges custom className with component classes", () => {
159
+ const { getByRole } = render(<Button className="custom">Test</Button>);
160
+ const btn = getByRole("button");
161
+ expect(btn.className).toContain("strand-btn");
162
+ expect(btn.className).toContain("custom");
163
+ });
164
+
165
+ // ── Full width ──
166
+
167
+ it("applies full-width class when fullWidth is true", () => {
168
+ const { getByRole } = render(<Button fullWidth>Test</Button>);
169
+ expect(getByRole("button").className).toContain("strand-btn--full-width");
170
+ });
171
+ });
@@ -0,0 +1,78 @@
1
+ /*! Strand UI | MIT License | dillingerstaffing.com */
2
+
3
+ import type { JSX } from "preact";
4
+ import { forwardRef } from "preact/compat";
5
+
6
+ export interface ButtonProps
7
+ extends Omit<JSX.HTMLAttributes<HTMLButtonElement>, "size" | "loading" | "type"> {
8
+ /** Visual style variant */
9
+ variant?: "primary" | "secondary" | "ghost" | "danger";
10
+ /** Button size */
11
+ size?: "sm" | "md" | "lg";
12
+ /** Show loading spinner and disable interaction */
13
+ loading?: boolean;
14
+ /** Square button for icon-only use */
15
+ iconOnly?: boolean;
16
+ /** HTML button type */
17
+ type?: "button" | "submit" | "reset";
18
+ /** Disabled state */
19
+ disabled?: boolean;
20
+ /** Stretch to full container width */
21
+ fullWidth?: boolean;
22
+ }
23
+
24
+ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
25
+ (
26
+ {
27
+ variant = "primary",
28
+ size = "md",
29
+ loading = false,
30
+ iconOnly = false,
31
+ fullWidth = false,
32
+ disabled = false,
33
+ className = "",
34
+ children,
35
+ onClick,
36
+ type = "button",
37
+ ...rest
38
+ },
39
+ ref,
40
+ ) => {
41
+ const isDisabled = disabled || loading;
42
+
43
+ const classes = [
44
+ "strand-btn",
45
+ `strand-btn--${variant}`,
46
+ `strand-btn--${size}`,
47
+ iconOnly && "strand-btn--icon-only",
48
+ fullWidth && "strand-btn--full-width",
49
+ loading && "strand-btn--loading",
50
+ className,
51
+ ]
52
+ .filter(Boolean)
53
+ .join(" ");
54
+
55
+ return (
56
+ <button
57
+ ref={ref}
58
+ type={type}
59
+ className={classes}
60
+ disabled={isDisabled}
61
+ aria-disabled={isDisabled ? "true" : undefined}
62
+ aria-busy={loading ? "true" : undefined}
63
+ onClick={isDisabled ? undefined : onClick}
64
+ {...rest}
65
+ >
66
+ {loading && <span className="strand-btn__spinner" aria-hidden="true" />}
67
+ <span
68
+ className="strand-btn__content"
69
+ style={loading ? { visibility: "hidden" } : undefined}
70
+ >
71
+ {children}
72
+ </span>
73
+ </button>
74
+ );
75
+ },
76
+ );
77
+
78
+ Button.displayName = "Button";
@@ -0,0 +1,2 @@
1
+ export { Button } from "./Button.js";
2
+ export type { ButtonProps } from "./Button.js";