@papillonarts/components 0.7.0 → 0.9.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/BranchName/branch-name.scss +2 -2
- 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.scss +4 -4
- package/build/primer/Button/Button.tsx +91 -0
- package/build/primer/Button/ButtonGroup.scss +2 -2
- 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/Button/misc.scss +2 -2
- 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/form-control.scss +4 -4
- package/build/primer/Form/form-select.scss +4 -4
- 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/Label/mixins.scss +3 -3
- package/build/primer/Layout/container.scss +1 -1
- package/build/primer/Layout/grid-offset.scss +1 -1
- package/build/primer/Layout/grid.scss +2 -2
- 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.scss +2 -2
- 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.scss +2 -2
- 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.scss +4 -4
- 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.scss +3 -3
- 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.scss +3 -3
- 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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isChecked, isNotChecked, isCheckedInactive, isNotCheckedInactive } from './Checkbox.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Checkbox />', () => {
|
|
4
|
+
afterEach(() => jest.clearAllMocks())
|
|
5
|
+
|
|
6
|
+
describe('Render', () => {
|
|
7
|
+
test('must match isChecked()', () => {
|
|
8
|
+
expect(global.renderToJSON(isChecked())).toMatchSnapshot()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('must match isCheckedInactive()', () => {
|
|
12
|
+
expect(global.renderToJSON(isCheckedInactive())).toMatchSnapshot()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('must match isNotChecked()', () => {
|
|
16
|
+
expect(global.renderToJSON(isNotChecked())).toMatchSnapshot()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('must match isNotCheckedInactive()', () => {
|
|
20
|
+
expect(global.renderToJSON(isNotCheckedInactive())).toMatchSnapshot()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const inputState = {
|
|
2
|
+
active: 'active',
|
|
3
|
+
inactive: 'inactive',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const inputType = {
|
|
7
|
+
text: 'text',
|
|
8
|
+
password: 'password',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const defaultProps = {
|
|
12
|
+
dataTest: null,
|
|
13
|
+
id: null,
|
|
14
|
+
className: null,
|
|
15
|
+
placeholder: null,
|
|
16
|
+
ariaAttr: {
|
|
17
|
+
label: '',
|
|
18
|
+
},
|
|
19
|
+
inputType: inputType.text,
|
|
20
|
+
onFocus: () => {},
|
|
21
|
+
onBlur: () => {},
|
|
22
|
+
state: inputState.active,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AriaAttrType {
|
|
26
|
+
label: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface InputProps {
|
|
30
|
+
dataTest?: string
|
|
31
|
+
id?: string
|
|
32
|
+
className?: string
|
|
33
|
+
placeholder?: string
|
|
34
|
+
ariaAttr?: AriaAttrType
|
|
35
|
+
inputType?: typeof inputType.text | typeof inputType.password
|
|
36
|
+
value: string
|
|
37
|
+
onChange: (value) => void
|
|
38
|
+
onKeyUp: (value) => void
|
|
39
|
+
onFocus?: (value) => void
|
|
40
|
+
onBlur?: (value) => void
|
|
41
|
+
autoFocus: boolean
|
|
42
|
+
state?: typeof inputState.active | typeof inputState.inactive
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import { InputProps, defaultProps, inputState } from './Input.prop'
|
|
3
|
+
import styles from './Input.scss'
|
|
4
|
+
import formStyles from '../index.scss'
|
|
5
|
+
|
|
6
|
+
export function Input({
|
|
7
|
+
dataTest = defaultProps.dataTest,
|
|
8
|
+
id = defaultProps.id,
|
|
9
|
+
className = defaultProps.className,
|
|
10
|
+
placeholder = defaultProps.placeholder,
|
|
11
|
+
ariaAttr = defaultProps.ariaAttr,
|
|
12
|
+
inputType = defaultProps.inputType,
|
|
13
|
+
value,
|
|
14
|
+
onChange,
|
|
15
|
+
onKeyUp,
|
|
16
|
+
onFocus = defaultProps.onFocus,
|
|
17
|
+
onBlur = defaultProps.onBlur,
|
|
18
|
+
autoFocus,
|
|
19
|
+
state = defaultProps.state,
|
|
20
|
+
}: InputProps) {
|
|
21
|
+
return (
|
|
22
|
+
<input
|
|
23
|
+
data-test={dataTest}
|
|
24
|
+
id={id}
|
|
25
|
+
className={cx(className, formStyles['form-control'], {
|
|
26
|
+
[styles['input-inactive']]: state === inputState.inactive,
|
|
27
|
+
})}
|
|
28
|
+
value={value}
|
|
29
|
+
onChange={(event) => {
|
|
30
|
+
onChange(event)
|
|
31
|
+
}}
|
|
32
|
+
onKeyUp={(event) => {
|
|
33
|
+
onKeyUp(event)
|
|
34
|
+
}}
|
|
35
|
+
onFocus={onFocus}
|
|
36
|
+
onBlur={onBlur}
|
|
37
|
+
type={inputType}
|
|
38
|
+
placeholder={placeholder}
|
|
39
|
+
aria-label={ariaAttr.label}
|
|
40
|
+
autoFocus={autoFocus} // eslint-disable-line
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { action } from 'storybook/actions'
|
|
2
|
+
import { withTests } from '@storybook/addon-jest'
|
|
3
|
+
import { inputState } from '../Input.prop'
|
|
4
|
+
import results from '../../../../../../../.jest-test-results.json'
|
|
5
|
+
|
|
6
|
+
const Input =
|
|
7
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
8
|
+
? require('../../../../index').primer.Form.Input.Input
|
|
9
|
+
: require('../../../../../build').primer.Form.Input.Input
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Primer/Atom/Form/Input',
|
|
13
|
+
component: Input,
|
|
14
|
+
decorators: [withTests({ results })],
|
|
15
|
+
parameters: { jest: ['Input.int.test.js'] },
|
|
16
|
+
excludeStories: ['placeholder', 'ariaAttr', 'custom'],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const placeholder = 'Fantastic placeholder'
|
|
20
|
+
|
|
21
|
+
const ariaAttr = {
|
|
22
|
+
label: 'Repository description',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function custom(onChange, onKeyUp, onFocus, onBlur) {
|
|
26
|
+
return <Input placeholder={placeholder} ariaAttr={ariaAttr} onChange={onChange} onKeyUp={onKeyUp} onFocus={onFocus} onBlur={onBlur} />
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function regular() {
|
|
30
|
+
return (
|
|
31
|
+
<Input
|
|
32
|
+
placeholder={placeholder}
|
|
33
|
+
ariaAttr={ariaAttr}
|
|
34
|
+
onChange={action('onChange')}
|
|
35
|
+
onKeyUp={action('onKeyUp')}
|
|
36
|
+
onFocus={action('onFocus')}
|
|
37
|
+
onBlur={action('onBlur')}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function inactive() {
|
|
43
|
+
return (
|
|
44
|
+
<Input
|
|
45
|
+
placeholder={placeholder}
|
|
46
|
+
ariaAttr={ariaAttr}
|
|
47
|
+
onChange={action('onChange')}
|
|
48
|
+
onKeyUp={action('onKeyUp')}
|
|
49
|
+
onFocus={action('onFocus')}
|
|
50
|
+
onBlur={action('onBlur')}
|
|
51
|
+
state={inputState.inactive}
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { regular, inactive } from './Input.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Input />', () => {
|
|
4
|
+
afterEach(() => jest.clearAllMocks())
|
|
5
|
+
|
|
6
|
+
describe('Render', () => {
|
|
7
|
+
test('must match regular()', () => {
|
|
8
|
+
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('must match inactive()', () => {
|
|
12
|
+
expect(global.renderToJSON(inactive())).toMatchSnapshot()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const radioState = {
|
|
2
|
+
active: 'active',
|
|
3
|
+
inactive: 'inactive',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const inputType = {
|
|
7
|
+
radio: 'radio',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const defaultProps = {
|
|
11
|
+
dataTest: null,
|
|
12
|
+
className: null,
|
|
13
|
+
htmlFor: 'checkbox',
|
|
14
|
+
inputType: inputType.radio,
|
|
15
|
+
isChecked: false,
|
|
16
|
+
text: null,
|
|
17
|
+
state: radioState.active,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface RadioProps {
|
|
21
|
+
dataTest?: string
|
|
22
|
+
className?: string
|
|
23
|
+
htmlFor?: string
|
|
24
|
+
inputType?: typeof inputType.radio
|
|
25
|
+
name: string
|
|
26
|
+
isChecked?: boolean
|
|
27
|
+
text?: string
|
|
28
|
+
onChange: (value) => void
|
|
29
|
+
state?: typeof radioState.active | typeof radioState.inactive
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import marginStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
|
|
3
|
+
import { RadioProps, defaultProps, radioState } from './Radio.prop'
|
|
4
|
+
import styles from './Radio.scss'
|
|
5
|
+
import formStyles from '../index.scss'
|
|
6
|
+
|
|
7
|
+
export function Radio({
|
|
8
|
+
dataTest = defaultProps.dataTest,
|
|
9
|
+
className = defaultProps.className,
|
|
10
|
+
htmlFor = defaultProps.htmlFor,
|
|
11
|
+
inputType = defaultProps.inputType,
|
|
12
|
+
name,
|
|
13
|
+
isChecked = defaultProps.isChecked,
|
|
14
|
+
text = defaultProps.text,
|
|
15
|
+
onChange,
|
|
16
|
+
state = defaultProps.state,
|
|
17
|
+
}: RadioProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-test={dataTest}
|
|
21
|
+
className={cx(className, marginStyles['m-0'], formStyles['form-checkbox'], {
|
|
22
|
+
[styles['radio-inactive']]: state === radioState.inactive,
|
|
23
|
+
})}
|
|
24
|
+
>
|
|
25
|
+
<label htmlFor={htmlFor}>
|
|
26
|
+
<input
|
|
27
|
+
type={inputType}
|
|
28
|
+
name={name}
|
|
29
|
+
onChange={(event) => {
|
|
30
|
+
onChange(event)
|
|
31
|
+
}}
|
|
32
|
+
checked={isChecked}
|
|
33
|
+
/>
|
|
34
|
+
{text}
|
|
35
|
+
</label>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fragment } from 'react'
|
|
2
|
+
import { action } from 'storybook/actions'
|
|
3
|
+
import { withTests } from '@storybook/addon-jest'
|
|
4
|
+
import { radioState } from '../Radio.prop'
|
|
5
|
+
import results from '../../../../../../../.jest-test-results.json'
|
|
6
|
+
|
|
7
|
+
const Radio =
|
|
8
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
9
|
+
? require('../../../../index').primer.Form.Radio.Radio
|
|
10
|
+
: require('../../../../../build').primer.Form.Radio.Radio
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Primer/Atom/Form/Radio',
|
|
14
|
+
component: Radio,
|
|
15
|
+
decorators: [withTests({ results })],
|
|
16
|
+
parameters: { jest: ['Radio.int.test.js'] },
|
|
17
|
+
excludeStories: ['name', 'custom'],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const name = 'fantastic-name'
|
|
21
|
+
|
|
22
|
+
export function custom(onChange) {
|
|
23
|
+
return <Radio name={name} onChange={onChange} text="White" />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function regular() {
|
|
27
|
+
return (
|
|
28
|
+
<Fragment>
|
|
29
|
+
<Radio name={name} onChange={action('onChange-white')} text="White" />
|
|
30
|
+
<Radio name={name} isChecked={true} onChange={action('onChange-black')} text="Black" />
|
|
31
|
+
</Fragment>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function inactive() {
|
|
36
|
+
return (
|
|
37
|
+
<Fragment>
|
|
38
|
+
<Radio name={name} onChange={action('onChange-white')} text="White" state={radioState.inactive} />
|
|
39
|
+
<Radio name={name} isChecked={true} onChange={action('onChange-black')} text="Black" state={radioState.inactive} />
|
|
40
|
+
</Fragment>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { regular, inactive } from './Radio.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Radio />', () => {
|
|
4
|
+
describe('Render', () => {
|
|
5
|
+
test('must match regular()', () => {
|
|
6
|
+
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('must match inactive()', () => {
|
|
10
|
+
expect(global.renderToJSON(inactive())).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
@import '@
|
|
2
|
-
@import '@
|
|
3
|
-
@import '@
|
|
4
|
-
@import '@
|
|
1
|
+
@import '@papillonarts/css/build/primer/support/variables/typography.scss';
|
|
2
|
+
@import '@papillonarts/css/build/primer/support/variables/misc.scss';
|
|
3
|
+
@import '@papillonarts/css/build/primer/support/mixins/misc.scss';
|
|
4
|
+
@import '@papillonarts/css/build/primer/support/mixins/layout.scss';
|
|
5
5
|
|
|
6
6
|
// stylelint-disable custom-property-pattern
|
|
7
7
|
// stylelint-disable no-descending-specificity
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
@import '@
|
|
2
|
-
@import '@
|
|
3
|
-
@import '@
|
|
4
|
-
@import '@
|
|
1
|
+
@import '@papillonarts/css/build/primer/support/variables/typography.scss';
|
|
2
|
+
@import '@papillonarts/css/build/primer/support/variables/layout.scss';
|
|
3
|
+
@import '@papillonarts/css/build/primer/support/mixins/layout.scss';
|
|
4
|
+
@import '@papillonarts/css/build/primer/support/mixins/color-modes.scss';
|
|
5
5
|
|
|
6
6
|
// stylelint-disable custom-property-pattern
|
|
7
7
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Checkbox, checkboxState } from './Checkbox'
|
|
2
|
+
import { Input, inputType, inputState } from './Input'
|
|
3
|
+
import { Radio, radioState } from './Radio'
|
|
4
|
+
|
|
5
|
+
export const Form = {
|
|
6
|
+
Checkbox: {
|
|
7
|
+
Checkbox,
|
|
8
|
+
checkboxState,
|
|
9
|
+
},
|
|
10
|
+
Input: {
|
|
11
|
+
Input,
|
|
12
|
+
inputType,
|
|
13
|
+
inputState,
|
|
14
|
+
},
|
|
15
|
+
Radio: {
|
|
16
|
+
Radio,
|
|
17
|
+
radioState,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const defaultProps = {
|
|
2
|
+
className: null,
|
|
3
|
+
idIndex: -1,
|
|
4
|
+
isSelectedIndex: -1,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ValueType {
|
|
8
|
+
value: React.ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ItemType {
|
|
12
|
+
names: React.ReactNode[]
|
|
13
|
+
values: ValueType[] | React.ReactNode[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DisplayTableProps {
|
|
17
|
+
className: string
|
|
18
|
+
items: ItemType[]
|
|
19
|
+
idIndex: number
|
|
20
|
+
isSelectedIndex: number
|
|
21
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Fragment } from 'react'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import { v1 as uuidv1 } from 'uuid'
|
|
4
|
+
import displayStyles from '@papillonarts/css/build/primer/utilities/visibility-display.scss'
|
|
5
|
+
import borderStyles from '@papillonarts/css/build/primer/utilities/borders.scss'
|
|
6
|
+
import paddingStyles from '@papillonarts/css/build/primer/utilities/padding.scss'
|
|
7
|
+
import typographyStyles from '@papillonarts/css/build/primer/utilities/typography.scss'
|
|
8
|
+
import colorStyles from '@papillonarts/css/build/primer/utilities/colors.scss'
|
|
9
|
+
import gridStyles from '../../Layout/grid.scss'
|
|
10
|
+
import { DisplayTableProps, defaultProps } from './DisplayTable.prop'
|
|
11
|
+
|
|
12
|
+
export function DisplayTable({
|
|
13
|
+
className = defaultProps.className,
|
|
14
|
+
items,
|
|
15
|
+
idIndex = defaultProps.idIndex,
|
|
16
|
+
isSelectedIndex = defaultProps.isSelectedIndex,
|
|
17
|
+
}: DisplayTableProps) {
|
|
18
|
+
return (
|
|
19
|
+
<Fragment>
|
|
20
|
+
<div className={cx(className, displayStyles['d-table'], gridStyles['col-12'], colorStyles['bg-blue-light'])}>
|
|
21
|
+
{items[0].names.map((name, index) => {
|
|
22
|
+
const isIdColumn = index === idIndex
|
|
23
|
+
const isSelectedColumn = index === isSelectedIndex
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Fragment key={uuidv1()}>
|
|
27
|
+
{!isIdColumn && (
|
|
28
|
+
<div
|
|
29
|
+
key={uuidv1()}
|
|
30
|
+
className={cx(
|
|
31
|
+
gridStyles['col-2'],
|
|
32
|
+
displayStyles['d-table-cell'],
|
|
33
|
+
borderStyles.border,
|
|
34
|
+
paddingStyles['p-2'],
|
|
35
|
+
typographyStyles.h6,
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{isSelectedColumn ? '' : name}
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
</Fragment>
|
|
42
|
+
)
|
|
43
|
+
})}
|
|
44
|
+
</div>
|
|
45
|
+
{items.map((item) => (
|
|
46
|
+
<div key={uuidv1()} className={cx(className, displayStyles['d-table'], gridStyles['col-12'])}>
|
|
47
|
+
{item.values.map((value, valueIndex) => {
|
|
48
|
+
const isIdColumn = valueIndex === idIndex
|
|
49
|
+
const isSelectedColumn = valueIndex === isSelectedIndex
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Fragment key={uuidv1()}>
|
|
53
|
+
{!isIdColumn && (
|
|
54
|
+
<div
|
|
55
|
+
key={uuidv1()}
|
|
56
|
+
className={cx(gridStyles['col-2'], displayStyles['d-table-cell'], borderStyles.border, paddingStyles['p-2'])}
|
|
57
|
+
>
|
|
58
|
+
{isSelectedColumn ? '' : (value?.value ?? value)}
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</Fragment>
|
|
62
|
+
)
|
|
63
|
+
})}
|
|
64
|
+
</div>
|
|
65
|
+
))}
|
|
66
|
+
</Fragment>
|
|
67
|
+
)
|
|
68
|
+
}
|