@papillonarts/components 0.8.0 → 0.10.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/build/index.ts +1 -0
- package/build/primer/Alert/Alert.mdx +88 -0
- package/build/primer/Alert/Alert.prop.ts +45 -0
- package/build/primer/Alert/Alert.tsx +101 -0
- package/build/primer/Alert/__tests__/Alert.int.story.tsx +86 -0
- package/build/primer/Alert/__tests__/Alert.int.test.ts +37 -0
- package/build/primer/Alert/index.ts +2 -0
- package/build/primer/Blankslate/Blankslate.mdx +57 -0
- package/build/primer/Blankslate/Blankslate.prop.ts +26 -0
- package/build/primer/Blankslate/Blankslate.tsx +26 -0
- package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +43 -0
- package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +29 -0
- package/build/primer/Blankslate/index.ts +2 -0
- package/build/primer/Breadcrumb/Breadcrumb.mdx +23 -0
- package/build/primer/Breadcrumb/Breadcrumb.prop.ts +28 -0
- package/build/primer/Breadcrumb/Breadcrumb.tsx +57 -0
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +40 -0
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +40 -0
- package/build/primer/Breadcrumb/index.ts +2 -0
- package/build/primer/Button/Button.mdx +239 -0
- package/build/primer/Button/Button.prop.ts +77 -0
- package/build/primer/Button/Button.tsx +91 -0
- package/build/primer/Button/__tests__/Button.int.story.tsx +173 -0
- package/build/primer/Button/__tests__/Button.int.test.ts +191 -0
- package/build/primer/Button/index.ts +2 -0
- package/build/primer/Dropdown/Dropdown.mdx +19 -0
- package/build/primer/Dropdown/Dropdown.prop.ts +33 -0
- package/build/primer/Dropdown/Dropdown.tsx +102 -0
- package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +43 -0
- package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +53 -0
- package/build/primer/Dropdown/index.ts +2 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +5 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.tsx +35 -0
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +23 -0
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +9 -0
- package/build/primer/ErrorBoundary/index.ts +1 -0
- package/build/primer/Form/Checkbox/Checkbox.prop.ts +34 -0
- package/build/primer/Form/Checkbox/Checkbox.tsx +40 -0
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +50 -0
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +23 -0
- package/build/primer/Form/Checkbox/index.ts +2 -0
- package/build/primer/Form/Input/Input.prop.ts +43 -0
- package/build/primer/Form/Input/Input.tsx +43 -0
- package/build/primer/Form/Input/__tests__/Input.int.story.tsx +54 -0
- package/build/primer/Form/Input/__tests__/Input.int.test.ts +15 -0
- package/build/primer/Form/Input/index.ts +2 -0
- package/build/primer/Form/Radio/Radio.prop.ts +30 -0
- package/build/primer/Form/Radio/Radio.tsx +38 -0
- package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +42 -0
- package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +13 -0
- package/build/primer/Form/Radio/index.ts +2 -0
- package/build/primer/Form/index.ts +19 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +21 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.tsx +68 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +289 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +27 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +9 -0
- package/build/primer/Grid/DisplayTable/index.ts +1 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +59 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.tsx +274 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +289 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +146 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +46 -0
- package/build/primer/Grid/FlexGrid/index.ts +2 -0
- package/build/primer/Grid/index.ts +9 -0
- package/build/primer/Icon/Icon.part.ts +1289 -0
- package/build/primer/Icon/Icon.prop.ts +1337 -0
- package/build/primer/Icon/Icon.tsx +49 -0
- package/build/primer/Icon/__tests__/Icon.int.story.tsx +58 -0
- package/build/primer/Icon/__tests__/Icon.int.test.ts +13 -0
- package/build/primer/Icon/index.ts +2 -0
- package/build/primer/Label/Label.mdx +13 -0
- package/build/primer/Label/Label.prop.ts +31 -0
- package/build/primer/Label/Label.tsx +27 -0
- package/build/primer/Label/__tests__/Label.int.story.tsx +19 -0
- package/build/primer/Label/__tests__/Label.int.test.ts +9 -0
- package/build/primer/Label/index.ts +1 -0
- package/build/primer/Loader/Loader.mdx +31 -0
- package/build/primer/Loader/Loader.prop.ts +16 -0
- package/build/primer/Loader/Loader.tsx +43 -0
- package/build/primer/Loader/__tests__/Loader.int.story.tsx +34 -0
- package/build/primer/Loader/__tests__/Loader.int.test.ts +21 -0
- package/build/primer/Loader/index.ts +2 -0
- package/build/primer/Navigation/Menu/Menu.prop.ts +26 -0
- package/build/primer/Navigation/Menu/Menu.tsx +42 -0
- package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +55 -0
- package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +57 -0
- package/build/primer/Navigation/Menu/index.ts +1 -0
- package/build/primer/Navigation/TabNav/TabNav.prop.ts +39 -0
- package/build/primer/Navigation/TabNav/TabNav.tsx +105 -0
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +168 -0
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +55 -0
- package/build/primer/Navigation/TabNav/index.ts +2 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +41 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +106 -0
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +140 -0
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +81 -0
- package/build/primer/Navigation/UnderlineNav/index.ts +2 -0
- package/build/primer/Navigation/index.ts +12 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +53 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +71 -0
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +48 -0
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +15 -0
- package/build/primer/Pagination/PreviousNext/index.ts +2 -0
- package/build/primer/Pagination/index.ts +6 -0
- package/build/primer/Popover/Popover.mdx +190 -0
- package/build/primer/Popover/Popover.prop.ts +49 -0
- package/build/primer/Popover/Popover.tsx +80 -0
- package/build/primer/Popover/__tests__/Popover.int.story.tsx +216 -0
- package/build/primer/Popover/__tests__/Popover.int.test.ts +71 -0
- package/build/primer/Popover/index.ts +2 -0
- package/build/primer/Progress/Progress.mdx +31 -0
- package/build/primer/Progress/Progress.prop.ts +16 -0
- package/build/primer/Progress/Progress.tsx +19 -0
- package/build/primer/Progress/__tests__/Progress.int.story.tsx +28 -0
- package/build/primer/Progress/__tests__/Progress.int.test.ts +17 -0
- package/build/primer/Progress/index.ts +2 -0
- package/build/primer/Select/Select.mdx +19 -0
- package/build/primer/Select/Select.prop.ts +24 -0
- package/build/primer/Select/Select.tsx +58 -0
- package/build/primer/Select/__tests__/Select.int.story.tsx +38 -0
- package/build/primer/Select/__tests__/Select.int.test.ts +42 -0
- package/build/primer/Select/index.ts +2 -0
- package/build/primer/SelectMenu/SelectMenu.mdx +13 -0
- package/build/primer/SelectMenu/SelectMenu.prop.ts +25 -0
- package/build/primer/SelectMenu/SelectMenu.tsx +68 -0
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +50 -0
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +56 -0
- package/build/primer/SelectMenu/index.ts +1 -0
- package/build/primer/Subhead/Subhead.mdx +20 -0
- package/build/primer/Subhead/Subhead.prop.ts +10 -0
- package/build/primer/Subhead/Subhead.tsx +15 -0
- package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +23 -0
- package/build/primer/Subhead/__tests__/Subhead.int.test.ts +13 -0
- package/build/primer/Subhead/index.ts +1 -0
- package/build/primer/Toast/Toast.prop.ts +21 -0
- package/build/primer/Toast/Toast.tsx +38 -0
- package/build/primer/Toast/__tests__/Toast.int.story.tsx +50 -0
- package/build/primer/Toast/__tests__/Toast.int.test.ts +25 -0
- package/build/primer/Toast/index.ts +2 -0
- package/build/primer/index.ts +83 -0
- package/package.json +4 -4
- package/build/index.js +0 -12
- package/build/primer/Alert/Alert.js +0 -121
- package/build/primer/Alert/Alert.prop.js +0 -38
- package/build/primer/Alert/index.js +0 -19
- package/build/primer/Blankslate/Blankslate.js +0 -31
- package/build/primer/Blankslate/Blankslate.prop.js +0 -26
- package/build/primer/Blankslate/index.js +0 -19
- package/build/primer/Breadcrumb/Breadcrumb.js +0 -74
- package/build/primer/Breadcrumb/Breadcrumb.prop.js +0 -29
- package/build/primer/Breadcrumb/index.js +0 -19
- package/build/primer/Button/Button.js +0 -99
- package/build/primer/Button/Button.prop.js +0 -67
- package/build/primer/Button/index.js +0 -49
- package/build/primer/Dropdown/Dropdown.js +0 -104
- package/build/primer/Dropdown/Dropdown.prop.js +0 -34
- package/build/primer/Dropdown/index.js +0 -19
- package/build/primer/ErrorBoundary/ErrorBoundary.js +0 -59
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +0 -11
- package/build/primer/ErrorBoundary/index.js +0 -12
- package/build/primer/Form/Checkbox/Checkbox.js +0 -49
- package/build/primer/Form/Checkbox/Checkbox.prop.js +0 -36
- package/build/primer/Form/Checkbox/index.js +0 -19
- package/build/primer/Form/Input/Input.js +0 -56
- package/build/primer/Form/Input/Input.prop.js +0 -43
- package/build/primer/Form/Input/index.js +0 -25
- package/build/primer/Form/Radio/Radio.js +0 -48
- package/build/primer/Form/Radio/Radio.prop.js +0 -34
- package/build/primer/Form/Radio/index.js +0 -19
- package/build/primer/Form/index.js +0 -24
- package/build/primer/Grid/DisplayTable/DisplayTable.js +0 -58
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +0 -18
- package/build/primer/Grid/DisplayTable/index.js +0 -12
- package/build/primer/Grid/FlexGrid/FlexGrid.js +0 -244
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +0 -49
- package/build/primer/Grid/FlexGrid/index.js +0 -25
- package/build/primer/Grid/index.js +0 -14
- package/build/primer/Icon/Icon.js +0 -70
- package/build/primer/Icon/Icon.part.js +0 -1295
- package/build/primer/Icon/Icon.prop.js +0 -689
- package/build/primer/Icon/index.js +0 -25
- package/build/primer/Label/Label.js +0 -31
- package/build/primer/Label/Label.prop.js +0 -34
- package/build/primer/Label/index.js +0 -12
- package/build/primer/Loader/Loader.js +0 -65
- package/build/primer/Loader/Loader.prop.js +0 -21
- package/build/primer/Loader/index.js +0 -19
- package/build/primer/Navigation/Menu/Menu.js +0 -70
- package/build/primer/Navigation/Menu/Menu.prop.js +0 -28
- package/build/primer/Navigation/Menu/index.js +0 -12
- package/build/primer/Navigation/TabNav/TabNav.js +0 -125
- package/build/primer/Navigation/TabNav/TabNav.prop.js +0 -36
- package/build/primer/Navigation/TabNav/index.js +0 -19
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +0 -121
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +0 -41
- package/build/primer/Navigation/UnderlineNav/index.js +0 -25
- package/build/primer/Navigation/index.js +0 -17
- package/build/primer/Pagination/PreviousNext/PreviousNext.js +0 -76
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +0 -56
- package/build/primer/Pagination/PreviousNext/index.js +0 -19
- package/build/primer/Pagination/index.js +0 -11
- package/build/primer/Popover/Popover.js +0 -63
- package/build/primer/Popover/Popover.prop.js +0 -41
- package/build/primer/Popover/index.js +0 -25
- package/build/primer/Progress/Progress.js +0 -31
- package/build/primer/Progress/Progress.prop.js +0 -21
- package/build/primer/Progress/index.js +0 -19
- package/build/primer/Select/Select.js +0 -66
- package/build/primer/Select/Select.prop.js +0 -27
- package/build/primer/Select/index.js +0 -19
- package/build/primer/SelectMenu/SelectMenu.js +0 -95
- package/build/primer/SelectMenu/SelectMenu.prop.js +0 -26
- package/build/primer/SelectMenu/index.js +0 -12
- package/build/primer/Subhead/Subhead.js +0 -27
- package/build/primer/Subhead/Subhead.prop.js +0 -16
- package/build/primer/Subhead/index.js +0 -12
- package/build/primer/Toast/Toast.js +0 -55
- package/build/primer/Toast/Toast.prop.js +0 -26
- package/build/primer/Toast/index.js +0 -19
- package/build/primer/index.js +0 -87
- /package/build/primer/Form/Checkbox/{Checkbox.md → Checkbox.mdx} +0 -0
- /package/build/primer/Form/Checkbox/__tests__/__snapshots__/{Checkbox.int.test.js.snap → Checkbox.int.test.ts.snap} +0 -0
- /package/build/primer/Form/Input/{Input.md → Input.mdx} +0 -0
- /package/build/primer/Form/Input/__tests__/__snapshots__/{Input.int.test.js.snap → Input.int.test.ts.snap} +0 -0
- /package/build/primer/Form/Radio/{Radio.md → Radio.mdx} +0 -0
- /package/build/primer/Form/Radio/__tests__/__snapshots__/{Radio.int.test.js.snap → Radio.int.test.ts.snap} +0 -0
- /package/build/primer/Grid/DisplayTable/{DisplayTable.md → DisplayTable.mdx} +0 -0
- /package/build/primer/Grid/DisplayTable/__tests__/__snapshots__/{DisplayTable.int.test.js.snap → DisplayTable.int.test.ts.snap} +0 -0
- /package/build/primer/Grid/FlexGrid/{FlexGrid.md → FlexGrid.mdx} +0 -0
- /package/build/primer/Grid/FlexGrid/__tests__/__snapshots__/{FlexGrid.int.test.js.snap → FlexGrid.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/Menu/{Menu.md → Menu.mdx} +0 -0
- /package/build/primer/Navigation/Menu/__tests__/__snapshots__/{Menu.int.test.js.snap → Menu.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/TabNav/{TabNav.md → TabNav.mdx} +0 -0
- /package/build/primer/Navigation/TabNav/__tests__/__snapshots__/{TabNav.int.test.js.snap → TabNav.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/UnderlineNav/{UnderlineNav.md → UnderlineNav.mdx} +0 -0
- /package/build/primer/Navigation/UnderlineNav/__tests__/__snapshots__/{UnderlineNav.int.test.js.snap → UnderlineNav.int.test.ts.snap} +0 -0
- /package/build/primer/Pagination/PreviousNext/{PreviousNext.md → PreviousNext.mdx} +0 -0
- /package/build/primer/Pagination/PreviousNext/__tests__/__snapshots__/{PreviousNext.int.test.js.snap → PreviousNext.int.test.ts.snap} +0 -0
package/build/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { primer } from './primer'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Alert
|
|
2
|
+
|
|
3
|
+
> Flash messages, or alerts, inform users of successful or pending actions. Use them sparingly. Don't show more than one at a time.
|
|
4
|
+
|
|
5
|
+
# Variants
|
|
6
|
+
|
|
7
|
+
> - Default,
|
|
8
|
+
> - Info, Warning, Error, Success
|
|
9
|
+
> - Consent, Consent with input
|
|
10
|
+
|
|
11
|
+
## Default
|
|
12
|
+
|
|
13
|
+
> Flash messages start off looking decently neutral—they're just light blue rounded rectangles.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Alert variant={alertVariant.info}>{children}</Alert>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Default Multiple Paragraphs
|
|
20
|
+
|
|
21
|
+
> You can put multiple paragraphs of text in a flash message—the last paragraph's bottom margin will be automatically override.
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Alert variant={alertVariant.default}>
|
|
25
|
+
<p>
|
|
26
|
+
This is a longer flash message in it's own paragraph. It ends up looking something like this. If we keep adding more text,
|
|
27
|
+
it'll eventually wrap to a new line.
|
|
28
|
+
</p>
|
|
29
|
+
<p>And this is another paragraph.</p>
|
|
30
|
+
</Alert>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Info
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
<Alert variant={alertVariant.info}>{children}</Alert>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Warning
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<Alert variant={alertVariant.warning}>{children}</Alert>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Error
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
<Alert variant={alertVariant.error}>{children}</Alert>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Success
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
<Alert variant={alertVariant.success}>{children}</Alert>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Consent
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
<Alert
|
|
61
|
+
variant={alertVariant.consent}
|
|
62
|
+
consent={{
|
|
63
|
+
action: {
|
|
64
|
+
approve: action('Approved'),
|
|
65
|
+
cancel: action('Cancelled'),
|
|
66
|
+
},
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</Alert>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Consent with input
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
<Alert
|
|
77
|
+
variant={alertVariant.consent}
|
|
78
|
+
consent={{
|
|
79
|
+
action: {
|
|
80
|
+
approve: action('Approved'),
|
|
81
|
+
cancel: action('Cancelled'),
|
|
82
|
+
},
|
|
83
|
+
withInput: true,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
87
|
+
</Alert>
|
|
88
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const alertVariant = {
|
|
2
|
+
default: 'default',
|
|
3
|
+
info: 'info',
|
|
4
|
+
warning: 'warning',
|
|
5
|
+
error: 'error',
|
|
6
|
+
success: 'success',
|
|
7
|
+
consent: 'consent',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const defaultProps = {
|
|
11
|
+
dataTest: null,
|
|
12
|
+
className: null,
|
|
13
|
+
variant: alertVariant.default,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ActionType {
|
|
17
|
+
approve?: (value?: string) => void
|
|
18
|
+
cancel?: (value?: string) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ConsentType {
|
|
22
|
+
action?: ActionType
|
|
23
|
+
withInput?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DataTestType {
|
|
27
|
+
default?: string
|
|
28
|
+
approve?: string
|
|
29
|
+
cancel?: string
|
|
30
|
+
value?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AlertProps {
|
|
34
|
+
dataTest?: DataTestType
|
|
35
|
+
className?: string
|
|
36
|
+
variant?:
|
|
37
|
+
| typeof alertVariant.default
|
|
38
|
+
| typeof alertVariant.info
|
|
39
|
+
| typeof alertVariant.warning
|
|
40
|
+
| typeof alertVariant.error
|
|
41
|
+
| typeof alertVariant.success
|
|
42
|
+
| typeof alertVariant.consent
|
|
43
|
+
children: React.ReactNode // https://react.dev/learn/typescript#typing-children
|
|
44
|
+
consent: ConsentType
|
|
45
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fragment } from 'react'
|
|
2
|
+
import { useState } from '@papillonarts/library/hooks'
|
|
3
|
+
import utilityStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
|
|
4
|
+
import cx from 'classnames'
|
|
5
|
+
import { AlertProps, defaultProps, alertVariant } from './Alert.prop'
|
|
6
|
+
import styles from './Alert.scss'
|
|
7
|
+
import buttonStyles from '../Button/Button.scss'
|
|
8
|
+
import { Input } from '../Form/Input'
|
|
9
|
+
import { Button, buttonVariant, buttonInputType, iconAlignment } from '../Button'
|
|
10
|
+
import { iconName } from '../Icon/Icon.prop'
|
|
11
|
+
import { Icon, iconSize } from '../Icon'
|
|
12
|
+
|
|
13
|
+
export function Alert({
|
|
14
|
+
dataTest = defaultProps.dataTest,
|
|
15
|
+
className = defaultProps.className,
|
|
16
|
+
variant = defaultProps.variant,
|
|
17
|
+
children,
|
|
18
|
+
consent,
|
|
19
|
+
}: AlertProps) {
|
|
20
|
+
const [consentValue, setConsentValue] = useState('')
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div data-test={dataTest?.default} className={className}>
|
|
24
|
+
<div className={cx(styles['flash-messages'])}>
|
|
25
|
+
<div
|
|
26
|
+
className={cx(styles.flash, {
|
|
27
|
+
[styles['flash-warn']]: variant === alertVariant.warning,
|
|
28
|
+
[styles['flash-error']]: variant === alertVariant.error,
|
|
29
|
+
[styles['flash-success']]: variant === alertVariant.success,
|
|
30
|
+
[styles['flash-consent']]: variant === alertVariant.consent,
|
|
31
|
+
})}
|
|
32
|
+
>
|
|
33
|
+
{consent && (
|
|
34
|
+
<Fragment>
|
|
35
|
+
<Button
|
|
36
|
+
dataTest={dataTest?.cancel}
|
|
37
|
+
className={cx(buttonStyles.btn, buttonStyles['btn-sm'], buttonStyles.primary, styles['flash-action'])}
|
|
38
|
+
text="Cancel"
|
|
39
|
+
icon={{ name: iconName.XCircleFill16, alignment: iconAlignment.left }}
|
|
40
|
+
variant={buttonVariant.default}
|
|
41
|
+
inputType={buttonInputType.submit}
|
|
42
|
+
onClick={() => {
|
|
43
|
+
consent?.action?.cancel()
|
|
44
|
+
setConsentValue('')
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
<Button
|
|
48
|
+
dataTest={dataTest?.approve}
|
|
49
|
+
className={cx(buttonStyles.btn, buttonStyles['btn-sm'], buttonStyles.primary, styles['flash-action'])}
|
|
50
|
+
text="Approve"
|
|
51
|
+
icon={{ name: iconName.CheckCircleFill16, alignment: iconAlignment.left }}
|
|
52
|
+
variant={buttonVariant.primary}
|
|
53
|
+
inputType={buttonInputType.submit}
|
|
54
|
+
autoFocus={consent?.withInput ? false : true} // eslint-disable-line
|
|
55
|
+
onClick={
|
|
56
|
+
consent?.withInput
|
|
57
|
+
? () => {
|
|
58
|
+
if (consentValue !== '') {
|
|
59
|
+
consent?.action?.approve(consentValue)
|
|
60
|
+
setConsentValue('')
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
: consent?.action?.approve
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
</Fragment>
|
|
67
|
+
)}
|
|
68
|
+
{variant === alertVariant.info && <Icon className={utilityStyles['mr-2']} icon={iconName.Info16} size={iconSize.small} />}
|
|
69
|
+
{variant === alertVariant.warning && !consent && (
|
|
70
|
+
<Icon className={utilityStyles['mr-2']} icon={iconName.Alert16} size={iconSize.small} />
|
|
71
|
+
)}
|
|
72
|
+
{variant === alertVariant.warning && consent && (
|
|
73
|
+
<Icon className={utilityStyles['mr-2']} icon={iconName.Question16} size={iconSize.small} />
|
|
74
|
+
)}
|
|
75
|
+
{variant === alertVariant.error && <Icon className={utilityStyles['mr-2']} icon={iconName.XCircle16} size={iconSize.small} />}
|
|
76
|
+
{variant === alertVariant.success && (
|
|
77
|
+
<Icon className={utilityStyles['mr-2']} icon={iconName.CheckCircle16} size={iconSize.small} />
|
|
78
|
+
)}
|
|
79
|
+
{variant === alertVariant.consent && <Icon className={utilityStyles['mr-2']} icon={iconName.Question16} size={iconSize.small} />}
|
|
80
|
+
{children}
|
|
81
|
+
{consent?.withInput && (
|
|
82
|
+
<Input
|
|
83
|
+
dataTest={dataTest?.value}
|
|
84
|
+
className={styles['flash-action']}
|
|
85
|
+
value={consentValue}
|
|
86
|
+
placeholder=""
|
|
87
|
+
ariaAttr={{ label: '' }}
|
|
88
|
+
onChange={(event) => {
|
|
89
|
+
setConsentValue(event.target.value)
|
|
90
|
+
}}
|
|
91
|
+
onKeyUp={(event) => {
|
|
92
|
+
setConsentValue(event.target.value)
|
|
93
|
+
}}
|
|
94
|
+
autoFocus={true} // eslint-disable-line
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://storybook.js.org/docs/configure/integration/typescript
|
|
2
|
+
|
|
3
|
+
import { action } from 'storybook/actions'
|
|
4
|
+
import { withTests } from '@storybook/addon-jest'
|
|
5
|
+
import { alertVariant } from '../Alert.prop'
|
|
6
|
+
import results from '../../../../../../.jest-test-results.json'
|
|
7
|
+
|
|
8
|
+
const children = 'Flash message goes here.'
|
|
9
|
+
|
|
10
|
+
const Alert =
|
|
11
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
12
|
+
? require('../../../index').primer.Alert.Alert
|
|
13
|
+
: require('../../../../build').primer.Alert.Alert
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Primer/Molecule/Alert',
|
|
17
|
+
component: Alert,
|
|
18
|
+
decorators: [withTests({ results })],
|
|
19
|
+
parameters: { jest: ['Alert.int.test.js'] },
|
|
20
|
+
excludeStories: ['custom'],
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function regular() {
|
|
24
|
+
return <Alert variant={alertVariant.default}>{children}</Alert>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function regularMultipleParagraphs() {
|
|
28
|
+
return (
|
|
29
|
+
<Alert variant={alertVariant.default}>
|
|
30
|
+
<p>
|
|
31
|
+
This is a longer flash message in it's own paragraph. It ends up looking something like this. If we keep adding more text,
|
|
32
|
+
it'll eventually wrap to a new line.
|
|
33
|
+
</p>
|
|
34
|
+
<p>And this is another paragraph.</p>
|
|
35
|
+
</Alert>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function info() {
|
|
40
|
+
return <Alert variant={alertVariant.info}>{children}</Alert>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function warning() {
|
|
44
|
+
return <Alert variant={alertVariant.warning}>{children}</Alert>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function error() {
|
|
48
|
+
return <Alert variant={alertVariant.error}>{children}</Alert>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function success() {
|
|
52
|
+
return <Alert variant={alertVariant.success}>{children}</Alert>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function consent() {
|
|
56
|
+
return (
|
|
57
|
+
<Alert
|
|
58
|
+
variant={alertVariant.consent}
|
|
59
|
+
consent={{
|
|
60
|
+
action: {
|
|
61
|
+
approve: action('Approved'),
|
|
62
|
+
cancel: action('Cancelled'),
|
|
63
|
+
},
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</Alert>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function consentWithInput() {
|
|
72
|
+
return (
|
|
73
|
+
<Alert
|
|
74
|
+
variant={alertVariant.consent}
|
|
75
|
+
consent={{
|
|
76
|
+
action: {
|
|
77
|
+
approve: action('Approved'),
|
|
78
|
+
cancel: action('Cancelled'),
|
|
79
|
+
},
|
|
80
|
+
withInput: true,
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
84
|
+
</Alert>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { regular, regularMultipleParagraphs, info, warning, error, success, consent, consentWithInput } from './Alert.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Alert />', () => {
|
|
4
|
+
describe('Render', () => {
|
|
5
|
+
test('must match regular()', () => {
|
|
6
|
+
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('must match regularMultipleParagraphs()', () => {
|
|
10
|
+
expect(global.renderToJSON(regularMultipleParagraphs())).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('must match info()', () => {
|
|
14
|
+
expect(global.renderToJSON(info())).toMatchSnapshot()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('must match warning()', () => {
|
|
18
|
+
expect(global.renderToJSON(warning())).toMatchSnapshot()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('must match error()', () => {
|
|
22
|
+
expect(global.renderToJSON(error())).toMatchSnapshot()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('must match success()', () => {
|
|
26
|
+
expect(global.renderToJSON(success())).toMatchSnapshot()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('must match consent()', () => {
|
|
30
|
+
expect(global.renderToJSON(consent())).toMatchSnapshot()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('must match consentWithInput()', () => {
|
|
34
|
+
expect(global.renderToJSON(consentWithInput())).toMatchSnapshot()
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Blankslate
|
|
2
|
+
|
|
3
|
+
> Blankslates are for when there is a lack of content within a page or section. Use them as placeholders to tell users why something isn't there. Be sure to provide an action to add content as well.
|
|
4
|
+
|
|
5
|
+
# Variants
|
|
6
|
+
|
|
7
|
+
> - Default
|
|
8
|
+
> - Narrow, Capped, Spacious
|
|
9
|
+
> - Large, No background
|
|
10
|
+
|
|
11
|
+
## Default
|
|
12
|
+
|
|
13
|
+
> Wrap some content in the outer .blankslate wrapper to give it the blankslate appearance.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Blankslate variant={blankslateVariant.default} heading={heading} text={text} />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Narrow
|
|
20
|
+
|
|
21
|
+
> Narrows the blankslate container to not occupy the entire available width.
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Blankslate variant={blankslateVariant.narrow} heading={heading} text={text} />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Capped
|
|
28
|
+
|
|
29
|
+
> Removes the border-radius on the top corners.
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<Blankslate variant={blankslateVariant.capped} heading={heading} text={text} />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Spacious
|
|
36
|
+
|
|
37
|
+
> Significantly increases the vertical padding.
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
<Blankslate variant={blankslateVariant.spacious} heading={heading} text={text} />
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Large
|
|
44
|
+
|
|
45
|
+
> Increases the size of the text in the blankslate
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
<Blankslate variant={blankslateVariant.large} heading={heading} text={text} />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## No background
|
|
52
|
+
|
|
53
|
+
> Removes the background-color and border.
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
<Blankslate hasCleanBackground={true} heading={heading} text={text} />
|
|
57
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const blankslateVariant = {
|
|
2
|
+
default: 'default',
|
|
3
|
+
narrow: 'narrow',
|
|
4
|
+
capped: 'capped',
|
|
5
|
+
spacious: 'spacious',
|
|
6
|
+
large: 'large',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const defaultProps = {
|
|
10
|
+
className: null,
|
|
11
|
+
variant: blankslateVariant.default,
|
|
12
|
+
hasCleanBackground: false,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BlankslateProps {
|
|
16
|
+
className?: string
|
|
17
|
+
heading: string
|
|
18
|
+
text: string
|
|
19
|
+
variant?:
|
|
20
|
+
| typeof blankslateVariant.default
|
|
21
|
+
| typeof blankslateVariant.narrow
|
|
22
|
+
| typeof blankslateVariant.capped
|
|
23
|
+
| typeof blankslateVariant.spacious
|
|
24
|
+
| typeof blankslateVariant.large
|
|
25
|
+
hasCleanBackground?: boolean
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import { BlankslateProps, defaultProps, blankslateVariant } from './Blankslate.prop'
|
|
3
|
+
import styles from './Blankslate.scss'
|
|
4
|
+
|
|
5
|
+
export function Blankslate({
|
|
6
|
+
className = defaultProps.className,
|
|
7
|
+
heading,
|
|
8
|
+
text,
|
|
9
|
+
variant = defaultProps.variant,
|
|
10
|
+
hasCleanBackground = defaultProps.hasCleanBackground,
|
|
11
|
+
}: BlankslateProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={cx(className, styles.blankslate, {
|
|
15
|
+
[styles['blankslate-narrow']]: variant === blankslateVariant.narrow,
|
|
16
|
+
[styles['blankslate-capped']]: (variant === blankslateVariant.capped) === true,
|
|
17
|
+
[styles['blankslate-spacious']]: variant === blankslateVariant.spacious,
|
|
18
|
+
[styles['blankslate-large']]: variant === blankslateVariant.large,
|
|
19
|
+
[styles['blankslate-clean-background']]: hasCleanBackground === true,
|
|
20
|
+
})}
|
|
21
|
+
>
|
|
22
|
+
<h3>{heading}</h3>
|
|
23
|
+
<p>{text}</p>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { withTests } from '@storybook/addon-jest'
|
|
2
|
+
import { blankslateVariant } from '../Blankslate.prop'
|
|
3
|
+
import results from '../../../../../../.jest-test-results.json'
|
|
4
|
+
|
|
5
|
+
const Blankslate =
|
|
6
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
7
|
+
? require('../../../index').primer.Blankslate.Blankslate
|
|
8
|
+
: require('../../../../build').primer.Blankslate.Blankslate
|
|
9
|
+
|
|
10
|
+
const heading = 'This is a blank slate'
|
|
11
|
+
const text = 'Use it to provide information when no dynamic content exists.'
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'Primer/Atom/Blankslate',
|
|
15
|
+
component: Blankslate,
|
|
16
|
+
decorators: [withTests({ results })],
|
|
17
|
+
parameters: { jest: ['Blankslate.int.test.js'] },
|
|
18
|
+
excludeStories: ['custom'],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function regular() {
|
|
22
|
+
return <Blankslate variant={blankslateVariant.default} heading={heading} text={text} />
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function narrow() {
|
|
26
|
+
return <Blankslate variant={blankslateVariant.narrow} heading={heading} text={text} />
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function capped() {
|
|
30
|
+
return <Blankslate variant={blankslateVariant.capped} heading={heading} text={text} />
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function spacious() {
|
|
34
|
+
return <Blankslate variant={blankslateVariant.spacious} heading={heading} text={text} />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function large() {
|
|
38
|
+
return <Blankslate variant={blankslateVariant.large} heading={heading} text={text} />
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function cleanBackground() {
|
|
42
|
+
return <Blankslate hasCleanBackground={true} heading={heading} text={text} />
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { regular, narrow, capped, spacious, large, cleanBackground } from './Blankslate.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Blankslate />', () => {
|
|
4
|
+
describe('Render', () => {
|
|
5
|
+
test('must match regular()', () => {
|
|
6
|
+
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('must match narrow()', () => {
|
|
10
|
+
expect(global.renderToJSON(narrow())).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('must match capped()', () => {
|
|
14
|
+
expect(global.renderToJSON(capped())).toMatchSnapshot()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('must match spacious()', () => {
|
|
18
|
+
expect(global.renderToJSON(spacious())).toMatchSnapshot()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('must match large()', () => {
|
|
22
|
+
expect(global.renderToJSON(large())).toMatchSnapshot()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('must match cleanBackground()', () => {
|
|
26
|
+
expect(global.renderToJSON(cleanBackground())).toMatchSnapshot()
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Breadcrumb
|
|
2
|
+
|
|
3
|
+
> Breadcrumbs are used to show taxonomical context on pages that are many levels deep in a site’s hierarchy. Breadcrumbs show and link to parent, grandparent, and sometimes great-grandparent pages. Breadcrumbs are most appropriate on pages that:
|
|
4
|
+
|
|
5
|
+
- Are many levels deep on a site
|
|
6
|
+
- Do not have a section-level navigation
|
|
7
|
+
- May need the ability to quickly go back to the previous (parent) page
|
|
8
|
+
|
|
9
|
+
# Variants
|
|
10
|
+
|
|
11
|
+
> - Default, Inactive
|
|
12
|
+
|
|
13
|
+
## Default
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Breadcrumb ariaAttr={ariaAttr} items={items} onClick={action('onClick')} />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Inactive
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<Breadcrumb ariaAttr={ariaAttr} items={items} onClick={action('onClick')} state={breadcrumbState.inactive} />
|
|
23
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const breadcrumbState = {
|
|
2
|
+
active: 'active',
|
|
3
|
+
inactive: 'inactive',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const defaultProps = {
|
|
7
|
+
className: null,
|
|
8
|
+
state: breadcrumbState.active,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AriaAttrType {
|
|
12
|
+
label: string
|
|
13
|
+
current: boolean | false | true | 'page' | 'step' | 'location' | 'date' | 'time'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ItemType {
|
|
17
|
+
href: string
|
|
18
|
+
text: string
|
|
19
|
+
isSelected: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BreadcrumbProps {
|
|
23
|
+
className?: string
|
|
24
|
+
ariaAttr: AriaAttrType
|
|
25
|
+
items: ItemType[]
|
|
26
|
+
onClick: (value) => void
|
|
27
|
+
state?: typeof breadcrumbState.active | typeof breadcrumbState.inactive
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
2
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
import { v1 as uuidv1 } from 'uuid'
|
|
5
|
+
import utilityStyles from '@papillonarts/css/build/primer/utilities/typography.scss'
|
|
6
|
+
import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
|
|
7
|
+
import { BreadcrumbProps, defaultProps, breadcrumbState } from './Breadcrumb.prop'
|
|
8
|
+
import styles from './Breadcrumb.scss'
|
|
9
|
+
|
|
10
|
+
export function Breadcrumb({ className = defaultProps.className, ariaAttr, items, onClick, state = defaultProps.state }: BreadcrumbProps) {
|
|
11
|
+
const indexItems = getIndexItems(items)
|
|
12
|
+
const { label, current } = ariaAttr
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<nav
|
|
16
|
+
className={cx(className, {
|
|
17
|
+
[styles['breadcrumb-inactive']]: state === breadcrumbState.inactive,
|
|
18
|
+
})}
|
|
19
|
+
aria-label={label}
|
|
20
|
+
>
|
|
21
|
+
<ol>
|
|
22
|
+
{indexItems.map((indexItem) => {
|
|
23
|
+
const { href, text, isSelected } = indexItem
|
|
24
|
+
|
|
25
|
+
const itemOtherProps = isSelected ? { ...{ 'aria-current': current } } : null
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<li
|
|
29
|
+
key={uuidv1()}
|
|
30
|
+
onClick={(e) => {
|
|
31
|
+
e.preventDefault()
|
|
32
|
+
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
|
|
33
|
+
onClick({
|
|
34
|
+
active: text,
|
|
35
|
+
ariaAttr,
|
|
36
|
+
items: newIndexItems.map(
|
|
37
|
+
(newIndexItem) => (({ href, text, isSelected }) => ({ href, text, isSelected }))(newIndexItem), // eslint-disable-line
|
|
38
|
+
),
|
|
39
|
+
})
|
|
40
|
+
}}
|
|
41
|
+
className={
|
|
42
|
+
!isSelected
|
|
43
|
+
? cx(styles['breadcrumb-item'])
|
|
44
|
+
: cx(styles['breadcrumb-item'], styles['breadcrumb-item-selected'], utilityStyles['text-gray'])
|
|
45
|
+
}
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
href={href}
|
|
48
|
+
{...itemOtherProps}
|
|
49
|
+
>
|
|
50
|
+
{isSelected ? text : <a href={href}>{text}</a>}
|
|
51
|
+
</li>
|
|
52
|
+
)
|
|
53
|
+
})}
|
|
54
|
+
</ol>
|
|
55
|
+
</nav>
|
|
56
|
+
)
|
|
57
|
+
}
|