@dillingerstaffing/strand-svelte 0.5.0 → 0.6.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.
- package/dist/css/strand-ui.css +49 -38
- package/dist/index.js +1817 -1789
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Alert/Alert.svelte +10 -0
- package/src/components/Alert/Alert.test.ts +28 -0
- package/src/components/Toast/Toast.svelte +10 -0
- package/src/components/Toast/Toast.test.ts +28 -0
- package/src/components/Toast/ToastProvider.svelte +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dillingerstaffing/strand-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Strand UI - Svelte component library built on the Strand Design Language",
|
|
5
5
|
"author": "Dillinger Staffing <engineering@dillingerstaffing.com> (https://dillingerstaffing.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"svelte": "^4.0.0 || ^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@dillingerstaffing/strand": "^0.
|
|
58
|
+
"@dillingerstaffing/strand": "^0.6.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
@@ -13,9 +13,19 @@
|
|
|
13
13
|
'strand-alert',
|
|
14
14
|
`strand-alert--${status}`,
|
|
15
15
|
].filter(Boolean).join(' ')
|
|
16
|
+
|
|
17
|
+
const statusLabels: Record<string, string> = {
|
|
18
|
+
info: 'INFO',
|
|
19
|
+
success: 'COMPLETE',
|
|
20
|
+
warning: 'WARNING',
|
|
21
|
+
error: 'ERROR',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$: statusLabel = statusLabels[status] ?? status.toUpperCase()
|
|
16
25
|
</script>
|
|
17
26
|
|
|
18
27
|
<div class={classes} {role} {...$$restProps}>
|
|
28
|
+
<span class="strand-alert__status">{statusLabel}</span>
|
|
19
29
|
<div class="strand-alert__content">
|
|
20
30
|
<slot />
|
|
21
31
|
</div>
|
|
@@ -61,4 +61,32 @@ describe('Alert', () => {
|
|
|
61
61
|
const { container } = render(Alert)
|
|
62
62
|
expect(container.querySelector('.strand-alert__content')).toBeInTheDocument()
|
|
63
63
|
})
|
|
64
|
+
|
|
65
|
+
it('renders status prefix for info', () => {
|
|
66
|
+
const { container } = render(Alert, { props: { status: 'info' } })
|
|
67
|
+
const status = container.querySelector('.strand-alert__status')
|
|
68
|
+
expect(status).toBeInTheDocument()
|
|
69
|
+
expect(status).toHaveTextContent('INFO')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('renders status prefix for success as COMPLETE', () => {
|
|
73
|
+
const { container } = render(Alert, { props: { status: 'success' } })
|
|
74
|
+
const status = container.querySelector('.strand-alert__status')
|
|
75
|
+
expect(status).toBeInTheDocument()
|
|
76
|
+
expect(status).toHaveTextContent('COMPLETE')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('renders status prefix for warning', () => {
|
|
80
|
+
const { container } = render(Alert, { props: { status: 'warning' } })
|
|
81
|
+
const status = container.querySelector('.strand-alert__status')
|
|
82
|
+
expect(status).toBeInTheDocument()
|
|
83
|
+
expect(status).toHaveTextContent('WARNING')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('renders status prefix for error', () => {
|
|
87
|
+
const { container } = render(Alert, { props: { status: 'error' } })
|
|
88
|
+
const status = container.querySelector('.strand-alert__status')
|
|
89
|
+
expect(status).toBeInTheDocument()
|
|
90
|
+
expect(status).toHaveTextContent('ERROR')
|
|
91
|
+
})
|
|
64
92
|
})
|
|
@@ -14,9 +14,19 @@
|
|
|
14
14
|
'strand-toast',
|
|
15
15
|
`strand-toast--${status}`,
|
|
16
16
|
].filter(Boolean).join(' ')
|
|
17
|
+
|
|
18
|
+
const statusLabels: Record<string, string> = {
|
|
19
|
+
info: 'INFO',
|
|
20
|
+
success: 'COMPLETE',
|
|
21
|
+
warning: 'WARNING',
|
|
22
|
+
error: 'ERROR',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$: statusLabel = statusLabels[status] ?? status.toUpperCase()
|
|
17
26
|
</script>
|
|
18
27
|
|
|
19
28
|
<div class={classes} role="status" aria-live={isUrgent ? 'assertive' : 'polite'} {...$$restProps}>
|
|
29
|
+
<span class="strand-toast__status">{statusLabel}</span>
|
|
20
30
|
<span class="strand-toast__message">{message}</span>
|
|
21
31
|
<button
|
|
22
32
|
type="button"
|
|
@@ -57,4 +57,32 @@ describe('Toast', () => {
|
|
|
57
57
|
await fireEvent.click(container.querySelector('.strand-toast__dismiss')!)
|
|
58
58
|
expect(ondismiss).toHaveBeenCalled()
|
|
59
59
|
})
|
|
60
|
+
|
|
61
|
+
it('renders status prefix for info', () => {
|
|
62
|
+
const { container } = render(Toast, { props: { message: 'Note', status: 'info' } })
|
|
63
|
+
const status = container.querySelector('.strand-toast__status')
|
|
64
|
+
expect(status).toBeInTheDocument()
|
|
65
|
+
expect(status).toHaveTextContent('INFO')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('renders status prefix for success as COMPLETE', () => {
|
|
69
|
+
const { container } = render(Toast, { props: { message: 'OK', status: 'success' } })
|
|
70
|
+
const status = container.querySelector('.strand-toast__status')
|
|
71
|
+
expect(status).toBeInTheDocument()
|
|
72
|
+
expect(status).toHaveTextContent('COMPLETE')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('renders status prefix for warning', () => {
|
|
76
|
+
const { container } = render(Toast, { props: { message: 'Warn', status: 'warning' } })
|
|
77
|
+
const status = container.querySelector('.strand-toast__status')
|
|
78
|
+
expect(status).toBeInTheDocument()
|
|
79
|
+
expect(status).toHaveTextContent('WARNING')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('renders status prefix for error', () => {
|
|
83
|
+
const { container } = render(Toast, { props: { message: 'Fail', status: 'error' } })
|
|
84
|
+
const status = container.querySelector('.strand-toast__status')
|
|
85
|
+
expect(status).toBeInTheDocument()
|
|
86
|
+
expect(status).toHaveTextContent('ERROR')
|
|
87
|
+
})
|
|
60
88
|
})
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
return status === 'error' || status === 'warning'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const statusLabels: Record<string, string> = {
|
|
20
|
+
info: 'INFO',
|
|
21
|
+
success: 'COMPLETE',
|
|
22
|
+
warning: 'WARNING',
|
|
23
|
+
error: 'ERROR',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function statusLabel(status: string): string {
|
|
27
|
+
return statusLabels[status] ?? status.toUpperCase()
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
onDestroy(() => {
|
|
20
31
|
unsubscribe()
|
|
21
32
|
})
|
|
@@ -30,6 +41,7 @@
|
|
|
30
41
|
role="status"
|
|
31
42
|
aria-live={isUrgent(entry.status) ? 'assertive' : 'polite'}
|
|
32
43
|
>
|
|
44
|
+
<span class="strand-toast__status">{statusLabel(entry.status)}</span>
|
|
33
45
|
<span class="strand-toast__message">{entry.message}</span>
|
|
34
46
|
<button
|
|
35
47
|
type="button"
|