@papillonarts/components 0.9.0 → 0.11.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.js +12 -0
- package/build/primer/Alert/Alert.js +122 -0
- package/build/primer/Alert/Alert.prop.js +19 -0
- package/build/primer/Alert/index.js +19 -0
- package/build/primer/Blankslate/Blankslate.js +30 -0
- package/build/primer/Blankslate/Blankslate.prop.js +18 -0
- package/build/primer/Blankslate/index.js +19 -0
- package/build/primer/Breadcrumb/Breadcrumb.js +75 -0
- package/build/primer/Breadcrumb/Breadcrumb.prop.js +14 -0
- package/build/primer/Breadcrumb/index.js +19 -0
- package/build/primer/Button/Button.js +108 -0
- package/build/primer/Button/Button.prop.js +48 -0
- package/build/primer/Button/index.js +49 -0
- package/build/primer/Dropdown/Dropdown.js +102 -0
- package/build/primer/Dropdown/Dropdown.prop.js +18 -0
- package/build/primer/Dropdown/index.js +19 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.js +59 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +7 -0
- package/build/primer/ErrorBoundary/index.js +12 -0
- package/build/primer/Form/Checkbox/Checkbox.js +48 -0
- package/build/primer/Form/Checkbox/Checkbox.prop.js +22 -0
- package/build/primer/Form/Checkbox/index.js +19 -0
- package/build/primer/Form/Input/Input.js +55 -0
- package/build/primer/Form/Input/Input.prop.js +27 -0
- package/build/primer/Form/Input/index.js +25 -0
- package/build/primer/Form/Radio/Radio.js +47 -0
- package/build/primer/Form/Radio/Radio.prop.js +22 -0
- package/build/primer/Form/Radio/index.js +19 -0
- package/build/primer/Form/index.js +24 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.js +57 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +11 -0
- package/build/primer/Grid/DisplayTable/index.js +12 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.js +249 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +28 -0
- package/build/primer/Grid/FlexGrid/index.js +25 -0
- package/build/primer/Grid/index.js +14 -0
- package/build/primer/Icon/Icon.js +70 -0
- package/build/primer/Icon/Icon.part.js +1295 -0
- package/build/primer/Icon/Icon.prop.js +678 -0
- package/build/primer/Icon/index.js +25 -0
- package/build/primer/Label/Label.js +30 -0
- package/build/primer/Label/Label.prop.js +26 -0
- package/build/primer/Label/index.js +12 -0
- package/build/primer/Loader/Loader.js +64 -0
- package/build/primer/Loader/Loader.prop.js +15 -0
- package/build/primer/Loader/index.js +19 -0
- package/build/primer/Navigation/Menu/Menu.js +69 -0
- package/build/primer/Navigation/Menu/Menu.prop.js +10 -0
- package/build/primer/Navigation/Menu/index.js +12 -0
- package/build/primer/Navigation/TabNav/TabNav.js +124 -0
- package/build/primer/Navigation/TabNav/TabNav.prop.js +16 -0
- package/build/primer/Navigation/TabNav/index.js +19 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +122 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +20 -0
- package/build/primer/Navigation/UnderlineNav/index.js +25 -0
- package/build/primer/Navigation/index.js +17 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.js +84 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +30 -0
- package/build/primer/Pagination/PreviousNext/index.js +19 -0
- package/build/primer/Pagination/index.js +11 -0
- package/build/primer/Popover/Popover.js +63 -0
- package/build/primer/Popover/Popover.prop.js +29 -0
- package/build/primer/Popover/index.js +25 -0
- package/build/primer/Progress/Progress.js +30 -0
- package/build/primer/Progress/Progress.prop.js +15 -0
- package/build/primer/Progress/index.js +19 -0
- package/build/primer/Select/Select.js +67 -0
- package/build/primer/Select/Select.prop.js +15 -0
- package/build/primer/Select/index.js +19 -0
- package/build/primer/SelectMenu/SelectMenu.js +94 -0
- package/build/primer/SelectMenu/SelectMenu.prop.js +10 -0
- package/build/primer/SelectMenu/index.js +12 -0
- package/build/primer/Subhead/Subhead.js +26 -0
- package/build/primer/Subhead/Subhead.prop.js +10 -0
- package/build/primer/Subhead/index.js +12 -0
- package/build/primer/Toast/Toast.js +54 -0
- package/build/primer/Toast/Toast.prop.js +18 -0
- package/build/primer/Toast/index.js +19 -0
- package/build/primer/index.js +87 -0
- package/package.json +5 -5
- package/build/index.ts +0 -1
- package/build/primer/Alert/Alert.prop.ts +0 -45
- package/build/primer/Alert/Alert.tsx +0 -101
- package/build/primer/Alert/__tests__/Alert.int.story.tsx +0 -86
- package/build/primer/Alert/__tests__/Alert.int.test.ts +0 -37
- package/build/primer/Alert/index.ts +0 -2
- package/build/primer/Blankslate/Blankslate.prop.ts +0 -26
- package/build/primer/Blankslate/Blankslate.tsx +0 -26
- package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +0 -43
- package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +0 -29
- package/build/primer/Blankslate/index.ts +0 -2
- package/build/primer/Breadcrumb/Breadcrumb.prop.ts +0 -28
- package/build/primer/Breadcrumb/Breadcrumb.tsx +0 -57
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +0 -40
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +0 -40
- package/build/primer/Breadcrumb/index.ts +0 -2
- package/build/primer/Button/Button.prop.ts +0 -77
- package/build/primer/Button/Button.tsx +0 -91
- package/build/primer/Button/__tests__/Button.int.story.tsx +0 -173
- package/build/primer/Button/__tests__/Button.int.test.ts +0 -191
- package/build/primer/Button/index.ts +0 -2
- package/build/primer/Dropdown/Dropdown.prop.ts +0 -33
- package/build/primer/Dropdown/Dropdown.tsx +0 -102
- package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +0 -43
- package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +0 -53
- package/build/primer/Dropdown/index.ts +0 -2
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +0 -5
- package/build/primer/ErrorBoundary/ErrorBoundary.tsx +0 -35
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +0 -23
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +0 -9
- package/build/primer/ErrorBoundary/index.ts +0 -1
- package/build/primer/Form/Checkbox/Checkbox.prop.ts +0 -34
- package/build/primer/Form/Checkbox/Checkbox.tsx +0 -40
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +0 -50
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +0 -23
- package/build/primer/Form/Checkbox/index.ts +0 -2
- package/build/primer/Form/Input/Input.prop.ts +0 -43
- package/build/primer/Form/Input/Input.tsx +0 -43
- package/build/primer/Form/Input/__tests__/Input.int.story.tsx +0 -54
- package/build/primer/Form/Input/__tests__/Input.int.test.ts +0 -15
- package/build/primer/Form/Input/index.ts +0 -2
- package/build/primer/Form/Radio/Radio.prop.ts +0 -30
- package/build/primer/Form/Radio/Radio.tsx +0 -38
- package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +0 -42
- package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +0 -13
- package/build/primer/Form/Radio/index.ts +0 -2
- package/build/primer/Form/index.ts +0 -19
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +0 -21
- package/build/primer/Grid/DisplayTable/DisplayTable.tsx +0 -68
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +0 -289
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +0 -27
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +0 -9
- package/build/primer/Grid/DisplayTable/index.ts +0 -1
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +0 -59
- package/build/primer/Grid/FlexGrid/FlexGrid.tsx +0 -274
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +0 -289
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +0 -146
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +0 -46
- package/build/primer/Grid/FlexGrid/index.ts +0 -2
- package/build/primer/Grid/index.ts +0 -9
- package/build/primer/Icon/Icon.part.ts +0 -1289
- package/build/primer/Icon/Icon.prop.ts +0 -1337
- package/build/primer/Icon/Icon.tsx +0 -49
- package/build/primer/Icon/__tests__/Icon.int.story.tsx +0 -58
- package/build/primer/Icon/__tests__/Icon.int.test.ts +0 -13
- package/build/primer/Icon/index.ts +0 -2
- package/build/primer/Label/Label.prop.ts +0 -31
- package/build/primer/Label/Label.tsx +0 -27
- package/build/primer/Label/__tests__/Label.int.story.tsx +0 -19
- package/build/primer/Label/__tests__/Label.int.test.ts +0 -9
- package/build/primer/Label/index.ts +0 -1
- package/build/primer/Loader/Loader.prop.ts +0 -16
- package/build/primer/Loader/Loader.tsx +0 -43
- package/build/primer/Loader/__tests__/Loader.int.story.tsx +0 -34
- package/build/primer/Loader/__tests__/Loader.int.test.ts +0 -21
- package/build/primer/Loader/index.ts +0 -2
- package/build/primer/Navigation/Menu/Menu.prop.ts +0 -26
- package/build/primer/Navigation/Menu/Menu.tsx +0 -42
- package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +0 -55
- package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +0 -57
- package/build/primer/Navigation/Menu/index.ts +0 -1
- package/build/primer/Navigation/TabNav/TabNav.prop.ts +0 -39
- package/build/primer/Navigation/TabNav/TabNav.tsx +0 -105
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +0 -168
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +0 -55
- package/build/primer/Navigation/TabNav/index.ts +0 -2
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +0 -41
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +0 -106
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +0 -140
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +0 -81
- package/build/primer/Navigation/UnderlineNav/index.ts +0 -2
- package/build/primer/Navigation/index.ts +0 -12
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +0 -53
- package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +0 -71
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +0 -48
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +0 -15
- package/build/primer/Pagination/PreviousNext/index.ts +0 -2
- package/build/primer/Pagination/index.ts +0 -6
- package/build/primer/Popover/Popover.prop.ts +0 -49
- package/build/primer/Popover/Popover.tsx +0 -80
- package/build/primer/Popover/__tests__/Popover.int.story.tsx +0 -216
- package/build/primer/Popover/__tests__/Popover.int.test.ts +0 -71
- package/build/primer/Popover/index.ts +0 -2
- package/build/primer/Progress/Progress.prop.ts +0 -16
- package/build/primer/Progress/Progress.tsx +0 -19
- package/build/primer/Progress/__tests__/Progress.int.story.tsx +0 -28
- package/build/primer/Progress/__tests__/Progress.int.test.ts +0 -17
- package/build/primer/Progress/index.ts +0 -2
- package/build/primer/Select/Select.prop.ts +0 -24
- package/build/primer/Select/Select.tsx +0 -58
- package/build/primer/Select/__tests__/Select.int.story.tsx +0 -38
- package/build/primer/Select/__tests__/Select.int.test.ts +0 -42
- package/build/primer/Select/index.ts +0 -2
- package/build/primer/SelectMenu/SelectMenu.prop.ts +0 -25
- package/build/primer/SelectMenu/SelectMenu.tsx +0 -68
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +0 -50
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +0 -56
- package/build/primer/SelectMenu/index.ts +0 -1
- package/build/primer/Subhead/Subhead.prop.ts +0 -10
- package/build/primer/Subhead/Subhead.tsx +0 -15
- package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +0 -23
- package/build/primer/Subhead/__tests__/Subhead.int.test.ts +0 -13
- package/build/primer/Subhead/index.ts +0 -1
- package/build/primer/Toast/Toast.prop.ts +0 -21
- package/build/primer/Toast/Toast.tsx +0 -38
- package/build/primer/Toast/__tests__/Toast.int.story.tsx +0 -50
- package/build/primer/Toast/__tests__/Toast.int.test.ts +0 -25
- package/build/primer/Toast/index.ts +0 -2
- package/build/primer/index.ts +0 -83
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { IconProps, defaultProps, iconSize, iconAlign } from './Icon.prop'
|
|
2
|
-
import { iconComponents } from './Icon.part'
|
|
3
|
-
|
|
4
|
-
const defaultSize = [16, 16]
|
|
5
|
-
|
|
6
|
-
export function Icon({
|
|
7
|
-
className = defaultProps.className,
|
|
8
|
-
ariaLabel = defaultProps.ariaLabel,
|
|
9
|
-
icon,
|
|
10
|
-
height = defaultProps.height,
|
|
11
|
-
width = defaultProps.width,
|
|
12
|
-
size = defaultProps.size,
|
|
13
|
-
fill = defaultProps.fill,
|
|
14
|
-
verticalAlign = defaultProps.verticalAlign,
|
|
15
|
-
...otherProps
|
|
16
|
-
}: IconProps) {
|
|
17
|
-
const widthHeight = defaultSize
|
|
18
|
-
|
|
19
|
-
const attrs = {
|
|
20
|
-
className,
|
|
21
|
-
'aria-hidden': ariaLabel ? 'false' : 'true',
|
|
22
|
-
'aria-label': ariaLabel,
|
|
23
|
-
height,
|
|
24
|
-
role: 'img',
|
|
25
|
-
viewBox: [0, 0, ...widthHeight].join(' '),
|
|
26
|
-
style: {},
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (width && height) {
|
|
30
|
-
Object.assign(attrs, { width, height })
|
|
31
|
-
} else {
|
|
32
|
-
const dims = { width: widthHeight[0], height: widthHeight[1] }
|
|
33
|
-
const given = width ? 'width' : 'height'
|
|
34
|
-
const computed = given === 'width' ? 'height' : 'width'
|
|
35
|
-
attrs[given] = width || height || iconSize[size] || size
|
|
36
|
-
attrs[computed] = attrs[given] * (dims[computed] / dims[given])
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
attrs.style = {
|
|
40
|
-
display: 'inline-block',
|
|
41
|
-
fill,
|
|
42
|
-
userSelect: 'none',
|
|
43
|
-
verticalAlign: iconAlign[verticalAlign] || verticalAlign,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const Element = iconComponents[icon]
|
|
47
|
-
|
|
48
|
-
return Element != null ? <Element className={className} {...attrs} {...otherProps} /> : null
|
|
49
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { withTests } from '@storybook/addon-jest'
|
|
2
|
-
import { iconNameKeys, iconNameKeysDefault, iconSizeKeys, iconSizeKeysDefault } from '../Icon.prop'
|
|
3
|
-
import results from '../../../../../../.jest-test-results.json'
|
|
4
|
-
|
|
5
|
-
const Icon =
|
|
6
|
-
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
7
|
-
? require('../../../index').primer.Icon.Icon
|
|
8
|
-
: require('../../../../build').primer.Icon.Icon
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Primer/Atom/Icon',
|
|
12
|
-
component: Icon,
|
|
13
|
-
decorators: [withTests({ results })],
|
|
14
|
-
parameters: { jest: ['Icon.int.test.js'] },
|
|
15
|
-
argTypes: {
|
|
16
|
-
className: {
|
|
17
|
-
control: { type: 'text' },
|
|
18
|
-
defaultValue: '',
|
|
19
|
-
},
|
|
20
|
-
icon: {
|
|
21
|
-
control: {
|
|
22
|
-
type: 'select',
|
|
23
|
-
options: iconNameKeys,
|
|
24
|
-
},
|
|
25
|
-
defaultValue: iconNameKeysDefault,
|
|
26
|
-
},
|
|
27
|
-
size: {
|
|
28
|
-
control: {
|
|
29
|
-
type: 'select',
|
|
30
|
-
options: iconSizeKeys,
|
|
31
|
-
},
|
|
32
|
-
defaultValue: iconSizeKeysDefault,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
excludeStories: ['custom'],
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function regular({ className = '', icon = iconNameKeysDefault, size = iconSizeKeysDefault, ...rest }) {
|
|
39
|
-
return <Icon className={className} icon={icon} size={size} {...rest} />
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function allIcons() {
|
|
43
|
-
return (
|
|
44
|
-
<div
|
|
45
|
-
style={{
|
|
46
|
-
columns: '4',
|
|
47
|
-
width: '800px',
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
{iconNameKeys.map((icon) => (
|
|
51
|
-
<div key={icon} style={{ padding: '4px', fontSize: '14px', lineHeight: '21px' }}>
|
|
52
|
-
<Icon icon={icon} style={{ marginRight: '4px', verticalAlign: 'middle' }} />
|
|
53
|
-
<span style={{ display: 'inline-block', verticalAlign: 'middle' }}>{icon}</span>
|
|
54
|
-
</div>
|
|
55
|
-
))}
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { regular, allIcons } from './Icon.int.story'
|
|
2
|
-
|
|
3
|
-
describe('<Icon />', () => {
|
|
4
|
-
describe('Render', () => {
|
|
5
|
-
test('must match regular()', () => {
|
|
6
|
-
expect(global.renderToJSON(regular({}))).toMatchSnapshot()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('must match allIcons()', () => {
|
|
10
|
-
expect(global.renderToJSON(allIcons())).toMatchSnapshot()
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const labelVariant = {
|
|
2
|
-
regular: 'regular',
|
|
3
|
-
state: 'state',
|
|
4
|
-
counter: 'counter',
|
|
5
|
-
issue: 'issue',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const labelBackgroundColor = {
|
|
9
|
-
blue: 'blue',
|
|
10
|
-
red: 'red',
|
|
11
|
-
green: 'green',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const labelTextColor = {
|
|
15
|
-
white: 'white',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const defaultProps = {
|
|
19
|
-
className: null,
|
|
20
|
-
variant: labelVariant.issue,
|
|
21
|
-
backgroundColor: labelBackgroundColor.blue,
|
|
22
|
-
textColor: labelTextColor.white,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface LabelProps {
|
|
26
|
-
className?: string
|
|
27
|
-
text: string
|
|
28
|
-
variant?: typeof labelVariant.regular | typeof labelVariant.state | typeof labelVariant.counter | typeof labelVariant.issue
|
|
29
|
-
backgroundColor?: typeof labelBackgroundColor.blue | typeof labelBackgroundColor.red | typeof labelBackgroundColor.green
|
|
30
|
-
textColor?: typeof labelTextColor.white
|
|
31
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import colorStyles from '@papillonarts/css/build/primer/utilities/colors.scss'
|
|
3
|
-
import { LabelProps, defaultProps, labelVariant, labelBackgroundColor, labelTextColor } from './Label.prop'
|
|
4
|
-
import labelsStyles from './labels.scss'
|
|
5
|
-
import issueLabelsStyles from './issue-labels.scss'
|
|
6
|
-
|
|
7
|
-
export function Label({
|
|
8
|
-
className = defaultProps.className,
|
|
9
|
-
text,
|
|
10
|
-
variant = defaultProps.variant,
|
|
11
|
-
backgroundColor = defaultProps.backgroundColor,
|
|
12
|
-
textColor = defaultProps.textColor,
|
|
13
|
-
}: LabelProps) {
|
|
14
|
-
return (
|
|
15
|
-
<span
|
|
16
|
-
title={`Label: ${text}`}
|
|
17
|
-
className={cx(className, {
|
|
18
|
-
[labelsStyles.Label]: variant === labelVariant.regular,
|
|
19
|
-
[issueLabelsStyles.IssueLabel]: variant === labelVariant.issue,
|
|
20
|
-
[colorStyles['bg-blue']]: backgroundColor === labelBackgroundColor.blue,
|
|
21
|
-
[colorStyles['text-white']]: textColor === labelTextColor.white,
|
|
22
|
-
})}
|
|
23
|
-
>
|
|
24
|
-
{text}
|
|
25
|
-
</span>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { withTests } from '@storybook/addon-jest'
|
|
2
|
-
import results from '../../../../../../.jest-test-results.json'
|
|
3
|
-
|
|
4
|
-
const Label =
|
|
5
|
-
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
6
|
-
? require('../../../index').primer.Label
|
|
7
|
-
: require('../../../../build').primer.Label
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Primer/Atom/Label',
|
|
11
|
-
component: Label,
|
|
12
|
-
decorators: [withTests({ results })],
|
|
13
|
-
parameters: { jest: ['Label.int.test.js'] },
|
|
14
|
-
excludeStories: ['custom'],
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function regular() {
|
|
18
|
-
return <Label text="default label" />
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Label } from './Label'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const loaderVariant = {
|
|
2
|
-
heading: 'heading',
|
|
3
|
-
text: 'text',
|
|
4
|
-
label: 'label',
|
|
5
|
-
button: 'button',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const defaultProps = {
|
|
9
|
-
className: null,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface LoaderProps {
|
|
13
|
-
className?: string
|
|
14
|
-
variant: typeof loaderVariant.heading | typeof loaderVariant.text | typeof loaderVariant.label | typeof loaderVariant.button
|
|
15
|
-
text: string
|
|
16
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import colorStyles from '@papillonarts/css/build/primer/utilities/colors.scss'
|
|
3
|
-
import marginStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
|
|
4
|
-
import { LoaderProps, defaultProps, loaderVariant } from './Loader.prop'
|
|
5
|
-
import styles from './Loader.scss'
|
|
6
|
-
import branchNameStyles from '../BranchName/branch-name.scss'
|
|
7
|
-
import buttonStyles from '../Button/Button.scss'
|
|
8
|
-
import labelStyles from '../Label/labels.scss'
|
|
9
|
-
|
|
10
|
-
export function Loader({ className = defaultProps.className, variant, text }: LoaderProps) {
|
|
11
|
-
switch (variant) {
|
|
12
|
-
case loaderVariant.heading:
|
|
13
|
-
return (
|
|
14
|
-
<h2 className={className}>
|
|
15
|
-
<span>{text}</span>
|
|
16
|
-
<span className={styles.AnimatedEllipsis} />
|
|
17
|
-
</h2>
|
|
18
|
-
)
|
|
19
|
-
case loaderVariant.text:
|
|
20
|
-
return (
|
|
21
|
-
<span className={cx(branchNameStyles['branch-name'], marginStyles['mt-2'])}>
|
|
22
|
-
<span>{text}</span>
|
|
23
|
-
<span className={styles.AnimatedEllipsis} />
|
|
24
|
-
</span>
|
|
25
|
-
)
|
|
26
|
-
case loaderVariant.label:
|
|
27
|
-
return (
|
|
28
|
-
<span className={cx(labelStyles.Label, colorStyles['bg-blue'], marginStyles['mt-3'])}>
|
|
29
|
-
<span>{text}</span>
|
|
30
|
-
<span className={styles.AnimatedEllipsis} />
|
|
31
|
-
</span>
|
|
32
|
-
)
|
|
33
|
-
case loaderVariant.button:
|
|
34
|
-
return (
|
|
35
|
-
<button type="button" className={cx(buttonStyles.btn, marginStyles['mt-3'])} aria-disabled="true">
|
|
36
|
-
<span>{text}</span>
|
|
37
|
-
<span className={styles.AnimatedEllipsis} />
|
|
38
|
-
</button>
|
|
39
|
-
)
|
|
40
|
-
default:
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { withTests } from '@storybook/addon-jest'
|
|
2
|
-
import { loaderVariant } from '../Loader.prop'
|
|
3
|
-
import results from '../../../../../../.jest-test-results.json'
|
|
4
|
-
|
|
5
|
-
const Loader =
|
|
6
|
-
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
7
|
-
? require('../../../index').primer.Loader.Loader
|
|
8
|
-
: require('../../../../build').primer.Loader.Loader
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Primer/Atom/Loader',
|
|
12
|
-
component: Loader,
|
|
13
|
-
decorators: [withTests({ results })],
|
|
14
|
-
parameters: { jest: ['Loader.int.test.js'] },
|
|
15
|
-
excludeStories: ['textValue', 'custom'],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const textValue = 'Loading'
|
|
19
|
-
|
|
20
|
-
export function heading() {
|
|
21
|
-
return <Loader variant={loaderVariant.heading} text={textValue} />
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function text() {
|
|
25
|
-
return <Loader variant={loaderVariant.text} text={textValue} />
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function label() {
|
|
29
|
-
return <Loader variant={loaderVariant.label} text={textValue} />
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function button() {
|
|
33
|
-
return <Loader variant={loaderVariant.button} text={textValue} />
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { heading, text, label, button } from './Loader.int.story'
|
|
2
|
-
|
|
3
|
-
describe('<Loader />', () => {
|
|
4
|
-
describe('Render', () => {
|
|
5
|
-
test('must match heading()', () => {
|
|
6
|
-
expect(global.renderToJSON(heading())).toMatchSnapshot()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('must match text()', () => {
|
|
10
|
-
expect(global.renderToJSON(text())).toMatchSnapshot()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('must match label()', () => {
|
|
14
|
-
expect(global.renderToJSON(label())).toMatchSnapshot()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('must match button()', () => {
|
|
18
|
-
expect(global.renderToJSON(button())).toMatchSnapshot()
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const defaultProps = {
|
|
2
|
-
className: null,
|
|
3
|
-
heading: null,
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface AriaAttrType {
|
|
7
|
-
label: string
|
|
8
|
-
labelledBy: string
|
|
9
|
-
current: boolean | false | true | 'page' | 'step' | 'location' | 'date' | 'time'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ItemType {
|
|
13
|
-
href: string
|
|
14
|
-
icon: string
|
|
15
|
-
text: string
|
|
16
|
-
html: React.ReactNode[]
|
|
17
|
-
isSelected: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface MenuProps {
|
|
21
|
-
className?: string
|
|
22
|
-
heading?: string
|
|
23
|
-
ariaAttr: AriaAttrType
|
|
24
|
-
items: ItemType[]
|
|
25
|
-
onClick: (value) => void
|
|
26
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import { v1 as uuidv1 } from 'uuid'
|
|
3
|
-
import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
|
|
4
|
-
import { useState } from '@papillonarts/library/hooks'
|
|
5
|
-
import { MenuProps, defaultProps } from './Menu.prop'
|
|
6
|
-
import styles from './Menu.scss'
|
|
7
|
-
import { Icon, iconSize } from '../../Icon'
|
|
8
|
-
|
|
9
|
-
export function Menu({ className = defaultProps.className, heading = defaultProps.heading, ariaAttr, items, onClick }: MenuProps) {
|
|
10
|
-
const [indexItems, setIndexItems] = useState(getIndexItems(items))
|
|
11
|
-
const { label, labelledBy, current } = ariaAttr
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<nav className={cx(className, styles.menu)} aria-label={label} aria-labelledby={labelledBy}>
|
|
15
|
-
{heading && <span className={styles['menu-heading']}>{heading}</span>}
|
|
16
|
-
{indexItems.map((indexItem) => {
|
|
17
|
-
const { href, icon, text, html, isSelected } = indexItem
|
|
18
|
-
|
|
19
|
-
const itemOtherProps = isSelected ? { ...{ 'aria-current': current } } : null
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<a
|
|
23
|
-
key={uuidv1()}
|
|
24
|
-
onClick={(e) => {
|
|
25
|
-
e.preventDefault()
|
|
26
|
-
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
|
|
27
|
-
setIndexItems(newIndexItems)
|
|
28
|
-
onClick(newIndexItems)
|
|
29
|
-
}}
|
|
30
|
-
className={styles['menu-item']}
|
|
31
|
-
href={href}
|
|
32
|
-
{...itemOtherProps}
|
|
33
|
-
>
|
|
34
|
-
{icon && <Icon className={styles.octicon} icon={icon} size={iconSize.small} />}
|
|
35
|
-
{html || null}
|
|
36
|
-
{text}
|
|
37
|
-
</a>
|
|
38
|
-
)
|
|
39
|
-
})}
|
|
40
|
-
</nav>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { action } from 'storybook/actions'
|
|
2
|
-
import { withTests } from '@storybook/addon-jest'
|
|
3
|
-
import { iconName } from '../../../Icon/Icon.prop'
|
|
4
|
-
import results from '../../../../../../../.jest-test-results.json'
|
|
5
|
-
|
|
6
|
-
const Menu =
|
|
7
|
-
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
8
|
-
? require('../../../../index').primer.Navigation.Menu
|
|
9
|
-
: require('../../../../../build').primer.Navigation.Menu
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: 'Primer/Molecule/Navigation/Menu',
|
|
13
|
-
component: Menu,
|
|
14
|
-
decorators: [withTests({ results })],
|
|
15
|
-
parameters: { jest: ['Menu.int.test.js'] },
|
|
16
|
-
excludeStories: ['heading', 'ariaAttr', 'defaultItems', 'iconItems', 'custom'],
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const heading = 'Menu heading'
|
|
20
|
-
|
|
21
|
-
export const ariaAttr = {
|
|
22
|
-
label: 'Person settings',
|
|
23
|
-
labelledBy: 'menu-heading',
|
|
24
|
-
current: 'page',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const defaultItems = [
|
|
28
|
-
{ href: '#url', text: 'Account', isSelected: true },
|
|
29
|
-
{ href: '#url', text: 'Profile', isSelected: false },
|
|
30
|
-
{ href: '#url', text: 'Emails', isSelected: false },
|
|
31
|
-
{ href: '#url', text: 'Notifications', isSelected: false },
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
export const iconItems = [
|
|
35
|
-
{ href: '#url', icon: iconName.Tools16, text: 'Account', isSelected: true },
|
|
36
|
-
{ href: '#url', icon: iconName.Person16, text: 'Profile', isSelected: false },
|
|
37
|
-
{ href: '#url', icon: iconName.Mail16, text: 'Emails', isSelected: false },
|
|
38
|
-
{ href: '#url', icon: iconName.Broadcast16, text: 'Notifications', isSelected: false },
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
export function custom(onClick) {
|
|
42
|
-
return <Menu ariaAttr={ariaAttr} items={defaultItems} onClick={onClick} />
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function regular() {
|
|
46
|
-
return <Menu ariaAttr={ariaAttr} items={defaultItems} onClick={action('onClick')} />
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function withIcons() {
|
|
50
|
-
return <Menu ariaAttr={ariaAttr} items={iconItems} onClick={action('onClick')} />
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function withHeading() {
|
|
54
|
-
return <Menu heading={heading} ariaAttr={ariaAttr} items={defaultItems} onClick={action('onClick')} />
|
|
55
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { defaultItems as items, regular, withIcons, withHeading } from './Menu.int.story'
|
|
2
|
-
|
|
3
|
-
jest.mock('@papillonarts/library/array', () => ({
|
|
4
|
-
getIndexItems: () => {},
|
|
5
|
-
getIndexItemsWithSelected: () => {},
|
|
6
|
-
}))
|
|
7
|
-
|
|
8
|
-
jest.mock('@papillonarts/library/hooks', () => ({
|
|
9
|
-
useState: () => {},
|
|
10
|
-
}))
|
|
11
|
-
|
|
12
|
-
const libraryArrayMockObject = require('@papillonarts/library/array')
|
|
13
|
-
const libraryHooksMockObject = require('@papillonarts/library/hooks')
|
|
14
|
-
|
|
15
|
-
describe('<Menu />', () => {
|
|
16
|
-
let indexItemsDataObject = [
|
|
17
|
-
{ ...items[0], index: 0 },
|
|
18
|
-
{ ...items[1], index: 1 },
|
|
19
|
-
{ ...items[2], index: 2 },
|
|
20
|
-
{ ...items[3], index: 3 },
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
const newIndexItemsWithSelectedDataObject = [
|
|
24
|
-
{ ...items[0], index: 0, isSelected: true },
|
|
25
|
-
{ ...items[1], index: 1, isSelected: false },
|
|
26
|
-
{ ...items[2], index: 2, isSelected: false },
|
|
27
|
-
{ ...items[3], index: 3, isSelected: false },
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
const setIndexItemsMockFn = jest.fn((indexItems) => {
|
|
31
|
-
indexItemsDataObject = indexItems
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
jest.spyOn(libraryArrayMockObject, 'getIndexItems').mockReturnValue(indexItemsDataObject)
|
|
36
|
-
|
|
37
|
-
jest.spyOn(libraryArrayMockObject, 'getIndexItemsWithSelected').mockReturnValue(newIndexItemsWithSelectedDataObject)
|
|
38
|
-
|
|
39
|
-
jest.spyOn(libraryHooksMockObject, 'useState').mockImplementation(() => [indexItemsDataObject, setIndexItemsMockFn])
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
afterEach(() => jest.clearAllMocks())
|
|
43
|
-
|
|
44
|
-
describe('Render', () => {
|
|
45
|
-
test('must match regular()', () => {
|
|
46
|
-
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('must match withIcons()', () => {
|
|
50
|
-
expect(global.renderToJSON(withIcons())).toMatchSnapshot()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('must match withHeading()', () => {
|
|
54
|
-
expect(global.renderToJSON(withHeading())).toMatchSnapshot()
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Menu } from './Menu'
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export const tabNavState = {
|
|
2
|
-
active: 'active',
|
|
3
|
-
inactive: 'inactive',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const defaultProps = {
|
|
7
|
-
className: null,
|
|
8
|
-
actions: null,
|
|
9
|
-
children: null,
|
|
10
|
-
state: tabNavState.active,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface AriaAttrType {
|
|
14
|
-
label: string
|
|
15
|
-
current: boolean | false | true | 'page' | 'step' | 'location' | 'date' | 'time'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface LinkType {
|
|
19
|
-
component: React.ReactNode
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ItemType {
|
|
23
|
-
href: string
|
|
24
|
-
text: string
|
|
25
|
-
link: LinkType
|
|
26
|
-
isSelected: boolean
|
|
27
|
-
enabled: boolean
|
|
28
|
-
visible: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface TabNavProps {
|
|
32
|
-
className?: string
|
|
33
|
-
ariaAttr: AriaAttrType
|
|
34
|
-
items: ItemType[]
|
|
35
|
-
actions?: React.ReactNode[]
|
|
36
|
-
onClick: (value) => void
|
|
37
|
-
children?: React.ReactNode
|
|
38
|
-
state?: typeof tabNavState.active | typeof tabNavState.inactive
|
|
39
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Fragment } from 'react'
|
|
2
|
-
import cx from 'classnames'
|
|
3
|
-
import { v1 as uuidv1 } from 'uuid'
|
|
4
|
-
import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
|
|
5
|
-
import { TabNavProps, defaultProps, tabNavState } from './TabNav.prop'
|
|
6
|
-
import styles from './TabNav.scss'
|
|
7
|
-
|
|
8
|
-
export function TabNav({
|
|
9
|
-
className = defaultProps.className,
|
|
10
|
-
ariaAttr,
|
|
11
|
-
items,
|
|
12
|
-
actions = defaultProps.actions,
|
|
13
|
-
onClick,
|
|
14
|
-
children = defaultProps.children,
|
|
15
|
-
state = defaultProps.state,
|
|
16
|
-
}: TabNavProps) {
|
|
17
|
-
if (!items) {
|
|
18
|
-
return null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { label, current } = ariaAttr
|
|
22
|
-
const indexItems = getIndexItems(items)
|
|
23
|
-
|
|
24
|
-
function renderActions() {
|
|
25
|
-
return <Fragment>{actions}</Fragment> // eslint-disable-line react/jsx-no-useless-fragment
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={cx(className, styles.tabnav, {
|
|
31
|
-
[styles['tabnav-inactive']]: state === tabNavState.inactive,
|
|
32
|
-
})}
|
|
33
|
-
>
|
|
34
|
-
{actions && renderActions()}
|
|
35
|
-
<nav className={styles['tabnav-tabs']} aria-label={label}>
|
|
36
|
-
{indexItems.map((indexItem) => {
|
|
37
|
-
const { href, text, link, isSelected, enabled, visible } = indexItem
|
|
38
|
-
|
|
39
|
-
const itemOtherProps = isSelected ? { ...{ 'aria-current': current } } : null
|
|
40
|
-
|
|
41
|
-
if (href && text) {
|
|
42
|
-
return (
|
|
43
|
-
<a
|
|
44
|
-
key={uuidv1()}
|
|
45
|
-
onClick={() => {
|
|
46
|
-
if (!enabled) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
|
|
51
|
-
onClick({
|
|
52
|
-
ariaAttr,
|
|
53
|
-
items: newIndexItems.map(
|
|
54
|
-
(newIndexItem) => (({ href, text, isSelected }) => ({ href, text, isSelected, enabled, visible }))(newIndexItem), // eslint-disable-line
|
|
55
|
-
),
|
|
56
|
-
})
|
|
57
|
-
}}
|
|
58
|
-
className={styles['tabnav-tab']}
|
|
59
|
-
href={href}
|
|
60
|
-
{...itemOtherProps}
|
|
61
|
-
>
|
|
62
|
-
{text}
|
|
63
|
-
</a>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (link) {
|
|
68
|
-
const Link = link.component
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Link
|
|
72
|
-
key={uuidv1()}
|
|
73
|
-
onClick={() => {
|
|
74
|
-
if (!enabled) {
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
|
|
79
|
-
onClick({
|
|
80
|
-
ariaAttr,
|
|
81
|
-
items: newIndexItems.map(
|
|
82
|
-
(newIndexItem) =>
|
|
83
|
-
(({ link, isSelected, enabled, visible }) => ({ link, isSelected, enabled, visible }))(newIndexItem), // eslint-disable-line
|
|
84
|
-
),
|
|
85
|
-
})
|
|
86
|
-
}}
|
|
87
|
-
className={cx(className, styles['tabnav-tab'], {
|
|
88
|
-
[styles['tabnav-tab-inactive']]: enabled === false,
|
|
89
|
-
[styles['tabnav-tab-hidden']]: visible === false,
|
|
90
|
-
})}
|
|
91
|
-
{...itemOtherProps}
|
|
92
|
-
{...link.props}
|
|
93
|
-
>
|
|
94
|
-
{link.children}
|
|
95
|
-
</Link>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return null
|
|
100
|
-
})}
|
|
101
|
-
</nav>
|
|
102
|
-
{children}
|
|
103
|
-
</div>
|
|
104
|
-
)
|
|
105
|
-
}
|