@dillingerstaffing/strand-ui 0.1.0 → 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/LICENSE +21 -0
- package/dist/components/Alert/Alert.d.ts +16 -0
- package/dist/components/Alert/Alert.d.ts.map +1 -0
- package/dist/components/Alert/index.d.ts +3 -0
- package/dist/components/Alert/index.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +16 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar/index.d.ts +3 -0
- package/dist/components/Avatar/index.d.ts.map +1 -0
- package/dist/components/Badge/Badge.d.ts +18 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -0
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +16 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb/index.d.ts +3 -0
- package/dist/components/Breadcrumb/index.d.ts.map +1 -0
- package/dist/components/Button/Button.d.ts +22 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Card/Card.d.ts +12 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +20 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Container/Container.d.ts +10 -0
- package/dist/components/Container/Container.d.ts.map +1 -0
- package/dist/components/Container/index.d.ts +3 -0
- package/dist/components/Container/index.d.ts.map +1 -0
- package/dist/components/DataReadout/DataReadout.d.ts +12 -0
- package/dist/components/DataReadout/DataReadout.d.ts.map +1 -0
- package/dist/components/DataReadout/index.d.ts +3 -0
- package/dist/components/DataReadout/index.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +20 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.d.ts.map +1 -0
- package/dist/components/Divider/Divider.d.ts +13 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Divider/index.d.ts.map +1 -0
- package/dist/components/FormField/FormField.d.ts +22 -0
- package/dist/components/FormField/FormField.d.ts.map +1 -0
- package/dist/components/FormField/index.d.ts +3 -0
- package/dist/components/FormField/index.d.ts.map +1 -0
- package/dist/components/Grid/Grid.d.ts +12 -0
- package/dist/components/Grid/Grid.d.ts.map +1 -0
- package/dist/components/Grid/index.d.ts +3 -0
- package/dist/components/Grid/index.d.ts.map +1 -0
- package/dist/components/Input/Input.d.ts +18 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Link/Link.d.ts +12 -0
- package/dist/components/Link/Link.d.ts.map +1 -0
- package/dist/components/Link/index.d.ts +3 -0
- package/dist/components/Link/index.d.ts.map +1 -0
- package/dist/components/Nav/Nav.d.ts +19 -0
- package/dist/components/Nav/Nav.d.ts.map +1 -0
- package/dist/components/Nav/index.d.ts +3 -0
- package/dist/components/Nav/index.d.ts.map +1 -0
- package/dist/components/Progress/Progress.d.ts +14 -0
- package/dist/components/Progress/Progress.d.ts.map +1 -0
- package/dist/components/Progress/index.d.ts +3 -0
- package/dist/components/Progress/index.d.ts.map +1 -0
- package/dist/components/Radio/Radio.d.ts +22 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +3 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Section/Section.d.ts +12 -0
- package/dist/components/Section/Section.d.ts.map +1 -0
- package/dist/components/Section/index.d.ts +3 -0
- package/dist/components/Section/index.d.ts.map +1 -0
- package/dist/components/Select/Select.d.ts +24 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +14 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +3 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Slider/Slider.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Slider/index.d.ts +3 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Spinner/Spinner.d.ts +10 -0
- package/dist/components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner/index.d.ts +3 -0
- package/dist/components/Spinner/index.d.ts.map +1 -0
- package/dist/components/Stack/Stack.d.ts +18 -0
- package/dist/components/Stack/Stack.d.ts.map +1 -0
- package/dist/components/Stack/index.d.ts +3 -0
- package/dist/components/Stack/index.d.ts.map +1 -0
- package/dist/components/Switch/Switch.d.ts +18 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -0
- package/dist/components/Switch/index.d.ts +3 -0
- package/dist/components/Switch/index.d.ts.map +1 -0
- package/dist/components/Table/Table.d.ts +24 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +19 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/index.d.ts +3 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tag/Tag.d.ts +18 -0
- package/dist/components/Tag/Tag.d.ts.map +1 -0
- package/dist/components/Tag/index.d.ts +3 -0
- package/dist/components/Tag/index.d.ts.map +1 -0
- package/dist/components/Textarea/Textarea.d.ts +22 -0
- package/dist/components/Textarea/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea/index.d.ts +3 -0
- package/dist/components/Textarea/index.d.ts.map +1 -0
- package/dist/components/Toast/Toast.d.ts +33 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.d.ts.map +1 -0
- package/dist/css/strand-ui.css +2301 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/package.json +12 -11
- package/src/__tests__/build-output.test.ts +77 -0
- package/src/components/Alert/Alert.css +67 -0
- package/src/components/Alert/Alert.test.tsx +92 -0
- package/src/components/Alert/Alert.tsx +59 -0
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Avatar/Avatar.css +55 -0
- package/src/components/Avatar/Avatar.test.tsx +123 -0
- package/src/components/Avatar/Avatar.tsx +67 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.css +72 -0
- package/src/components/Badge/Badge.test.tsx +121 -0
- package/src/components/Badge/Badge.tsx +92 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.css +45 -0
- package/src/components/Breadcrumb/Breadcrumb.test.tsx +107 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +59 -0
- package/src/components/Breadcrumb/index.ts +2 -0
- package/src/components/Button/Button.css +188 -0
- package/src/components/Button/Button.test.tsx +171 -0
- package/src/components/Button/Button.tsx +78 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Card/Card.css +59 -0
- package/src/components/Card/Card.test.tsx +90 -0
- package/src/components/Card/Card.tsx +41 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.css +97 -0
- package/src/components/Checkbox/Checkbox.test.tsx +92 -0
- package/src/components/Checkbox/Checkbox.tsx +137 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Container/Container.css +25 -0
- package/src/components/Container/Container.test.tsx +82 -0
- package/src/components/Container/Container.tsx +37 -0
- package/src/components/Container/index.ts +2 -0
- package/src/components/DataReadout/DataReadout.css +30 -0
- package/src/components/DataReadout/DataReadout.test.tsx +105 -0
- package/src/components/DataReadout/DataReadout.tsx +29 -0
- package/src/components/DataReadout/index.ts +2 -0
- package/src/components/Dialog/Dialog.css +80 -0
- package/src/components/Dialog/Dialog.test.tsx +203 -0
- package/src/components/Dialog/Dialog.tsx +179 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Divider/Divider.css +44 -0
- package/src/components/Divider/Divider.test.tsx +86 -0
- package/src/components/Divider/Divider.tsx +81 -0
- package/src/components/Divider/index.ts +2 -0
- package/src/components/FormField/FormField.css +47 -0
- package/src/components/FormField/FormField.test.tsx +99 -0
- package/src/components/FormField/FormField.tsx +79 -0
- package/src/components/FormField/index.ts +2 -0
- package/src/components/Grid/Grid.css +6 -0
- package/src/components/Grid/Grid.test.tsx +86 -0
- package/src/components/Grid/Grid.tsx +45 -0
- package/src/components/Grid/index.ts +2 -0
- package/src/components/Input/Input.css +80 -0
- package/src/components/Input/Input.test.tsx +95 -0
- package/src/components/Input/Input.tsx +69 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Link/Link.css +24 -0
- package/src/components/Link/Link.test.tsx +88 -0
- package/src/components/Link/Link.tsx +31 -0
- package/src/components/Link/index.ts +2 -0
- package/src/components/Nav/Nav.css +169 -0
- package/src/components/Nav/Nav.test.tsx +174 -0
- package/src/components/Nav/Nav.tsx +101 -0
- package/src/components/Nav/index.ts +2 -0
- package/src/components/Progress/Progress.css +93 -0
- package/src/components/Progress/Progress.test.tsx +93 -0
- package/src/components/Progress/Progress.tsx +104 -0
- package/src/components/Progress/index.ts +2 -0
- package/src/components/Radio/Radio.css +98 -0
- package/src/components/Radio/Radio.test.tsx +80 -0
- package/src/components/Radio/Radio.tsx +72 -0
- package/src/components/Radio/index.ts +2 -0
- package/src/components/Section/Section.css +28 -0
- package/src/components/Section/Section.test.tsx +100 -0
- package/src/components/Section/Section.tsx +41 -0
- package/src/components/Section/index.ts +2 -0
- package/src/components/Select/Select.css +68 -0
- package/src/components/Select/Select.test.tsx +99 -0
- package/src/components/Select/Select.tsx +78 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Skeleton/Skeleton.css +52 -0
- package/src/components/Skeleton/Skeleton.test.tsx +96 -0
- package/src/components/Skeleton/Skeleton.tsx +55 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Slider/Slider.css +107 -0
- package/src/components/Slider/Slider.test.tsx +85 -0
- package/src/components/Slider/Slider.tsx +66 -0
- package/src/components/Slider/index.ts +2 -0
- package/src/components/Spinner/Spinner.css +61 -0
- package/src/components/Spinner/Spinner.test.tsx +56 -0
- package/src/components/Spinner/Spinner.tsx +38 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Stack/Stack.css +56 -0
- package/src/components/Stack/Stack.test.tsx +130 -0
- package/src/components/Stack/Stack.tsx +77 -0
- package/src/components/Stack/index.ts +2 -0
- package/src/components/Switch/Switch.css +94 -0
- package/src/components/Switch/Switch.test.tsx +98 -0
- package/src/components/Switch/Switch.tsx +80 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Table/Table.css +78 -0
- package/src/components/Table/Table.test.tsx +134 -0
- package/src/components/Table/Table.tsx +102 -0
- package/src/components/Table/index.ts +2 -0
- package/src/components/Tabs/Tabs.css +46 -0
- package/src/components/Tabs/Tabs.test.tsx +164 -0
- package/src/components/Tabs/Tabs.tsx +126 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Tag/Tag.css +98 -0
- package/src/components/Tag/Tag.test.tsx +112 -0
- package/src/components/Tag/Tag.tsx +73 -0
- package/src/components/Tag/index.ts +2 -0
- package/src/components/Textarea/Textarea.css +73 -0
- package/src/components/Textarea/Textarea.test.tsx +89 -0
- package/src/components/Textarea/Textarea.tsx +102 -0
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/Toast/Toast.css +103 -0
- package/src/components/Toast/Toast.test.tsx +219 -0
- package/src/components/Toast/Toast.tsx +177 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.css +63 -0
- package/src/components/Tooltip/Tooltip.test.tsx +196 -0
- package/src/components/Tooltip/Tooltip.tsx +89 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/index.ts +99 -0
- package/src/test-setup.ts +7 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*! Strand UI v0.1.0 | MIT License | dillingerstaffing.com */
|
|
2
|
+
export { Button } from "./components/Button/index.js";
|
|
3
|
+
export type { ButtonProps } from "./components/Button/index.js";
|
|
4
|
+
export { Input } from "./components/Input/index.js";
|
|
5
|
+
export type { InputProps } from "./components/Input/index.js";
|
|
6
|
+
export { Textarea } from "./components/Textarea/index.js";
|
|
7
|
+
export type { TextareaProps } from "./components/Textarea/index.js";
|
|
8
|
+
export { Select } from "./components/Select/index.js";
|
|
9
|
+
export type { SelectProps, SelectOption } from "./components/Select/index.js";
|
|
10
|
+
export { Checkbox } from "./components/Checkbox/index.js";
|
|
11
|
+
export type { CheckboxProps } from "./components/Checkbox/index.js";
|
|
12
|
+
export { Radio } from "./components/Radio/index.js";
|
|
13
|
+
export type { RadioProps } from "./components/Radio/index.js";
|
|
14
|
+
export { Switch } from "./components/Switch/index.js";
|
|
15
|
+
export type { SwitchProps } from "./components/Switch/index.js";
|
|
16
|
+
export { Slider } from "./components/Slider/index.js";
|
|
17
|
+
export type { SliderProps } from "./components/Slider/index.js";
|
|
18
|
+
export { FormField } from "./components/FormField/index.js";
|
|
19
|
+
export type { FormFieldProps } from "./components/FormField/index.js";
|
|
20
|
+
export { Card } from "./components/Card/index.js";
|
|
21
|
+
export type { CardProps } from "./components/Card/index.js";
|
|
22
|
+
export { Badge } from "./components/Badge/index.js";
|
|
23
|
+
export type { BadgeProps } from "./components/Badge/index.js";
|
|
24
|
+
export { Avatar } from "./components/Avatar/index.js";
|
|
25
|
+
export type { AvatarProps } from "./components/Avatar/index.js";
|
|
26
|
+
export { Tag } from "./components/Tag/index.js";
|
|
27
|
+
export type { TagProps } from "./components/Tag/index.js";
|
|
28
|
+
export { Table } from "./components/Table/index.js";
|
|
29
|
+
export type { TableProps, TableColumn } from "./components/Table/index.js";
|
|
30
|
+
export { DataReadout } from "./components/DataReadout/index.js";
|
|
31
|
+
export type { DataReadoutProps } from "./components/DataReadout/index.js";
|
|
32
|
+
export { Stack } from "./components/Stack/index.js";
|
|
33
|
+
export type { StackProps } from "./components/Stack/index.js";
|
|
34
|
+
export { Grid } from "./components/Grid/index.js";
|
|
35
|
+
export type { GridProps } from "./components/Grid/index.js";
|
|
36
|
+
export { Container } from "./components/Container/index.js";
|
|
37
|
+
export type { ContainerProps } from "./components/Container/index.js";
|
|
38
|
+
export { Divider } from "./components/Divider/index.js";
|
|
39
|
+
export type { DividerProps } from "./components/Divider/index.js";
|
|
40
|
+
export { Section } from "./components/Section/index.js";
|
|
41
|
+
export type { SectionProps } from "./components/Section/index.js";
|
|
42
|
+
export { Link } from "./components/Link/index.js";
|
|
43
|
+
export type { LinkProps } from "./components/Link/index.js";
|
|
44
|
+
export { Tabs } from "./components/Tabs/index.js";
|
|
45
|
+
export type { TabsProps, TabItem } from "./components/Tabs/index.js";
|
|
46
|
+
export { Breadcrumb } from "./components/Breadcrumb/index.js";
|
|
47
|
+
export type { BreadcrumbProps, BreadcrumbItem } from "./components/Breadcrumb/index.js";
|
|
48
|
+
export { Nav } from "./components/Nav/index.js";
|
|
49
|
+
export type { NavProps } from "./components/Nav/index.js";
|
|
50
|
+
export { Toast, ToastProvider, useToast } from "./components/Toast/index.js";
|
|
51
|
+
export type { ToastProps } from "./components/Toast/index.js";
|
|
52
|
+
export { Alert } from "./components/Alert/index.js";
|
|
53
|
+
export type { AlertProps } from "./components/Alert/index.js";
|
|
54
|
+
export { Dialog } from "./components/Dialog/index.js";
|
|
55
|
+
export type { DialogProps } from "./components/Dialog/index.js";
|
|
56
|
+
export { Tooltip } from "./components/Tooltip/index.js";
|
|
57
|
+
export type { TooltipProps } from "./components/Tooltip/index.js";
|
|
58
|
+
export { Progress } from "./components/Progress/index.js";
|
|
59
|
+
export type { ProgressProps } from "./components/Progress/index.js";
|
|
60
|
+
export { Spinner } from "./components/Spinner/index.js";
|
|
61
|
+
export type { SpinnerProps } from "./components/Spinner/index.js";
|
|
62
|
+
export { Skeleton } from "./components/Skeleton/index.js";
|
|
63
|
+
export type { SkeletonProps } from "./components/Skeleton/index.js";
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dillingerstaffing/strand-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Strand UI - Preact/React component library built on the Strand Design Language",
|
|
5
5
|
"author": "Dillinger Staffing <engineering@dillingerstaffing.com> (https://dillingerstaffing.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,20 +22,15 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"import": "./dist/index.js"
|
|
24
24
|
},
|
|
25
|
-
"./css
|
|
25
|
+
"./css/strand-ui.css": "./dist/css/strand-ui.css"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist/"
|
|
28
|
+
"dist/",
|
|
29
|
+
"src/"
|
|
29
30
|
],
|
|
30
31
|
"sideEffects": [
|
|
31
32
|
"dist/css/*.css"
|
|
32
33
|
],
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build": "vite build",
|
|
35
|
-
"test": "vitest run",
|
|
36
|
-
"test:watch": "vitest",
|
|
37
|
-
"test:coverage": "vitest run --coverage"
|
|
38
|
-
},
|
|
39
34
|
"peerDependencies": {
|
|
40
35
|
"preact": "^10.0.0"
|
|
41
36
|
},
|
|
@@ -45,7 +40,7 @@
|
|
|
45
40
|
}
|
|
46
41
|
},
|
|
47
42
|
"dependencies": {
|
|
48
|
-
"@dillingerstaffing/strand": "
|
|
43
|
+
"@dillingerstaffing/strand": "0.1.1"
|
|
49
44
|
},
|
|
50
45
|
"devDependencies": {
|
|
51
46
|
"@testing-library/preact": "^3.2.0",
|
|
@@ -54,5 +49,11 @@
|
|
|
54
49
|
"preact": "^10.25.0",
|
|
55
50
|
"vite": "^6.0.0",
|
|
56
51
|
"vitest": "^3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"test:coverage": "vitest run --coverage"
|
|
57
58
|
}
|
|
58
|
-
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const distDir = resolve(__dirname, "../../dist");
|
|
6
|
+
|
|
7
|
+
describe("Build output", () => {
|
|
8
|
+
it("produces index.js bundle", () => {
|
|
9
|
+
expect(existsSync(resolve(distDir, "index.js"))).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("produces index.d.ts declarations", () => {
|
|
13
|
+
expect(existsSync(resolve(distDir, "index.d.ts"))).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("declarations export all component types", () => {
|
|
17
|
+
const dts = readFileSync(resolve(distDir, "index.d.ts"), "utf-8");
|
|
18
|
+
const expectedExports = [
|
|
19
|
+
"Button", "Input", "Textarea", "Select", "Checkbox", "Radio",
|
|
20
|
+
"Switch", "Slider", "FormField", "Card", "Badge", "Avatar",
|
|
21
|
+
"Tag", "Table", "DataReadout", "Stack", "Grid", "Container",
|
|
22
|
+
"Divider", "Section", "Link", "Tabs", "Breadcrumb", "Nav",
|
|
23
|
+
"Toast", "Alert", "Dialog", "Tooltip", "Progress", "Spinner", "Skeleton",
|
|
24
|
+
];
|
|
25
|
+
for (const name of expectedExports) {
|
|
26
|
+
expect(dts, `Missing export: ${name}`).toContain(name);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("produces combined CSS file", () => {
|
|
31
|
+
expect(existsSync(resolve(distDir, "css/strand-ui.css"))).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("CSS file contains styles for all components", () => {
|
|
35
|
+
const css = readFileSync(resolve(distDir, "css/strand-ui.css"), "utf-8");
|
|
36
|
+
const expectedClasses = [
|
|
37
|
+
".strand-btn", ".strand-input", ".strand-select",
|
|
38
|
+
".strand-checkbox", ".strand-radio", ".strand-switch",
|
|
39
|
+
".strand-slider", ".strand-card", ".strand-badge",
|
|
40
|
+
".strand-avatar", ".strand-tag", ".strand-table",
|
|
41
|
+
".strand-data-readout", ".strand-stack", ".strand-grid",
|
|
42
|
+
".strand-container", ".strand-divider", ".strand-section",
|
|
43
|
+
".strand-link", ".strand-tabs", ".strand-breadcrumb",
|
|
44
|
+
".strand-nav", ".strand-toast", ".strand-alert",
|
|
45
|
+
".strand-dialog", ".strand-tooltip", ".strand-progress",
|
|
46
|
+
".strand-spinner", ".strand-skeleton",
|
|
47
|
+
];
|
|
48
|
+
for (const cls of expectedClasses) {
|
|
49
|
+
expect(css, `Missing CSS class: ${cls}`).toContain(cls);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("CSS file uses only strand tokens (no hardcoded colors)", () => {
|
|
54
|
+
const css = readFileSync(resolve(distDir, "css/strand-ui.css"), "utf-8");
|
|
55
|
+
// Remove comments and check for hardcoded hex colors that aren't in rgba()
|
|
56
|
+
const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
57
|
+
const hexMatches = withoutComments.match(/#[0-9a-fA-F]{6}\b/g) || [];
|
|
58
|
+
// Filter out known exceptions (danger hover/active states that extend the palette)
|
|
59
|
+
const knownExceptions = ["#DC2626", "#B91C1C", "#0D7377", "#92400E", "#991B1B"];
|
|
60
|
+
const unexpected = hexMatches.filter(
|
|
61
|
+
(h) => !knownExceptions.includes(h.toUpperCase())
|
|
62
|
+
);
|
|
63
|
+
expect(unexpected, `Hardcoded hex colors found: ${unexpected.join(", ")}`).toEqual([]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("JS bundle is under 50KB gzipped budget", () => {
|
|
67
|
+
const js = readFileSync(resolve(distDir, "index.js"), "utf-8");
|
|
68
|
+
// Rough check: uncompressed should be well under 200KB (gzip ~4:1 ratio)
|
|
69
|
+
expect(js.length).toBeLessThan(200_000);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("src/ directory exists for CLI copy-paste", () => {
|
|
73
|
+
expect(existsSync(resolve(__dirname, "../components/Button/Button.tsx"))).toBe(true);
|
|
74
|
+
expect(existsSync(resolve(__dirname, "../components/Button/Button.css"))).toBe(true);
|
|
75
|
+
expect(existsSync(resolve(__dirname, "../components/Dialog/Dialog.tsx"))).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*! Strand UI | MIT License | dillingerstaffing.com */
|
|
2
|
+
|
|
3
|
+
/* ── Base ── */
|
|
4
|
+
.strand-alert {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
width: 100%;
|
|
10
|
+
padding: var(--strand-space-4);
|
|
11
|
+
border-radius: var(--strand-radius-md);
|
|
12
|
+
border-left: 4px solid transparent;
|
|
13
|
+
font-family: var(--strand-font-sans);
|
|
14
|
+
font-size: var(--strand-text-sm);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ── Status variants ── */
|
|
18
|
+
.strand-alert--info {
|
|
19
|
+
background: var(--strand-blue-glow);
|
|
20
|
+
border-left-color: var(--strand-blue-primary);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.strand-alert--success {
|
|
24
|
+
background: rgba(34, 197, 94, 0.08);
|
|
25
|
+
border-left-color: var(--strand-green-positive);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.strand-alert--warning {
|
|
29
|
+
background: rgba(245, 158, 11, 0.08);
|
|
30
|
+
border-left-color: var(--strand-amber-caution);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.strand-alert--error {
|
|
34
|
+
background: rgba(239, 68, 68, 0.08);
|
|
35
|
+
border-left-color: var(--strand-red-alert);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ── Content ── */
|
|
39
|
+
.strand-alert__content {
|
|
40
|
+
flex: 1;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ── Dismiss button ── */
|
|
45
|
+
.strand-alert__dismiss {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
width: 24px;
|
|
51
|
+
height: 24px;
|
|
52
|
+
margin-left: var(--strand-space-4);
|
|
53
|
+
padding: 0;
|
|
54
|
+
border: none;
|
|
55
|
+
border-radius: var(--strand-radius-md);
|
|
56
|
+
background: transparent;
|
|
57
|
+
color: var(--strand-gray-500);
|
|
58
|
+
font-size: var(--strand-text-base);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
transition: background var(--strand-duration-fast) ease,
|
|
61
|
+
color var(--strand-duration-fast) ease;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.strand-alert__dismiss:hover {
|
|
65
|
+
background: var(--strand-gray-100);
|
|
66
|
+
color: var(--strand-gray-600);
|
|
67
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/preact";
|
|
3
|
+
import { Alert } from "./Alert.js";
|
|
4
|
+
|
|
5
|
+
describe("Alert", () => {
|
|
6
|
+
// ── Rendering ──
|
|
7
|
+
|
|
8
|
+
it("renders children text", () => {
|
|
9
|
+
const { getByRole } = render(<Alert>Something happened</Alert>);
|
|
10
|
+
expect(getByRole("status")).toHaveTextContent("Something happened");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// ── Status classes ──
|
|
14
|
+
|
|
15
|
+
it("applies info status class by default", () => {
|
|
16
|
+
const { getByRole } = render(<Alert>Info</Alert>);
|
|
17
|
+
expect(getByRole("status").className).toContain("strand-alert--info");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("applies success status class", () => {
|
|
21
|
+
const { getByRole } = render(<Alert status="success">OK</Alert>);
|
|
22
|
+
expect(getByRole("status").className).toContain("strand-alert--success");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("applies warning status class", () => {
|
|
26
|
+
const { getByRole } = render(<Alert status="warning">Warn</Alert>);
|
|
27
|
+
expect(getByRole("alert").className).toContain("strand-alert--warning");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("applies error status class", () => {
|
|
31
|
+
const { getByRole } = render(<Alert status="error">Fail</Alert>);
|
|
32
|
+
expect(getByRole("alert").className).toContain("strand-alert--error");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ── ARIA roles ──
|
|
36
|
+
|
|
37
|
+
it("uses role alert for error status", () => {
|
|
38
|
+
const { getByRole } = render(<Alert status="error">Err</Alert>);
|
|
39
|
+
expect(getByRole("alert")).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("uses role alert for warning status", () => {
|
|
43
|
+
const { getByRole } = render(<Alert status="warning">Warn</Alert>);
|
|
44
|
+
expect(getByRole("alert")).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("uses role status for info status", () => {
|
|
48
|
+
const { getByRole } = render(<Alert status="info">Info</Alert>);
|
|
49
|
+
expect(getByRole("status")).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("uses role status for success status", () => {
|
|
53
|
+
const { getByRole } = render(<Alert status="success">OK</Alert>);
|
|
54
|
+
expect(getByRole("status")).toBeTruthy();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// ── Dismissible ──
|
|
58
|
+
|
|
59
|
+
it("shows dismiss button when dismissible", () => {
|
|
60
|
+
const { getByLabelText } = render(
|
|
61
|
+
<Alert dismissible>Dismissible</Alert>,
|
|
62
|
+
);
|
|
63
|
+
expect(getByLabelText("Dismiss")).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("calls onDismiss when dismiss button is clicked", () => {
|
|
67
|
+
const onDismiss = vi.fn();
|
|
68
|
+
const { getByLabelText } = render(
|
|
69
|
+
<Alert dismissible onDismiss={onDismiss}>
|
|
70
|
+
Dismiss me
|
|
71
|
+
</Alert>,
|
|
72
|
+
);
|
|
73
|
+
fireEvent.click(getByLabelText("Dismiss"));
|
|
74
|
+
expect(onDismiss).toHaveBeenCalledTimes(1);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("does not show dismiss button when not dismissible", () => {
|
|
78
|
+
const { queryByLabelText } = render(<Alert>Not dismissible</Alert>);
|
|
79
|
+
expect(queryByLabelText("Dismiss")).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// ── Custom className ──
|
|
83
|
+
|
|
84
|
+
it("merges custom className", () => {
|
|
85
|
+
const { getByRole } = render(
|
|
86
|
+
<Alert className="custom">Content</Alert>,
|
|
87
|
+
);
|
|
88
|
+
const el = getByRole("status");
|
|
89
|
+
expect(el.className).toContain("strand-alert");
|
|
90
|
+
expect(el.className).toContain("custom");
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*! Strand UI | MIT License | dillingerstaffing.com */
|
|
2
|
+
|
|
3
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
4
|
+
import { forwardRef } from "preact/compat";
|
|
5
|
+
|
|
6
|
+
export interface AlertProps
|
|
7
|
+
extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "status"> {
|
|
8
|
+
/** Visual status of the alert */
|
|
9
|
+
status?: "info" | "success" | "warning" | "error";
|
|
10
|
+
/** Show dismiss button */
|
|
11
|
+
dismissible?: boolean;
|
|
12
|
+
/** Called when dismiss button is clicked */
|
|
13
|
+
onDismiss?: () => void;
|
|
14
|
+
/** Alert content */
|
|
15
|
+
children?: ComponentChildren;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
status = "info",
|
|
22
|
+
dismissible = false,
|
|
23
|
+
onDismiss,
|
|
24
|
+
className = "",
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
},
|
|
28
|
+
ref,
|
|
29
|
+
) => {
|
|
30
|
+
const role =
|
|
31
|
+
status === "error" || status === "warning" ? "alert" : "status";
|
|
32
|
+
|
|
33
|
+
const classes = [
|
|
34
|
+
"strand-alert",
|
|
35
|
+
`strand-alert--${status}`,
|
|
36
|
+
className,
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(" ");
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div ref={ref} className={classes} role={role} {...rest}>
|
|
43
|
+
<div className="strand-alert__content">{children}</div>
|
|
44
|
+
{dismissible && (
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
className="strand-alert__dismiss"
|
|
48
|
+
aria-label="Dismiss"
|
|
49
|
+
onClick={onDismiss}
|
|
50
|
+
>
|
|
51
|
+
×
|
|
52
|
+
</button>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
Alert.displayName = "Alert";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*! Strand UI | MIT License | dillingerstaffing.com */
|
|
2
|
+
|
|
3
|
+
/* ── Base ── */
|
|
4
|
+
.strand-avatar {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
border-radius: var(--strand-radius-full);
|
|
9
|
+
background: var(--strand-surface-recessed);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
font-family: var(--strand-font-sans);
|
|
13
|
+
font-weight: var(--strand-weight-medium);
|
|
14
|
+
color: var(--strand-gray-600);
|
|
15
|
+
user-select: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ── Image ── */
|
|
19
|
+
.strand-avatar__img {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
object-fit: cover;
|
|
23
|
+
border-radius: var(--strand-radius-full);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ── Initials ── */
|
|
27
|
+
.strand-avatar__initials {
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
line-height: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* ── Sizes ── */
|
|
33
|
+
.strand-avatar--sm {
|
|
34
|
+
width: 32px;
|
|
35
|
+
height: 32px;
|
|
36
|
+
font-size: var(--strand-text-xs);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.strand-avatar--md {
|
|
40
|
+
width: 40px;
|
|
41
|
+
height: 40px;
|
|
42
|
+
font-size: var(--strand-text-sm);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.strand-avatar--lg {
|
|
46
|
+
width: 48px;
|
|
47
|
+
height: 48px;
|
|
48
|
+
font-size: var(--strand-text-base);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.strand-avatar--xl {
|
|
52
|
+
width: 64px;
|
|
53
|
+
height: 64px;
|
|
54
|
+
font-size: var(--strand-text-lg);
|
|
55
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/preact";
|
|
3
|
+
import { Avatar } from "./Avatar.js";
|
|
4
|
+
|
|
5
|
+
describe("Avatar", () => {
|
|
6
|
+
// ── Image mode ──
|
|
7
|
+
|
|
8
|
+
it("renders image when src is provided", () => {
|
|
9
|
+
const { container } = render(
|
|
10
|
+
<Avatar src="https://example.com/photo.jpg" alt="Jane Doe" />,
|
|
11
|
+
);
|
|
12
|
+
const img = container.querySelector("img");
|
|
13
|
+
expect(img).toBeTruthy();
|
|
14
|
+
expect(img?.getAttribute("src")).toBe("https://example.com/photo.jpg");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("sets alt text on image", () => {
|
|
18
|
+
const { container } = render(
|
|
19
|
+
<Avatar src="https://example.com/photo.jpg" alt="Jane Doe" />,
|
|
20
|
+
);
|
|
21
|
+
const img = container.querySelector("img");
|
|
22
|
+
expect(img?.getAttribute("alt")).toBe("Jane Doe");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// ── Initials mode ──
|
|
26
|
+
|
|
27
|
+
it("shows initials when no src is provided", () => {
|
|
28
|
+
const { container } = render(<Avatar initials="jd" />);
|
|
29
|
+
const initialsEl = container.querySelector(".strand-avatar__initials");
|
|
30
|
+
expect(initialsEl).toBeTruthy();
|
|
31
|
+
expect(initialsEl?.textContent).toBe("JD");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("initials are uppercase", () => {
|
|
35
|
+
const { container } = render(<Avatar initials="ab" />);
|
|
36
|
+
const initialsEl = container.querySelector(".strand-avatar__initials");
|
|
37
|
+
expect(initialsEl?.textContent).toBe("AB");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("truncates initials to 2 characters", () => {
|
|
41
|
+
const { container } = render(<Avatar initials="abc" />);
|
|
42
|
+
const initialsEl = container.querySelector(".strand-avatar__initials");
|
|
43
|
+
expect(initialsEl?.textContent).toBe("AB");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// ── Fallback ──
|
|
47
|
+
|
|
48
|
+
it("falls back to initials on image error", () => {
|
|
49
|
+
const { container } = render(
|
|
50
|
+
<Avatar src="https://example.com/broken.jpg" initials="jd" alt="Jane" />,
|
|
51
|
+
);
|
|
52
|
+
const img = container.querySelector("img");
|
|
53
|
+
expect(img).toBeTruthy();
|
|
54
|
+
|
|
55
|
+
fireEvent.error(img!);
|
|
56
|
+
|
|
57
|
+
const initialsEl = container.querySelector(".strand-avatar__initials");
|
|
58
|
+
expect(initialsEl).toBeTruthy();
|
|
59
|
+
expect(initialsEl?.textContent).toBe("JD");
|
|
60
|
+
expect(container.querySelector("img")).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ── Sizes ──
|
|
64
|
+
|
|
65
|
+
it("applies md size class by default", () => {
|
|
66
|
+
const { container } = render(<Avatar initials="A" />);
|
|
67
|
+
expect(container.firstElementChild?.className).toContain(
|
|
68
|
+
"strand-avatar--md",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("applies sm size class", () => {
|
|
73
|
+
const { container } = render(<Avatar initials="A" size="sm" />);
|
|
74
|
+
expect(container.firstElementChild?.className).toContain(
|
|
75
|
+
"strand-avatar--sm",
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("applies lg size class", () => {
|
|
80
|
+
const { container } = render(<Avatar initials="A" size="lg" />);
|
|
81
|
+
expect(container.firstElementChild?.className).toContain(
|
|
82
|
+
"strand-avatar--lg",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("applies xl size class", () => {
|
|
87
|
+
const { container } = render(<Avatar initials="A" size="xl" />);
|
|
88
|
+
expect(container.firstElementChild?.className).toContain(
|
|
89
|
+
"strand-avatar--xl",
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// ── Shape ──
|
|
94
|
+
|
|
95
|
+
it("has circular shape class", () => {
|
|
96
|
+
const { container } = render(<Avatar initials="A" />);
|
|
97
|
+
expect(container.firstElementChild?.className).toContain("strand-avatar");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// ── Custom className ──
|
|
101
|
+
|
|
102
|
+
it("merges custom className", () => {
|
|
103
|
+
const { container } = render(<Avatar initials="A" className="custom" />);
|
|
104
|
+
const el = container.firstElementChild;
|
|
105
|
+
expect(el?.className).toContain("strand-avatar");
|
|
106
|
+
expect(el?.className).toContain("custom");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ── Accessibility ──
|
|
110
|
+
|
|
111
|
+
it("has role img and aria-label", () => {
|
|
112
|
+
const { container } = render(<Avatar initials="JD" alt="Jane Doe" />);
|
|
113
|
+
const el = container.firstElementChild;
|
|
114
|
+
expect(el?.getAttribute("role")).toBe("img");
|
|
115
|
+
expect(el?.getAttribute("aria-label")).toBe("Jane Doe");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("uses initials for aria-label when no alt", () => {
|
|
119
|
+
const { container } = render(<Avatar initials="jd" />);
|
|
120
|
+
const el = container.firstElementChild;
|
|
121
|
+
expect(el?.getAttribute("aria-label")).toBe("JD");
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*! Strand UI | MIT License | dillingerstaffing.com */
|
|
2
|
+
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import { forwardRef } from "preact/compat";
|
|
5
|
+
import { useState, useCallback } from "preact/hooks";
|
|
6
|
+
|
|
7
|
+
export interface AvatarProps
|
|
8
|
+
extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "size"> {
|
|
9
|
+
/** Image URL */
|
|
10
|
+
src?: string;
|
|
11
|
+
/** Alt text for image */
|
|
12
|
+
alt?: string;
|
|
13
|
+
/** Fallback initials (1-2 characters) */
|
|
14
|
+
initials?: string;
|
|
15
|
+
/** Avatar size */
|
|
16
|
+
size?: "sm" | "md" | "lg" | "xl";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Avatar = forwardRef<HTMLDivElement, AvatarProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
src,
|
|
23
|
+
alt = "",
|
|
24
|
+
initials = "",
|
|
25
|
+
size = "md",
|
|
26
|
+
className = "",
|
|
27
|
+
...rest
|
|
28
|
+
},
|
|
29
|
+
ref,
|
|
30
|
+
) => {
|
|
31
|
+
const [imgError, setImgError] = useState(false);
|
|
32
|
+
|
|
33
|
+
const handleError = useCallback(() => {
|
|
34
|
+
setImgError(true);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const showImage = src && !imgError;
|
|
38
|
+
const displayInitials = initials.slice(0, 2).toUpperCase();
|
|
39
|
+
|
|
40
|
+
const classes = [
|
|
41
|
+
"strand-avatar",
|
|
42
|
+
`strand-avatar--${size}`,
|
|
43
|
+
className,
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join(" ");
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div ref={ref} className={classes} role="img" aria-label={alt || displayInitials} {...rest}>
|
|
50
|
+
{showImage ? (
|
|
51
|
+
<img
|
|
52
|
+
className="strand-avatar__img"
|
|
53
|
+
src={src}
|
|
54
|
+
alt={alt}
|
|
55
|
+
onError={handleError}
|
|
56
|
+
/>
|
|
57
|
+
) : (
|
|
58
|
+
<span className="strand-avatar__initials" aria-hidden="true">
|
|
59
|
+
{displayInitials}
|
|
60
|
+
</span>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
Avatar.displayName = "Avatar";
|