@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.
Files changed (209) hide show
  1. package/build/index.js +12 -0
  2. package/build/primer/Alert/Alert.js +122 -0
  3. package/build/primer/Alert/Alert.prop.js +19 -0
  4. package/build/primer/Alert/index.js +19 -0
  5. package/build/primer/Blankslate/Blankslate.js +30 -0
  6. package/build/primer/Blankslate/Blankslate.prop.js +18 -0
  7. package/build/primer/Blankslate/index.js +19 -0
  8. package/build/primer/Breadcrumb/Breadcrumb.js +75 -0
  9. package/build/primer/Breadcrumb/Breadcrumb.prop.js +14 -0
  10. package/build/primer/Breadcrumb/index.js +19 -0
  11. package/build/primer/Button/Button.js +108 -0
  12. package/build/primer/Button/Button.prop.js +48 -0
  13. package/build/primer/Button/index.js +49 -0
  14. package/build/primer/Dropdown/Dropdown.js +102 -0
  15. package/build/primer/Dropdown/Dropdown.prop.js +18 -0
  16. package/build/primer/Dropdown/index.js +19 -0
  17. package/build/primer/ErrorBoundary/ErrorBoundary.js +59 -0
  18. package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +7 -0
  19. package/build/primer/ErrorBoundary/index.js +12 -0
  20. package/build/primer/Form/Checkbox/Checkbox.js +48 -0
  21. package/build/primer/Form/Checkbox/Checkbox.prop.js +22 -0
  22. package/build/primer/Form/Checkbox/index.js +19 -0
  23. package/build/primer/Form/Input/Input.js +55 -0
  24. package/build/primer/Form/Input/Input.prop.js +27 -0
  25. package/build/primer/Form/Input/index.js +25 -0
  26. package/build/primer/Form/Radio/Radio.js +47 -0
  27. package/build/primer/Form/Radio/Radio.prop.js +22 -0
  28. package/build/primer/Form/Radio/index.js +19 -0
  29. package/build/primer/Form/index.js +24 -0
  30. package/build/primer/Grid/DisplayTable/DisplayTable.js +57 -0
  31. package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +11 -0
  32. package/build/primer/Grid/DisplayTable/index.js +12 -0
  33. package/build/primer/Grid/FlexGrid/FlexGrid.js +249 -0
  34. package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +28 -0
  35. package/build/primer/Grid/FlexGrid/index.js +25 -0
  36. package/build/primer/Grid/index.js +14 -0
  37. package/build/primer/Icon/Icon.js +70 -0
  38. package/build/primer/Icon/Icon.part.js +1295 -0
  39. package/build/primer/Icon/Icon.prop.js +678 -0
  40. package/build/primer/Icon/index.js +25 -0
  41. package/build/primer/Label/Label.js +30 -0
  42. package/build/primer/Label/Label.prop.js +26 -0
  43. package/build/primer/Label/index.js +12 -0
  44. package/build/primer/Loader/Loader.js +64 -0
  45. package/build/primer/Loader/Loader.prop.js +15 -0
  46. package/build/primer/Loader/index.js +19 -0
  47. package/build/primer/Navigation/Menu/Menu.js +69 -0
  48. package/build/primer/Navigation/Menu/Menu.prop.js +10 -0
  49. package/build/primer/Navigation/Menu/index.js +12 -0
  50. package/build/primer/Navigation/TabNav/TabNav.js +124 -0
  51. package/build/primer/Navigation/TabNav/TabNav.prop.js +16 -0
  52. package/build/primer/Navigation/TabNav/index.js +19 -0
  53. package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +122 -0
  54. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +20 -0
  55. package/build/primer/Navigation/UnderlineNav/index.js +25 -0
  56. package/build/primer/Navigation/index.js +17 -0
  57. package/build/primer/Pagination/PreviousNext/PreviousNext.js +84 -0
  58. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +30 -0
  59. package/build/primer/Pagination/PreviousNext/index.js +19 -0
  60. package/build/primer/Pagination/index.js +11 -0
  61. package/build/primer/Popover/Popover.js +63 -0
  62. package/build/primer/Popover/Popover.prop.js +29 -0
  63. package/build/primer/Popover/index.js +25 -0
  64. package/build/primer/Progress/Progress.js +30 -0
  65. package/build/primer/Progress/Progress.prop.js +15 -0
  66. package/build/primer/Progress/index.js +19 -0
  67. package/build/primer/Select/Select.js +67 -0
  68. package/build/primer/Select/Select.prop.js +15 -0
  69. package/build/primer/Select/index.js +19 -0
  70. package/build/primer/SelectMenu/SelectMenu.js +94 -0
  71. package/build/primer/SelectMenu/SelectMenu.prop.js +10 -0
  72. package/build/primer/SelectMenu/index.js +12 -0
  73. package/build/primer/Subhead/Subhead.js +26 -0
  74. package/build/primer/Subhead/Subhead.prop.js +10 -0
  75. package/build/primer/Subhead/index.js +12 -0
  76. package/build/primer/Toast/Toast.js +54 -0
  77. package/build/primer/Toast/Toast.prop.js +18 -0
  78. package/build/primer/Toast/index.js +19 -0
  79. package/build/primer/index.js +87 -0
  80. package/package.json +5 -5
  81. package/build/index.ts +0 -1
  82. package/build/primer/Alert/Alert.prop.ts +0 -45
  83. package/build/primer/Alert/Alert.tsx +0 -101
  84. package/build/primer/Alert/__tests__/Alert.int.story.tsx +0 -86
  85. package/build/primer/Alert/__tests__/Alert.int.test.ts +0 -37
  86. package/build/primer/Alert/index.ts +0 -2
  87. package/build/primer/Blankslate/Blankslate.prop.ts +0 -26
  88. package/build/primer/Blankslate/Blankslate.tsx +0 -26
  89. package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +0 -43
  90. package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +0 -29
  91. package/build/primer/Blankslate/index.ts +0 -2
  92. package/build/primer/Breadcrumb/Breadcrumb.prop.ts +0 -28
  93. package/build/primer/Breadcrumb/Breadcrumb.tsx +0 -57
  94. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +0 -40
  95. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +0 -40
  96. package/build/primer/Breadcrumb/index.ts +0 -2
  97. package/build/primer/Button/Button.prop.ts +0 -77
  98. package/build/primer/Button/Button.tsx +0 -91
  99. package/build/primer/Button/__tests__/Button.int.story.tsx +0 -173
  100. package/build/primer/Button/__tests__/Button.int.test.ts +0 -191
  101. package/build/primer/Button/index.ts +0 -2
  102. package/build/primer/Dropdown/Dropdown.prop.ts +0 -33
  103. package/build/primer/Dropdown/Dropdown.tsx +0 -102
  104. package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +0 -43
  105. package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +0 -53
  106. package/build/primer/Dropdown/index.ts +0 -2
  107. package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +0 -5
  108. package/build/primer/ErrorBoundary/ErrorBoundary.tsx +0 -35
  109. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +0 -23
  110. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +0 -9
  111. package/build/primer/ErrorBoundary/index.ts +0 -1
  112. package/build/primer/Form/Checkbox/Checkbox.prop.ts +0 -34
  113. package/build/primer/Form/Checkbox/Checkbox.tsx +0 -40
  114. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +0 -50
  115. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +0 -23
  116. package/build/primer/Form/Checkbox/index.ts +0 -2
  117. package/build/primer/Form/Input/Input.prop.ts +0 -43
  118. package/build/primer/Form/Input/Input.tsx +0 -43
  119. package/build/primer/Form/Input/__tests__/Input.int.story.tsx +0 -54
  120. package/build/primer/Form/Input/__tests__/Input.int.test.ts +0 -15
  121. package/build/primer/Form/Input/index.ts +0 -2
  122. package/build/primer/Form/Radio/Radio.prop.ts +0 -30
  123. package/build/primer/Form/Radio/Radio.tsx +0 -38
  124. package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +0 -42
  125. package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +0 -13
  126. package/build/primer/Form/Radio/index.ts +0 -2
  127. package/build/primer/Form/index.ts +0 -19
  128. package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +0 -21
  129. package/build/primer/Grid/DisplayTable/DisplayTable.tsx +0 -68
  130. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +0 -289
  131. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +0 -27
  132. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +0 -9
  133. package/build/primer/Grid/DisplayTable/index.ts +0 -1
  134. package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +0 -59
  135. package/build/primer/Grid/FlexGrid/FlexGrid.tsx +0 -274
  136. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +0 -289
  137. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +0 -146
  138. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +0 -46
  139. package/build/primer/Grid/FlexGrid/index.ts +0 -2
  140. package/build/primer/Grid/index.ts +0 -9
  141. package/build/primer/Icon/Icon.part.ts +0 -1289
  142. package/build/primer/Icon/Icon.prop.ts +0 -1337
  143. package/build/primer/Icon/Icon.tsx +0 -49
  144. package/build/primer/Icon/__tests__/Icon.int.story.tsx +0 -58
  145. package/build/primer/Icon/__tests__/Icon.int.test.ts +0 -13
  146. package/build/primer/Icon/index.ts +0 -2
  147. package/build/primer/Label/Label.prop.ts +0 -31
  148. package/build/primer/Label/Label.tsx +0 -27
  149. package/build/primer/Label/__tests__/Label.int.story.tsx +0 -19
  150. package/build/primer/Label/__tests__/Label.int.test.ts +0 -9
  151. package/build/primer/Label/index.ts +0 -1
  152. package/build/primer/Loader/Loader.prop.ts +0 -16
  153. package/build/primer/Loader/Loader.tsx +0 -43
  154. package/build/primer/Loader/__tests__/Loader.int.story.tsx +0 -34
  155. package/build/primer/Loader/__tests__/Loader.int.test.ts +0 -21
  156. package/build/primer/Loader/index.ts +0 -2
  157. package/build/primer/Navigation/Menu/Menu.prop.ts +0 -26
  158. package/build/primer/Navigation/Menu/Menu.tsx +0 -42
  159. package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +0 -55
  160. package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +0 -57
  161. package/build/primer/Navigation/Menu/index.ts +0 -1
  162. package/build/primer/Navigation/TabNav/TabNav.prop.ts +0 -39
  163. package/build/primer/Navigation/TabNav/TabNav.tsx +0 -105
  164. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +0 -168
  165. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +0 -55
  166. package/build/primer/Navigation/TabNav/index.ts +0 -2
  167. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +0 -41
  168. package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +0 -106
  169. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +0 -140
  170. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +0 -81
  171. package/build/primer/Navigation/UnderlineNav/index.ts +0 -2
  172. package/build/primer/Navigation/index.ts +0 -12
  173. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +0 -53
  174. package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +0 -71
  175. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +0 -48
  176. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +0 -15
  177. package/build/primer/Pagination/PreviousNext/index.ts +0 -2
  178. package/build/primer/Pagination/index.ts +0 -6
  179. package/build/primer/Popover/Popover.prop.ts +0 -49
  180. package/build/primer/Popover/Popover.tsx +0 -80
  181. package/build/primer/Popover/__tests__/Popover.int.story.tsx +0 -216
  182. package/build/primer/Popover/__tests__/Popover.int.test.ts +0 -71
  183. package/build/primer/Popover/index.ts +0 -2
  184. package/build/primer/Progress/Progress.prop.ts +0 -16
  185. package/build/primer/Progress/Progress.tsx +0 -19
  186. package/build/primer/Progress/__tests__/Progress.int.story.tsx +0 -28
  187. package/build/primer/Progress/__tests__/Progress.int.test.ts +0 -17
  188. package/build/primer/Progress/index.ts +0 -2
  189. package/build/primer/Select/Select.prop.ts +0 -24
  190. package/build/primer/Select/Select.tsx +0 -58
  191. package/build/primer/Select/__tests__/Select.int.story.tsx +0 -38
  192. package/build/primer/Select/__tests__/Select.int.test.ts +0 -42
  193. package/build/primer/Select/index.ts +0 -2
  194. package/build/primer/SelectMenu/SelectMenu.prop.ts +0 -25
  195. package/build/primer/SelectMenu/SelectMenu.tsx +0 -68
  196. package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +0 -50
  197. package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +0 -56
  198. package/build/primer/SelectMenu/index.ts +0 -1
  199. package/build/primer/Subhead/Subhead.prop.ts +0 -10
  200. package/build/primer/Subhead/Subhead.tsx +0 -15
  201. package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +0 -23
  202. package/build/primer/Subhead/__tests__/Subhead.int.test.ts +0 -13
  203. package/build/primer/Subhead/index.ts +0 -1
  204. package/build/primer/Toast/Toast.prop.ts +0 -21
  205. package/build/primer/Toast/Toast.tsx +0 -38
  206. package/build/primer/Toast/__tests__/Toast.int.story.tsx +0 -50
  207. package/build/primer/Toast/__tests__/Toast.int.test.ts +0 -25
  208. package/build/primer/Toast/index.ts +0 -2
  209. package/build/primer/index.ts +0 -83
