@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.
Files changed (254) hide show
  1. package/build/index.ts +1 -0
  2. package/build/primer/Alert/Alert.mdx +88 -0
  3. package/build/primer/Alert/Alert.prop.ts +45 -0
  4. package/build/primer/Alert/Alert.tsx +101 -0
  5. package/build/primer/Alert/__tests__/Alert.int.story.tsx +86 -0
  6. package/build/primer/Alert/__tests__/Alert.int.test.ts +37 -0
  7. package/build/primer/Alert/index.ts +2 -0
  8. package/build/primer/Blankslate/Blankslate.mdx +57 -0
  9. package/build/primer/Blankslate/Blankslate.prop.ts +26 -0
  10. package/build/primer/Blankslate/Blankslate.tsx +26 -0
  11. package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +43 -0
  12. package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +29 -0
  13. package/build/primer/Blankslate/index.ts +2 -0
  14. package/build/primer/BranchName/branch-name.scss +2 -2
  15. package/build/primer/Breadcrumb/Breadcrumb.mdx +23 -0
  16. package/build/primer/Breadcrumb/Breadcrumb.prop.ts +28 -0
  17. package/build/primer/Breadcrumb/Breadcrumb.tsx +57 -0
  18. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +40 -0
  19. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +40 -0
  20. package/build/primer/Breadcrumb/index.ts +2 -0
  21. package/build/primer/Button/Button.mdx +239 -0
  22. package/build/primer/Button/Button.prop.ts +77 -0
  23. package/build/primer/Button/Button.scss +4 -4
  24. package/build/primer/Button/Button.tsx +91 -0
  25. package/build/primer/Button/ButtonGroup.scss +2 -2
  26. package/build/primer/Button/__tests__/Button.int.story.tsx +173 -0
  27. package/build/primer/Button/__tests__/Button.int.test.ts +191 -0
  28. package/build/primer/Button/index.ts +2 -0
  29. package/build/primer/Button/misc.scss +2 -2
  30. package/build/primer/Dropdown/Dropdown.mdx +19 -0
  31. package/build/primer/Dropdown/Dropdown.prop.ts +33 -0
  32. package/build/primer/Dropdown/Dropdown.tsx +102 -0
  33. package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +43 -0
  34. package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +53 -0
  35. package/build/primer/Dropdown/index.ts +2 -0
  36. package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +5 -0
  37. package/build/primer/ErrorBoundary/ErrorBoundary.tsx +35 -0
  38. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +23 -0
  39. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +9 -0
  40. package/build/primer/ErrorBoundary/index.ts +1 -0
  41. package/build/primer/Form/Checkbox/Checkbox.prop.ts +34 -0
  42. package/build/primer/Form/Checkbox/Checkbox.tsx +40 -0
  43. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +50 -0
  44. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +23 -0
  45. package/build/primer/Form/Checkbox/index.ts +2 -0
  46. package/build/primer/Form/Input/Input.prop.ts +43 -0
  47. package/build/primer/Form/Input/Input.tsx +43 -0
  48. package/build/primer/Form/Input/__tests__/Input.int.story.tsx +54 -0
  49. package/build/primer/Form/Input/__tests__/Input.int.test.ts +15 -0
  50. package/build/primer/Form/Input/index.ts +2 -0
  51. package/build/primer/Form/Radio/Radio.prop.ts +30 -0
  52. package/build/primer/Form/Radio/Radio.tsx +38 -0
  53. package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +42 -0
  54. package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +13 -0
  55. package/build/primer/Form/Radio/index.ts +2 -0
  56. package/build/primer/Form/form-control.scss +4 -4
  57. package/build/primer/Form/form-select.scss +4 -4
  58. package/build/primer/Form/index.ts +19 -0
  59. package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +21 -0
  60. package/build/primer/Grid/DisplayTable/DisplayTable.tsx +68 -0
  61. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +289 -0
  62. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +27 -0
  63. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +9 -0
  64. package/build/primer/Grid/DisplayTable/index.ts +1 -0
  65. package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +59 -0
  66. package/build/primer/Grid/FlexGrid/FlexGrid.tsx +274 -0
  67. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +289 -0
  68. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +146 -0
  69. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +46 -0
  70. package/build/primer/Grid/FlexGrid/index.ts +2 -0
  71. package/build/primer/Grid/index.ts +9 -0
  72. package/build/primer/Icon/Icon.part.ts +1289 -0
  73. package/build/primer/Icon/Icon.prop.ts +1337 -0
  74. package/build/primer/Icon/Icon.tsx +49 -0
  75. package/build/primer/Icon/__tests__/Icon.int.story.tsx +58 -0
  76. package/build/primer/Icon/__tests__/Icon.int.test.ts +13 -0
  77. package/build/primer/Icon/index.ts +2 -0
  78. package/build/primer/Label/Label.mdx +13 -0
  79. package/build/primer/Label/Label.prop.ts +31 -0
  80. package/build/primer/Label/Label.tsx +27 -0
  81. package/build/primer/Label/__tests__/Label.int.story.tsx +19 -0
  82. package/build/primer/Label/__tests__/Label.int.test.ts +9 -0
  83. package/build/primer/Label/index.ts +1 -0
  84. package/build/primer/Label/mixins.scss +3 -3
  85. package/build/primer/Layout/container.scss +1 -1
  86. package/build/primer/Layout/grid-offset.scss +1 -1
  87. package/build/primer/Layout/grid.scss +2 -2
  88. package/build/primer/Loader/Loader.mdx +31 -0
  89. package/build/primer/Loader/Loader.prop.ts +16 -0
  90. package/build/primer/Loader/Loader.tsx +43 -0
  91. package/build/primer/Loader/__tests__/Loader.int.story.tsx +34 -0
  92. package/build/primer/Loader/__tests__/Loader.int.test.ts +21 -0
  93. package/build/primer/Loader/index.ts +2 -0
  94. package/build/primer/Navigation/Menu/Menu.prop.ts +26 -0
  95. package/build/primer/Navigation/Menu/Menu.tsx +42 -0
  96. package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +55 -0
  97. package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +57 -0
  98. package/build/primer/Navigation/Menu/index.ts +1 -0
  99. package/build/primer/Navigation/TabNav/TabNav.prop.ts +39 -0
  100. package/build/primer/Navigation/TabNav/TabNav.tsx +105 -0
  101. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +168 -0
  102. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +55 -0
  103. package/build/primer/Navigation/TabNav/index.ts +2 -0
  104. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +41 -0
  105. package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +106 -0
  106. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +140 -0
  107. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +81 -0
  108. package/build/primer/Navigation/UnderlineNav/index.ts +2 -0
  109. package/build/primer/Navigation/index.ts +12 -0
  110. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +53 -0
  111. package/build/primer/Pagination/PreviousNext/PreviousNext.scss +2 -2
  112. package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +71 -0
  113. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +48 -0
  114. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +15 -0
  115. package/build/primer/Pagination/PreviousNext/index.ts +2 -0
  116. package/build/primer/Pagination/index.ts +6 -0
  117. package/build/primer/Popover/Popover.mdx +190 -0
  118. package/build/primer/Popover/Popover.prop.ts +49 -0
  119. package/build/primer/Popover/Popover.tsx +80 -0
  120. package/build/primer/Popover/__tests__/Popover.int.story.tsx +216 -0
  121. package/build/primer/Popover/__tests__/Popover.int.test.ts +71 -0
  122. package/build/primer/Popover/index.ts +2 -0
  123. package/build/primer/Progress/Progress.mdx +31 -0
  124. package/build/primer/Progress/Progress.prop.ts +16 -0
  125. package/build/primer/Progress/Progress.tsx +19 -0
  126. package/build/primer/Progress/__tests__/Progress.int.story.tsx +28 -0
  127. package/build/primer/Progress/__tests__/Progress.int.test.ts +17 -0
  128. package/build/primer/Progress/index.ts +2 -0
  129. package/build/primer/Select/Select.mdx +19 -0
  130. package/build/primer/Select/Select.prop.ts +24 -0
  131. package/build/primer/Select/Select.scss +2 -2
  132. package/build/primer/Select/Select.tsx +58 -0
  133. package/build/primer/Select/__tests__/Select.int.story.tsx +38 -0
  134. package/build/primer/Select/__tests__/Select.int.test.ts +42 -0
  135. package/build/primer/Select/index.ts +2 -0
  136. package/build/primer/SelectMenu/SelectMenu.mdx +13 -0
  137. package/build/primer/SelectMenu/SelectMenu.prop.ts +25 -0
  138. package/build/primer/SelectMenu/SelectMenu.scss +4 -4
  139. package/build/primer/SelectMenu/SelectMenu.tsx +68 -0
  140. package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +50 -0
  141. package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +56 -0
  142. package/build/primer/SelectMenu/index.ts +1 -0
  143. package/build/primer/Subhead/Subhead.mdx +20 -0
  144. package/build/primer/Subhead/Subhead.prop.ts +10 -0
  145. package/build/primer/Subhead/Subhead.scss +3 -3
  146. package/build/primer/Subhead/Subhead.tsx +15 -0
  147. package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +23 -0
  148. package/build/primer/Subhead/__tests__/Subhead.int.test.ts +13 -0
  149. package/build/primer/Subhead/index.ts +1 -0
  150. package/build/primer/Toast/Toast.prop.ts +21 -0
  151. package/build/primer/Toast/Toast.scss +3 -3
  152. package/build/primer/Toast/Toast.tsx +38 -0
  153. package/build/primer/Toast/__tests__/Toast.int.story.tsx +50 -0
  154. package/build/primer/Toast/__tests__/Toast.int.test.ts +25 -0
  155. package/build/primer/Toast/index.ts +2 -0
  156. package/build/primer/index.ts +83 -0
  157. package/package.json +4 -4
  158. package/build/index.js +0 -12
  159. package/build/primer/Alert/Alert.js +0 -121
  160. package/build/primer/Alert/Alert.prop.js +0 -38
  161. package/build/primer/Alert/index.js +0 -19
  162. package/build/primer/Blankslate/Blankslate.js +0 -31
  163. package/build/primer/Blankslate/Blankslate.prop.js +0 -26
  164. package/build/primer/Blankslate/index.js +0 -19
  165. package/build/primer/Breadcrumb/Breadcrumb.js +0 -74
  166. package/build/primer/Breadcrumb/Breadcrumb.prop.js +0 -29
  167. package/build/primer/Breadcrumb/index.js +0 -19
  168. package/build/primer/Button/Button.js +0 -99
  169. package/build/primer/Button/Button.prop.js +0 -67
  170. package/build/primer/Button/index.js +0 -49
  171. package/build/primer/Dropdown/Dropdown.js +0 -104
  172. package/build/primer/Dropdown/Dropdown.prop.js +0 -34
  173. package/build/primer/Dropdown/index.js +0 -19
  174. package/build/primer/ErrorBoundary/ErrorBoundary.js +0 -59
  175. package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +0 -11
  176. package/build/primer/ErrorBoundary/index.js +0 -12
  177. package/build/primer/Form/Checkbox/Checkbox.js +0 -49
  178. package/build/primer/Form/Checkbox/Checkbox.prop.js +0 -36
  179. package/build/primer/Form/Checkbox/index.js +0 -19
  180. package/build/primer/Form/Input/Input.js +0 -56
  181. package/build/primer/Form/Input/Input.prop.js +0 -43
  182. package/build/primer/Form/Input/index.js +0 -25
  183. package/build/primer/Form/Radio/Radio.js +0 -48
  184. package/build/primer/Form/Radio/Radio.prop.js +0 -34
  185. package/build/primer/Form/Radio/index.js +0 -19
  186. package/build/primer/Form/index.js +0 -24
  187. package/build/primer/Grid/DisplayTable/DisplayTable.js +0 -58
  188. package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +0 -18
  189. package/build/primer/Grid/DisplayTable/index.js +0 -12
  190. package/build/primer/Grid/FlexGrid/FlexGrid.js +0 -244
  191. package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +0 -49
  192. package/build/primer/Grid/FlexGrid/index.js +0 -25
  193. package/build/primer/Grid/index.js +0 -14
  194. package/build/primer/Icon/Icon.js +0 -70
  195. package/build/primer/Icon/Icon.part.js +0 -1295
  196. package/build/primer/Icon/Icon.prop.js +0 -689
  197. package/build/primer/Icon/index.js +0 -25
  198. package/build/primer/Label/Label.js +0 -31
  199. package/build/primer/Label/Label.prop.js +0 -34
  200. package/build/primer/Label/index.js +0 -12
  201. package/build/primer/Loader/Loader.js +0 -65
  202. package/build/primer/Loader/Loader.prop.js +0 -21
  203. package/build/primer/Loader/index.js +0 -19
  204. package/build/primer/Navigation/Menu/Menu.js +0 -70
  205. package/build/primer/Navigation/Menu/Menu.prop.js +0 -28
  206. package/build/primer/Navigation/Menu/index.js +0 -12
  207. package/build/primer/Navigation/TabNav/TabNav.js +0 -125
  208. package/build/primer/Navigation/TabNav/TabNav.prop.js +0 -36
  209. package/build/primer/Navigation/TabNav/index.js +0 -19
  210. package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +0 -121
  211. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +0 -41
  212. package/build/primer/Navigation/UnderlineNav/index.js +0 -25
  213. package/build/primer/Navigation/index.js +0 -17
  214. package/build/primer/Pagination/PreviousNext/PreviousNext.js +0 -76
  215. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +0 -56
  216. package/build/primer/Pagination/PreviousNext/index.js +0 -19
  217. package/build/primer/Pagination/index.js +0 -11
  218. package/build/primer/Popover/Popover.js +0 -63
  219. package/build/primer/Popover/Popover.prop.js +0 -41
  220. package/build/primer/Popover/index.js +0 -25
  221. package/build/primer/Progress/Progress.js +0 -31
  222. package/build/primer/Progress/Progress.prop.js +0 -21
  223. package/build/primer/Progress/index.js +0 -19
  224. package/build/primer/Select/Select.js +0 -66
  225. package/build/primer/Select/Select.prop.js +0 -27
  226. package/build/primer/Select/index.js +0 -19
  227. package/build/primer/SelectMenu/SelectMenu.js +0 -95
  228. package/build/primer/SelectMenu/SelectMenu.prop.js +0 -26
  229. package/build/primer/SelectMenu/index.js +0 -12
  230. package/build/primer/Subhead/Subhead.js +0 -27
  231. package/build/primer/Subhead/Subhead.prop.js +0 -16
  232. package/build/primer/Subhead/index.js +0 -12
  233. package/build/primer/Toast/Toast.js +0 -55
  234. package/build/primer/Toast/Toast.prop.js +0 -26
  235. package/build/primer/Toast/index.js +0 -19
  236. package/build/primer/index.js +0 -87
  237. /package/build/primer/Form/Checkbox/{Checkbox.md → Checkbox.mdx} +0 -0
  238. /package/build/primer/Form/Checkbox/__tests__/__snapshots__/{Checkbox.int.test.js.snap → Checkbox.int.test.ts.snap} +0 -0
  239. /package/build/primer/Form/Input/{Input.md → Input.mdx} +0 -0
  240. /package/build/primer/Form/Input/__tests__/__snapshots__/{Input.int.test.js.snap → Input.int.test.ts.snap} +0 -0
  241. /package/build/primer/Form/Radio/{Radio.md → Radio.mdx} +0 -0
  242. /package/build/primer/Form/Radio/__tests__/__snapshots__/{Radio.int.test.js.snap → Radio.int.test.ts.snap} +0 -0
  243. /package/build/primer/Grid/DisplayTable/{DisplayTable.md → DisplayTable.mdx} +0 -0
  244. /package/build/primer/Grid/DisplayTable/__tests__/__snapshots__/{DisplayTable.int.test.js.snap → DisplayTable.int.test.ts.snap} +0 -0
  245. /package/build/primer/Grid/FlexGrid/{FlexGrid.md → FlexGrid.mdx} +0 -0
  246. /package/build/primer/Grid/FlexGrid/__tests__/__snapshots__/{FlexGrid.int.test.js.snap → FlexGrid.int.test.ts.snap} +0 -0
  247. /package/build/primer/Navigation/Menu/{Menu.md → Menu.mdx} +0 -0
  248. /package/build/primer/Navigation/Menu/__tests__/__snapshots__/{Menu.int.test.js.snap → Menu.int.test.ts.snap} +0 -0
  249. /package/build/primer/Navigation/TabNav/{TabNav.md → TabNav.mdx} +0 -0
  250. /package/build/primer/Navigation/TabNav/__tests__/__snapshots__/{TabNav.int.test.js.snap → TabNav.int.test.ts.snap} +0 -0
  251. /package/build/primer/Navigation/UnderlineNav/{UnderlineNav.md → UnderlineNav.mdx} +0 -0
  252. /package/build/primer/Navigation/UnderlineNav/__tests__/__snapshots__/{UnderlineNav.int.test.js.snap → UnderlineNav.int.test.ts.snap} +0 -0
  253. /package/build/primer/Pagination/PreviousNext/{PreviousNext.md → PreviousNext.mdx} +0 -0
  254. /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,2 @@
1
+ export { Checkbox } from './Checkbox'
2
+ export { checkboxState } from './Checkbox.prop'
@@ -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,2 @@
1
+ export { Input } from './Input'
2
+ export { inputType, inputState } from './Input.prop'
@@ -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
+ })
@@ -0,0 +1,2 @@
1
+ export { Radio } from './Radio'
2
+ export { radioState } from './Radio.prop'
@@ -1,7 +1,7 @@
1
- @import '@papillonbits/css/build/primer/support/variables/typography.scss';
2
- @import '@papillonbits/css/build/primer/support/variables/misc.scss';
3
- @import '@papillonbits/css/build/primer/support/mixins/misc.scss';
4
- @import '@papillonbits/css/build/primer/support/mixins/layout.scss';
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 '@papillonbits/css/build/primer/support/variables/typography.scss';
2
- @import '@papillonbits/css/build/primer/support/variables/layout.scss';
3
- @import '@papillonbits/css/build/primer/support/mixins/layout.scss';
4
- @import '@papillonbits/css/build/primer/support/mixins/color-modes.scss';
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
+ }