@@ -1,58 +0,0 @@
1
- import cx from 'classnames'
2
- import { v1 as uuidv1 } from 'uuid'
3
- import layoutStyles from '@papillonarts/css/build/primer/utilities/layout.scss'
4
- import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
5
- import { SelectProps, defaultProps, selectState } from './Select.prop'
6
- import styles from './Select.scss'
7
-
8
- export function Select({
9
- id = defaultProps.id,
10
- className = defaultProps.className,
11
- selectedText,
12
- items,
13
- onChange,
14
- state = defaultProps.state,
15
- }: SelectProps) {
16
- const indexItems = getIndexItems(items)
17
-
18
- const handleOnChange = (event) => {
19
- const indexItem = indexItems.find((item) => item.text === event.target.value)
20
- const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
21
-
22
- onChange({
23
- selectedText: indexItem.text,
24
- items: newIndexItems.map((newIndexItem) =>
25
- (({ text: newIndexItemText, isSelected: newIndexItemIsSelected }) => ({
26
- text: newIndexItemText,
27
- isSelected: newIndexItemIsSelected,
28
- }))(newIndexItem),
29
- ),
30
- })
31
- }
32
-
33
- return (
34
- <div className={cx(className, styles.select)}>
35
- <select
36
- id={id}
37
- // @ts-ignore
38
- readOnly={false}
39
- onChange={handleOnChange}
40
- className={cx(styles['select-menu'], layoutStyles['width-full'], {
41
- [styles['select-inactive']]: state === selectState.inactive,
42
- })}
43
- value={selectedText}
44
- >
45
- {items &&
46
- indexItems.map((indexItem) => {
47
- const { text, isSelected } = indexItem
48
-
49
- return (
50
- <option key={uuidv1()} value={text} selected={isSelected}>
51
- {text}
52
- </option>
53
- )
54
- })}
55
- </select>
56
- </div>
57
- )
58
- }
@@ -1,38 +0,0 @@
1
- import { action } from 'storybook/actions'
2
- import { withTests } from '@storybook/addon-jest'
3
- import { selectState } from '../Select.prop'
4
- import results from '../../../../../../.jest-test-results.json'
5
-
6
- const Select =
7
- process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
8
- ? require('../../../index').primer.Select.Select
9
- : require('../../../../build').primer.Select.Select
10
-
11
- export default {
12
- title: 'Primer/Atom/Select',
13
- component: Select,
14
- decorators: [withTests({ results })],
15
- parameters: { jest: ['Select.int.test.js'] },
16
- excludeStories: ['selectedText', 'items', 'custom'],
17
- }
18
-
19
- export const selectedText = 'Select'
20
-
21
- export const items = [
22
- { text: 'Select Item 1', isSelected: true },
23
- { text: 'Select Item 2', isSelected: false },
24
- { text: 'Select Item 3', isSelected: false },
25
- { text: 'Select Item 4', isSelected: false },
26
- ]
27
-
28
- export function custom(onChange) {
29
- return <Select selectedText={selectedText} items={items} onChange={onChange} />
30
- }
31
-
32
- export function regular() {
33
- return <Select selectedText={selectedText} items={items} onChange={action('onChange')} />
34
- }
35
-
36
- export function inactive() {
37
- return <Select selectedText={selectedText} items={items} onChange={action('onChange')} state={selectState.inactive} />
38
- }
@@ -1,42 +0,0 @@
1
- import { items, regular, inactive } from './Select.int.story'
2
-
3
- jest.mock('@papillonarts/library/array', () => ({
4
- getIndexItems: () => {},
5
- getIndexItemsWithSelected: () => {},
6
- }))
7
-
8
- const libraryArrayMockObject = require('@papillonarts/library/array')
9
-
10
- describe('<Select />', () => {
11
- const indexItemsDataObject = [
12
- { ...items[0], index: 0 },
13
- { ...items[1], index: 1 },
14
- { ...items[2], index: 2 },
15
- { ...items[3], index: 3 },
16
- ]
17
-
18
- const newIndexItemsWithSelectedDataObject = [
19
- { ...items[0], index: 0, isSelected: true },
20
- { ...items[1], index: 1, isSelected: false },
21
- { ...items[2], index: 2, isSelected: false },
22
- { ...items[3], index: 3, isSelected: false },
23
- ]
24
-
25
- beforeEach(() => {
26
- jest.spyOn(libraryArrayMockObject, 'getIndexItems').mockReturnValue(indexItemsDataObject)
27
-
28
- jest.spyOn(libraryArrayMockObject, 'getIndexItemsWithSelected').mockReturnValue(newIndexItemsWithSelectedDataObject)
29
- })
30
-
31
- afterEach(() => jest.clearAllMocks())
32
-
33
- describe('Render', () => {
34
- test('must match regular()', () => {
35
- expect(global.renderToJSON(regular())).toMatchSnapshot()
36
- })
37
-
38
- test('must match inacive()', () => {
39
- expect(global.renderToJSON(inactive())).toMatchSnapshot()
40
- })
41
- })
42
- })
@@ -1,2 +0,0 @@
1
- export { Select } from './Select'
2
- export { selectState } from './Select.prop'
@@ -1,25 +0,0 @@
1
- import { IconNameType } from '../Icon/Icon.prop'
2
-
3
- export const defaultProps = {
4
- className: null,
5
- title: null,
6
- }
7
-
8
- export interface AriaAttrType {
9
- haspopup: boolean
10
- }
11
-
12
- export interface ItemType {
13
- text: string
14
- isSelected: boolean
15
- }
16
-
17
- export interface SelectMenuProps {
18
- className?: string
19
- summary: string
20
- icon: IconNameType
21
- title?: string
22
- ariaAttr: AriaAttrType
23
- items: ItemType[]
24
- onClick: (value) => void
25
- }
@@ -1,68 +0,0 @@
1
- import cx from 'classnames'
2
- import { v1 as uuidv1 } from 'uuid'
3
- import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
4
- import { useRef, useState } from '@papillonarts/library/hooks'
5
- import utilityStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
6
- import detailsStyles from '@papillonarts/css/build/primer/utilities/details.scss'
7
- import { SelectMenuProps, defaultProps } from './SelectMenu.prop'
8
- import styles from './SelectMenu.scss'
9
- import buttonStyles from '../Button/Button.scss'
10
- import { Icon, iconSize } from '../Icon'
11
-
12
- export function SelectMenu({
13
- className = defaultProps.className,
14
- summary,
15
- icon,
16
- title = defaultProps.title,
17
- ariaAttr,
18
- items,
19
- onClick,
20
- }: SelectMenuProps) {
21
- const [indexItems, setIndexItems] = useState(getIndexItems(items))
22
- const { haspopup } = ariaAttr
23
- const details = useRef(null)
24
-
25
- return (
26
- <details ref={details} className={cx(className, detailsStyles['details-reset'], detailsStyles['details-overlay'])}>
27
- <summary className={cx(buttonStyles.btn, buttonStyles['btn-outline'])} aria-haspopup={haspopup}>
28
- {summary} <Icon className={cx(utilityStyles['ml-2'])} icon={icon} size={iconSize.small} />
29
- </summary>
30
- <div className={styles.SelectMenu}>
31
- <div className={styles['SelectMenu-modal']}>
32
- {title && (
33
- <header className={styles['SelectMenu-header']}>
34
- <h3 className={styles['SelectMenu-title']}>{title}</h3>
35
- <button className={styles['SelectMenu-closeButton']} type="button" />
36
- </header>
37
- )}
38
- <div className={styles['SelectMenu-list']}>
39
- {indexItems.map((indexItem) => {
40
- const { text } = indexItem
41
-
42
- return (
43
- <button
44
- type="button"
45
- key={uuidv1()}
46
- onClick={(e) => {
47
- e.preventDefault()
48
- const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
49
- setIndexItems(newIndexItems)
50
- onClick({
51
- ariaAttr,
52
- items: newIndexItems.map((newIndexItem) => (({ text, isSelected }) => ({ text, isSelected }))(newIndexItem)), // eslint-disable-line
53
- })
54
- details.current.removeAttribute('open')
55
- }}
56
- className={styles['SelectMenu-item']}
57
- role="menuitem"
58
- >
59
- {text}
60
- </button>
61
- )
62
- })}
63
- </div>
64
- </div>
65
- </div>
66
- </details>
67
- )
68
- }
@@ -1,50 +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 SelectMenu =
7
- process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
8
- ? require('../../../index').primer.SelectMenu
9
- : require('../../../../build').primer.SelectMenu
10
-
11
- export default {
12
- title: 'Primer/Molecule/SelectMenu',
13
- component: SelectMenu,
14
- decorators: [withTests({ results })],
15
- parameters: { jest: ['SelectMenu.int.test.js'] },
16
- excludeStories: ['summary', 'title', 'ariaAttr', 'items', 'custom'],
17
- }
18
-
19
- export const summary = 'Choose an item'
20
-
21
- export const title = 'Title'
22
-
23
- export const ariaAttr = {
24
- haspopup: true,
25
- current: 'page',
26
- }
27
-
28
- export const items = [
29
- { text: 'Item 1', isSelected: true },
30
- { text: 'Item 2', isSelected: false },
31
- { text: 'Item 3', isSelected: false },
32
- { text: 'Item 4', isSelected: false },
33
- ]
34
-
35
- export function custom(onClick) {
36
- return <SelectMenu summary={summary} icon={iconName.ChevronDown16} title={title} ariaAttr={ariaAttr} items={items} onClick={onClick} />
37
- }
38
-
39
- export function regular() {
40
- return (
41
- <SelectMenu
42
- summary={summary}
43
- icon={iconName.ChevronDown16}
44
- title={title}
45
- ariaAttr={ariaAttr}
46
- items={items}
47
- onClick={action('onClick')}
48
- />
49
- )
50
- }
@@ -1,56 +0,0 @@
1
- import { items, regular } from './SelectMenu.int.story'
2
-
3
- jest.mock('@papillonarts/library/array', () => ({
4
- getIndexItems: () => {},
5
- getIndexItemsWithSelected: () => {},
6
- }))
7
-
8
- jest.mock('@papillonarts/library/hooks', () => ({
9
- useRef: () => {},
10
- useState: () => {},
11
- }))
12
-
13
- const libraryArrayMockObject = require('@papillonarts/library/array')
14
- const libraryHooksMockObject = require('@papillonarts/library/hooks')
15
-
16
- describe('<SelectMenu />', () => {
17
- let indexItemsDataObject = [
18
- { ...items[0], index: 0 },
19
- { ...items[1], index: 1 },
20
- { ...items[2], index: 2 },
21
- { ...items[3], index: 3 },
22
- ]
23
-
24
- const newIndexItemsWithSelectedDataObject = [
25
- { ...items[0], index: 0, isSelected: true },
26
- { ...items[1], index: 1, isSelected: false },
27
- { ...items[2], index: 2, isSelected: false },
28
- { ...items[3], index: 3, isSelected: false },
29
- ]
30
-
31
- const setIndexItemsMockFn = jest.fn((indexItems) => {
32
- indexItemsDataObject = indexItems
33
- })
34
-
35
- beforeEach(() => {
36
- jest.spyOn(libraryArrayMockObject, 'getIndexItems').mockReturnValue(indexItemsDataObject)
37
-
38
- jest.spyOn(libraryArrayMockObject, 'getIndexItemsWithSelected').mockReturnValue(newIndexItemsWithSelectedDataObject)
39
-
40
- jest.spyOn(libraryHooksMockObject, 'useState').mockImplementation(() => [indexItemsDataObject, setIndexItemsMockFn])
41
-
42
- jest.spyOn(libraryHooksMockObject, 'useRef').mockImplementation(() => ({
43
- current: {
44
- removeAttribute: () => {},
45
- },
46
- }))
47
- })
48
-
49
- afterEach(() => jest.clearAllMocks())
50
-
51
- describe('Render', () => {
52
- test('must match regular()', () => {
53
- expect(global.renderToJSON(regular())).toMatchSnapshot()
54
- })
55
- })
56
- })
@@ -1 +0,0 @@
1
- export { SelectMenu } from './SelectMenu'
@@ -1,10 +0,0 @@
1
- export const defaultProps = {
2
- className: null,
3
- isSpacious: false,
4
- }
5
-
6
- export interface SubheadProps {
7
- className?: string
8
- heading: string
9
- isSpacious?: boolean
10
- }
@@ -1,15 +0,0 @@
1
- import cx from 'classnames'
2
- import { SubheadProps, defaultProps } from './Subhead.prop'
3
- import styles from './Subhead.scss'
4
-
5
- export function Subhead({ className = defaultProps.className, heading, isSpacious = defaultProps.isSpacious }: SubheadProps) {
6
- return (
7
- <div
8
- className={cx(className, styles.Subhead, {
9
- [styles['Subhead--spacious']]: isSpacious === true,
10
- })}
11
- >
12
- <div className={styles['Subhead-heading']}>{heading}</div>
13
- </div>
14
- )
15
- }
@@ -1,23 +0,0 @@
1
- import { withTests } from '@storybook/addon-jest'
2
- import results from '../../../../../../.jest-test-results.json'
3
-
4
- const Subhead =
5
- process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
6
- ? require('../../../index').primer.Subhead
7
- : require('../../../../build').primer.Subhead
8
-
9
- export default {
10
- title: 'Primer/Atom/Subhead',
11
- component: Subhead,
12
- decorators: [withTests({ results })],
13
- parameters: { jest: ['Subhead.int.test.js'] },
14
- excludeStories: ['custom'],
15
- }
16
-
17
- export function plain() {
18
- return <Subhead heading="Plain subhead" />
19
- }
20
-
21
- export function spacious() {
22
- return <Subhead heading="Spacious subhead" isSpacious={true} />
23
- }
@@ -1,13 +0,0 @@
1
- import { plain, spacious } from './Subhead.int.story'
2
-
3
- describe('<Subhead />', () => {
4
- describe('Render', () => {
5
- test('must match plain()', () => {
6
- expect(global.renderToJSON(plain())).toMatchSnapshot()
7
- })
8
-
9
- test('must match spacious()', () => {
10
- expect(global.renderToJSON(spacious())).toMatchSnapshot()
11
- })
12
- })
13
- })
@@ -1 +0,0 @@
1
- export { Subhead } from './Subhead'
@@ -1,21 +0,0 @@
1
- export const toastVariant = {
2
- info: 'info',
3
- success: 'success',
4
- warning: 'warning',
5
- error: 'error',
6
- }
7
-
8
- export const defaultProps = {
9
- className: null,
10
- variant: toastVariant.info,
11
- isDismissable: false,
12
- onClick: () => {},
13
- }
14
-
15
- export interface ToastProps {
16
- className?: string
17
- variant?: typeof toastVariant.info | typeof toastVariant.success | typeof toastVariant.warning | typeof toastVariant.error
18
- text: string
19
- isDismissable?: boolean
20
- onClick?: (value) => void
21
- }
@@ -1,38 +0,0 @@
1
- import cx from 'classnames'
2
- import paddingStyles from '@papillonarts/css/build/primer/utilities/padding.scss'
3
- import { ToastProps, defaultProps, toastVariant } from './Toast.prop'
4
- import styles from './Toast.scss'
5
- import { Icon, iconName, iconSize } from '../Icon'
6
-
7
- export function Toast({
8
- className = defaultProps.className,
9
- variant = defaultProps.variant,
10
- text,
11
- isDismissable = defaultProps.isDismissable,
12
- onClick = defaultProps.onClick,
13
- }: ToastProps) {
14
- return (
15
- <div className={cx(className, paddingStyles['p-1'])}>
16
- <div
17
- className={cx(styles.Toast, {
18
- [styles['Toast--success']]: variant === toastVariant.success,
19
- [styles['Toast--warning']]: variant === toastVariant.warning,
20
- [styles['Toast--error']]: variant === toastVariant.error,
21
- })}
22
- >
23
- <span className={styles['Toast-icon']}>
24
- {variant === toastVariant.info && <Icon icon={iconName.Info16} />}
25
- {variant === toastVariant.success && <Icon icon={iconName.Check16} />}
26
- {variant === toastVariant.warning && <Icon icon={iconName.Alert16} />}
27
- {variant === toastVariant.error && <Icon icon={iconName.Stop16} />}
28
- </span>
29
- <span className={styles['Toast-content']}>{text}</span>
30
- {isDismissable && (
31
- <button type="button" className={styles['Toast-dismissButton']} onClick={onClick}>
32
- <Icon icon={iconName.X16} size={iconSize.small} />
33
- </button>
34
- )}
35
- </div>
36
- </div>
37
- )
38
- }
@@ -1,50 +0,0 @@
1
- import { action } from 'storybook/actions'
2
- import { withTests } from '@storybook/addon-jest'
3
- import { toastVariant } from '../Toast.prop'
4
- import results from '../../../../../../.jest-test-results.json'
5
-
6
- const text = {
7
- custom: 'Toast message goes here',
8
- info: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.Aenean massa. Cum sociis natoquepenatibus et ma',
9
- success: 'Success message goes here',
10
- warning: 'Warning message goes here',
11
- error: 'Error message goes here',
12
- dismissable: 'This toast is dismissable.',
13
- }
14
-
15
- const Toast =
16
- process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
17
- ? require('../../../index').primer.Toast.Toast
18
- : require('../../../../build').primer.Toast.Toast
19
-
20
- export default {
21
- title: 'Primer/Molecule/Toast',
22
- component: Toast,
23
- decorators: [withTests({ results })],
24
- parameters: { jest: ['Toast.int.test.js'] },
25
- excludeStories: ['custom'],
26
- }
27
-
28
- export function custom(onClick) {
29
- return <Toast text={text.custom} isDismissable={true} onClick={onClick} />
30
- }
31
-
32
- export function info() {
33
- return <Toast variant={toastVariant.info} text={text.info} />
34
- }
35
-
36
- export function success() {
37
- return <Toast variant={toastVariant.success} text={text.success} />
38
- }
39
-
40
- export function warning() {
41
- return <Toast variant={toastVariant.warning} text={text.warning} />
42
- }
43
-
44
- export function error() {
45
- return <Toast variant={toastVariant.error} text={text.error} />
46
- }
47
-
48
- export function dismissable() {
49
- return <Toast variant={toastVariant.info} text={text.dismissable} isDismissable={true} onClick={action('onClick')} />
50
- }
@@ -1,25 +0,0 @@
1
- import { info, success, warning, error, dismissable } from './Toast.int.story'
2
-
3
- describe('<Button />', () => {
4
- describe('Render', () => {
5
- test('must match info()', () => {
6
- expect(global.renderToJSON(info())).toMatchSnapshot()
7
- })
8
-
9
- test('must match success()', () => {
10
- expect(global.renderToJSON(success())).toMatchSnapshot()
11
- })
12
-
13
- test('must match warning()', () => {
14
- expect(global.renderToJSON(warning())).toMatchSnapshot()
15
- })
16
-
17
- test('must match error()', () => {
18
- expect(global.renderToJSON(error())).toMatchSnapshot()
19
- })
20
-
21
- test('must match dismissable()', () => {
22
- expect(global.renderToJSON(dismissable())).toMatchSnapshot()
23
- })
24
- })
25
- })
@@ -1,2 +0,0 @@
1
- export { Toast } from './Toast'
2
- export { toastVariant } from './Toast.prop'
@@ -1,83 +0,0 @@
1
- import { Alert, alertVariant } from './Alert'
2
- import { Breadcrumb, breadcrumbState } from './Breadcrumb'
3
- import { Blankslate, blankslateVariant } from './Blankslate'
4
- import { Button, buttonElement, buttonVariant, buttonSize, buttonState, iconAlignment, buttonInputType } from './Button'
5
- import { Dropdown, dropdownState } from './Dropdown'
6
- import { ErrorBoundary } from './ErrorBoundary'
7
- import { Form } from './Form'
8
- import { Grid } from './Grid'
9
- import { Icon, iconName, iconSize } from './Icon'
10
- import { Label } from './Label'
11
- import { Loader, loaderVariant } from './Loader'
12
- import { Navigation } from './Navigation'
13
- import { Pagination } from './Pagination'
14
- import { Popover, popoverVariant, popoverSize } from './Popover'
15
- import { Progress, progressVariant } from './Progress'
16
- import { Select, selectState } from './Select'
17
- import { SelectMenu } from './SelectMenu'
18
- import { Subhead } from './Subhead'
19
- import { Toast, toastVariant } from './Toast'
20
-
21
- import '@papillonarts/css/build/primer/index.scss'
22
-
23
- export const primer = {
24
- Alert: {
25
- Alert,
26
- alertVariant,
27
- },
28
- Breadcrumb: {
29
- Breadcrumb,
30
- breadcrumbState,
31
- },
32
- Blankslate: {
33
- Blankslate,
34
- blankslateVariant,
35
- },
36
- Button: {
37
- Button,
38
- buttonElement,
39
- buttonVariant,
40
- buttonSize,
41
- buttonState,
42
- iconAlignment,
43
- buttonInputType,
44
- },
45
- Dropdown: {
46
- Dropdown,
47
- dropdownState,
48
- },
49
- ErrorBoundary,
50
- Form,
51
- Grid,
52
- Icon: {
53
- Icon,
54
- iconName,
55
- iconSize,
56
- },
57
- Label,
58
- Loader: {
59
- Loader,
60
- loaderVariant,
61
- },
62
- Navigation,
63
- Pagination,
64
- Popover: {
65
- Popover,
66
- popoverVariant,
67
- popoverSize,
68
- },
69
- Progress: {
70
- Progress,
71
- progressVariant,
72
- },
73
- Select: {
74
- Select,
75
- selectState,
76
- },
77
- SelectMenu,
78
- Subhead,
79
- Toast: {
80
- Toast,
81
- toastVariant,
82
- },
83
- }