@jpmorganchase/mosaic-components 0.1.0-beta.71 → 0.1.0-beta.73

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 (192) hide show
  1. package/package.json +8 -5
  2. package/.turbo/turbo-build.log +0 -4
  3. package/CHANGELOG.md +0 -686
  4. package/src/Accordion/__tests__/index.test.tsx +0 -82
  5. package/src/Accordion/index.tsx +0 -88
  6. package/src/Accordion/styles.css.ts +0 -16
  7. package/src/AudioPlayer/__tests__/index.test.tsx +0 -19
  8. package/src/AudioPlayer/index.tsx +0 -163
  9. package/src/AudioPlayer/styles.css.ts +0 -65
  10. package/src/BrowserOnly.tsx +0 -17
  11. package/src/Button.tsx +0 -25
  12. package/src/Callout/__tests__/index.test.tsx +0 -102
  13. package/src/Callout/index.tsx +0 -62
  14. package/src/Callout/styles.css.ts +0 -77
  15. package/src/Card/index.tsx +0 -35
  16. package/src/Card/styles.css.ts +0 -23
  17. package/src/Cards.tsx +0 -25
  18. package/src/ComponentExample/index.tsx +0 -23
  19. package/src/ComponentExample/styles.css.ts +0 -25
  20. package/src/DataTable.tsx +0 -114
  21. package/src/EditionFilterView/__tests__/index.test.tsx +0 -49
  22. package/src/EditionFilterView/index.tsx +0 -108
  23. package/src/EditionFilterView/styles.css.ts +0 -8
  24. package/src/EditionTileLink/index.tsx +0 -90
  25. package/src/EditionTileLink/styles.css.ts +0 -95
  26. package/src/Feature/Feature.tsx +0 -92
  27. package/src/Feature/FeatureActions/index.tsx +0 -34
  28. package/src/Feature/FeatureActions/styles.css.ts +0 -15
  29. package/src/Feature/FeatureContent/index.tsx +0 -30
  30. package/src/Feature/FeatureContent/styles.css.ts +0 -13
  31. package/src/Feature/FeatureEyebrow/index.tsx +0 -19
  32. package/src/Feature/FeatureEyebrow/styles.css.ts +0 -11
  33. package/src/Feature/FeatureTitle/index.tsx +0 -18
  34. package/src/Feature/FeatureTitle/styles.css.ts +0 -9
  35. package/src/Feature/index.tsx +0 -10
  36. package/src/Feature/styles.css.ts +0 -58
  37. package/src/Features/index.tsx +0 -33
  38. package/src/Features/styles.css.ts +0 -10
  39. package/src/FilterToolbar/ContentArea/index.tsx +0 -12
  40. package/src/FilterToolbar/ContentArea/styles.css.ts +0 -16
  41. package/src/FilterToolbar/FilterDropdown/__tests__/index.test.tsx +0 -22
  42. package/src/FilterToolbar/FilterDropdown/index.tsx +0 -62
  43. package/src/FilterToolbar/FilterDropdown/styles.css.ts +0 -16
  44. package/src/FilterToolbar/PillGroup/__tests__/index.test.tsx +0 -26
  45. package/src/FilterToolbar/PillGroup/index.tsx +0 -36
  46. package/src/FilterToolbar/PillGroup/styles.css.ts +0 -17
  47. package/src/FilterToolbar/Search/__tests__/index.test.tsx +0 -34
  48. package/src/FilterToolbar/Search/index.tsx +0 -33
  49. package/src/FilterToolbar/Search/styles.css.ts +0 -9
  50. package/src/FilterToolbar/SortDropdown/__tests__/index.test.tsx +0 -22
  51. package/src/FilterToolbar/SortDropdown/defaultSort.js +0 -8
  52. package/src/FilterToolbar/SortDropdown/index.tsx +0 -53
  53. package/src/FilterToolbar/SortDropdown/styles.css.ts +0 -15
  54. package/src/FilterToolbar/Toolbar.tsx +0 -38
  55. package/src/FilterToolbar/ToolbarProvider.tsx +0 -94
  56. package/src/FilterToolbar/__tests__/Toolbar.test.tsx +0 -127
  57. package/src/FilterToolbar/__tests__/ToolbarProvider.test.tsx +0 -85
  58. package/src/FilterToolbar/index.tsx +0 -9
  59. package/src/FilterToolbar/styles.css.ts +0 -19
  60. package/src/FilterView/ContentArea/index.tsx +0 -24
  61. package/src/FilterView/ContentArea/styles.css.ts +0 -16
  62. package/src/FilterView/FilterView.tsx +0 -205
  63. package/src/FilterView/FilterViewProvider.tsx +0 -23
  64. package/src/FilterView/NoResults/index.tsx +0 -19
  65. package/src/FilterView/NoResults/styles.css.ts +0 -13
  66. package/src/FilterView/Pagination/index.tsx +0 -40
  67. package/src/FilterView/Pagination/styles.css.ts +0 -40
  68. package/src/FilterView/Pagination/usePagination.ts +0 -31
  69. package/src/FilterView/ResultCount/index.tsx +0 -23
  70. package/src/FilterView/ResultCount/styles.css.ts +0 -11
  71. package/src/FilterView/__tests__/index.test.tsx +0 -109
  72. package/src/FilterView/index.tsx +0 -5
  73. package/src/FilterView/useResultCount.tsx +0 -8
  74. package/src/FormattedContent.tsx +0 -75
  75. package/src/Grid/index.tsx +0 -29
  76. package/src/Grid/styles.css.ts +0 -13
  77. package/src/GridBase/index.tsx +0 -60
  78. package/src/GridBase/styles.css.ts +0 -19
  79. package/src/HelpLinks/index.tsx +0 -80
  80. package/src/HelpLinks/styles.css.ts +0 -32
  81. package/src/Hero/__tests__/index.test.tsx +0 -19
  82. package/src/Hero/index.tsx +0 -172
  83. package/src/Hero/styles.css.ts +0 -111
  84. package/src/Icon/index.tsx +0 -50
  85. package/src/ImageProvider.ts +0 -9
  86. package/src/Impact/index.tsx +0 -36
  87. package/src/Impact/styles.css.ts +0 -72
  88. package/src/Impacts.tsx +0 -25
  89. package/src/IsomorphicSuspense.tsx +0 -9
  90. package/src/Label/__tests__/index.test.tsx +0 -27
  91. package/src/Label/index.tsx +0 -42
  92. package/src/Label/styles.css.ts +0 -14
  93. package/src/Link/index.tsx +0 -83
  94. package/src/Link/styles.css.ts +0 -15
  95. package/src/LinkBase/index.tsx +0 -32
  96. package/src/LinkButton.css.ts +0 -19
  97. package/src/LinkButton.tsx +0 -22
  98. package/src/LinkProvider.ts +0 -9
  99. package/src/LinkText/index.tsx +0 -121
  100. package/src/LinkText/styles.css.ts +0 -30
  101. package/src/Links/index.tsx +0 -18
  102. package/src/Links/styles.css.ts +0 -13
  103. package/src/List/ListItem.tsx +0 -31
  104. package/src/List/OrderedList.tsx +0 -22
  105. package/src/List/UnorderedList.tsx +0 -35
  106. package/src/List/index.tsx +0 -3
  107. package/src/Markdown/AnchorHeading/__tests__/index.test.tsx +0 -56
  108. package/src/Markdown/AnchorHeading/index.css.ts +0 -64
  109. package/src/Markdown/AnchorHeading/index.tsx +0 -97
  110. package/src/Markdown/BlockQuote/index.css.ts +0 -6
  111. package/src/Markdown/BlockQuote/index.tsx +0 -21
  112. package/src/Markdown/Heading.tsx +0 -39
  113. package/src/Markdown/InlineCode.tsx +0 -10
  114. package/src/Markdown/Link.tsx +0 -11
  115. package/src/Markdown/Pre/index.css.ts +0 -35
  116. package/src/Markdown/Pre/index.tsx +0 -155
  117. package/src/Markdown/Table.tsx +0 -11
  118. package/src/Markdown/Tbody.tsx +0 -9
  119. package/src/Markdown/Td.tsx +0 -9
  120. package/src/Markdown/Th.tsx +0 -9
  121. package/src/Markdown/Thead.tsx +0 -9
  122. package/src/Markdown/ThematicBreak/index.css.ts +0 -5
  123. package/src/Markdown/ThematicBreak/index.tsx +0 -10
  124. package/src/Markdown/Tr.tsx +0 -9
  125. package/src/Markdown/__tests__/Heading.test.tsx +0 -56
  126. package/src/Markdown/index.tsx +0 -210
  127. package/src/Markdown/markdownElements.tsx +0 -52
  128. package/src/Markdown/withMarkdownSpacing/index.tsx +0 -33
  129. package/src/Markdown/withMarkdownSpacing/styles.css.ts +0 -7
  130. package/src/PageFilterView/index.tsx +0 -86
  131. package/src/PageFilterView/styles.css.ts +0 -8
  132. package/src/ReactLive/index.tsx +0 -71
  133. package/src/ReactLive/styles.css.ts +0 -28
  134. package/src/SecondaryNavbar/index.tsx +0 -55
  135. package/src/SecondaryNavbar/styles.css.ts +0 -27
  136. package/src/SectionHeading/__tests__/index.test.tsx +0 -20
  137. package/src/SectionHeading/index.tsx +0 -33
  138. package/src/SectionHeading/styles.css.ts +0 -15
  139. package/src/StickyHeader/index.tsx +0 -52
  140. package/src/StickyHeader/styles.css.ts +0 -17
  141. package/src/Story/index.tsx +0 -70
  142. package/src/Story/styles.css.ts +0 -37
  143. package/src/Tabs/index.tsx +0 -65
  144. package/src/Tabs/styles.css.ts +0 -7
  145. package/src/TabsBase/TabsBase.tsx +0 -89
  146. package/src/TabsBase/TabsButton.tsx +0 -30
  147. package/src/TabsBase/TabsLink.tsx +0 -30
  148. package/src/TabsBase/TabsMenuButton.tsx +0 -41
  149. package/src/TabsBase/index.ts +0 -4
  150. package/src/TabsBase/styles.css.ts +0 -64
  151. package/src/TabsBase/tabsMenuButton.css.ts +0 -25
  152. package/src/Tag/__tests__/index.test.tsx +0 -58
  153. package/src/Tag/index.tsx +0 -62
  154. package/src/Tag/styles.css.ts +0 -48
  155. package/src/ThemeProvider.tsx +0 -37
  156. package/src/TileBase/TileBase.tsx +0 -159
  157. package/src/TileBase/TileStateProvider.tsx +0 -52
  158. package/src/TileBase/index.ts +0 -2
  159. package/src/TileBase/styles.css.ts +0 -15
  160. package/src/TileButton/index.tsx +0 -68
  161. package/src/TileContent/index.tsx +0 -155
  162. package/src/TileContent/styles.css.ts +0 -229
  163. package/src/TileContentLabel/index.tsx +0 -74
  164. package/src/TileContentLabel/styles.css.ts +0 -22
  165. package/src/TileLink/index.tsx +0 -83
  166. package/src/TileLink/styles.css.ts +0 -9
  167. package/src/Tiles.tsx +0 -17
  168. package/src/Typography/Typography.tsx +0 -22
  169. package/src/Typography/index.tsx +0 -54
  170. package/src/Typography/withStyledTypography.tsx +0 -25
  171. package/src/VideoPlayer/__tests__/index.test.tsx +0 -13
  172. package/src/VideoPlayer/index.tsx +0 -179
  173. package/src/VideoPlayer/styles.css.ts +0 -87
  174. package/src/ViewStack/View.tsx +0 -19
  175. package/src/ViewStack/ViewStack.tsx +0 -50
  176. package/src/ViewStack/__tests__/index.test.tsx +0 -86
  177. package/src/ViewStack/index.tsx +0 -2
  178. package/src/__tests__/Button.test.tsx +0 -13
  179. package/src/__tests__/LinkButton.test.tsx +0 -16
  180. package/src/__tests__/ReactLive.test.tsx +0 -21
  181. package/src/canUseDOM.ts +0 -5
  182. package/src/common/types/index.ts +0 -52
  183. package/src/index.tsx +0 -59
  184. package/src/styles.ts +0 -45
  185. package/src/useBreakpoint.ts +0 -28
  186. package/src/useLockBodyScroll.ts +0 -16
  187. package/src/useOutsideClick.ts +0 -25
  188. package/src/useSize.ts +0 -32
  189. package/src/useSpacing.ts +0 -17
  190. package/src/utils/hasProtocol.ts +0 -1
  191. package/src/utils/index.ts +0 -1
  192. package/tsconfig.json +0 -8
@@ -1,77 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import {
3
- backgroundColor,
4
- calloutBorder,
5
- calloutColor,
6
- foregroundColor,
7
- paragraph,
8
- responsiveSprinkles
9
- } from '@jpmorganchase/mosaic-theme';
10
-
11
- const defaultBorder = calloutBorder({
12
- variant: 'note',
13
- borderTopWidth: 'thick',
14
- borderBottomWidth: 'medium'
15
- });
16
-
17
- export default {
18
- root: style([
19
- {
20
- width: '100%'
21
- },
22
- backgroundColor({ variant: 'regular' }),
23
- responsiveSprinkles({
24
- paddingTop: ['x4', 'x4', 'x4', 'x4'],
25
- paddingBottom: ['x4', 'x4', 'x4', 'x4']
26
- })
27
- ]),
28
- title: style([
29
- {
30
- verticalAlign: 'middle'
31
- },
32
- paragraph({ variant: 'paragraph1' })
33
- ]),
34
- content: style([
35
- paragraph({ variant: 'paragraph4' }),
36
- responsiveSprinkles({
37
- paddingLeft: ['x4', 'x4', 'x4', 'x4'],
38
- paddingTop: ['x2', 'x2', 'x2', 'x2']
39
- }),
40
- foregroundColor({ variant: 'high' })
41
- ]),
42
- icon: style([
43
- {
44
- verticalAlign: 'middle'
45
- },
46
- responsiveSprinkles({
47
- paddingLeft: ['x4', 'x4', 'x4', 'x4'],
48
- paddingRight: ['x2', 'x2', 'x2', 'x2']
49
- })
50
- ]),
51
- caution: calloutColor({ variant: 'caution' }),
52
- important: calloutColor({ variant: 'important' }),
53
- note: calloutColor({ variant: 'note' }),
54
- tip: calloutColor({ variant: 'tip' }),
55
- warning: calloutColor({ variant: 'warning' }),
56
- cautionBorder: calloutBorder({
57
- variant: 'caution',
58
- borderTopWidth: 'thick',
59
- borderBottomWidth: 'medium'
60
- }),
61
- importantBorder: calloutBorder({
62
- variant: 'important',
63
- borderTopWidth: 'thick',
64
- borderBottomWidth: 'medium'
65
- }),
66
- noteBorder: defaultBorder,
67
- tipBorder: calloutBorder({
68
- variant: 'tip',
69
- borderTopWidth: 'thick',
70
- borderBottomWidth: 'medium'
71
- }),
72
- warningBorder: calloutBorder({
73
- variant: 'warning',
74
- borderTopWidth: 'thick',
75
- borderBottomWidth: 'medium'
76
- })
77
- };
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
-
3
- import styles from './styles.css';
4
-
5
- /**
6
- * The props type for [[`Card`]].
7
- */
8
- export interface CardProps {
9
- /** The content of the card. */
10
- children: React.ReactNode;
11
- /** Additional class name for root class override. */
12
- className?: string;
13
- /** The step of the card. */
14
- step: string;
15
- /** The title of the card. */
16
- title: string;
17
- }
18
-
19
- /**
20
- * Renders a card. Cards are used to create a list of steps.
21
- * @example
22
- * ```tsx
23
- * <Card step="01" title="Create">
24
- * Starting with foundations and frameworks, create apps that leverage a common architecture to
25
- * make your build easier.
26
- * </Card>
27
- *```
28
- */
29
- export const Card: React.FC<CardProps> = ({ children, step, title, ...rest }: CardProps) => (
30
- <div {...rest}>
31
- <p className={styles.step}>{step}</p>
32
- <p className={styles.title}>{title}</p>
33
- <div className={styles.content}>{children}</div>
34
- </div>
35
- );
@@ -1,23 +0,0 @@
1
- import { heading, responsiveSprinkles, watermark } from '@jpmorganchase/mosaic-theme';
2
- import { style } from '@vanilla-extract/css';
3
-
4
- export default {
5
- content: style([
6
- {
7
- display: 'block'
8
- },
9
- responsiveSprinkles({ paddingTop: ['x6', 'x6', 'x6', 'x6'] })
10
- ]),
11
- step: style([
12
- {
13
- display: 'block',
14
- position: 'absolute'
15
- },
16
- watermark()
17
- ]),
18
- title: style([
19
- heading({ variant: 'heading6' }),
20
- { display: 'block' },
21
- responsiveSprinkles({ paddingTop: ['x6', 'x6', 'x6', 'x6'] })
22
- ])
23
- };
package/src/Cards.tsx DELETED
@@ -1,25 +0,0 @@
1
- import React, { Children, cloneElement, ReactElement } from 'react';
2
-
3
- import { Grid } from './Grid';
4
- import { CardProps } from './Card';
5
-
6
- export interface CardsProps {
7
- className?: string;
8
- children: ReactElement<CardProps>[];
9
- }
10
-
11
- function layoutChildren(children) {
12
- return Children.map(children, (child, index) =>
13
- cloneElement(child, {
14
- key: `card-${index}`,
15
- // disable any default spacing added by withMarkdownSpacing
16
- spacing: 'none'
17
- })
18
- );
19
- }
20
-
21
- export const Cards: React.FC<CardsProps> = ({ children, ...rest }) => (
22
- <Grid size="medium" {...rest}>
23
- {layoutChildren(children)}
24
- </Grid>
25
- );
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
-
4
- import styles from './styles.css';
5
-
6
- export interface ComponentExampleProps {
7
- /** Contents */
8
- children: React.ReactNode;
9
- /** Additional class name for overrides */
10
- className?: string;
11
- }
12
-
13
- export const ComponentExample: React.FC<ComponentExampleProps> = ({
14
- children,
15
- className,
16
- ...rest
17
- }: ComponentExampleProps) => (
18
- <div className={classnames(styles.root, className)} {...rest}>
19
- <div className={styles.innerContainer}>
20
- <div className={styles.component}>{children}</div>
21
- </div>
22
- </div>
23
- );
@@ -1,25 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { componentExample, responsiveSprinkles, siteBorder } from '@jpmorganchase/mosaic-theme';
3
-
4
- export default {
5
- component: componentExample({ backgroundColor: 'component' }),
6
- innerContainer: style([
7
- componentExample({ backgroundColor: 'inner' }),
8
- siteBorder({
9
- variant: 'boundary',
10
- borderTopWidth: 'thin',
11
- borderRightWidth: 'thin',
12
- borderBottomWidth: 'thin',
13
- borderLeftWidth: 'thin'
14
- })
15
- ]),
16
- root: style([
17
- style({
18
- width: '100%'
19
- }),
20
- style([componentExample({ backgroundColor: 'outer' })]),
21
- responsiveSprinkles({
22
- padding: ['x4', 'x4', 'x4', 'x4']
23
- })
24
- ])
25
- };
package/src/DataTable.tsx DELETED
@@ -1,114 +0,0 @@
1
- import React, { ReactElement, Ref } from 'react';
2
- import type { Column, PluginHook } from 'react-table';
3
- import classnames from 'clsx';
4
- import {
5
- table as tableRecipe,
6
- tbody as tbodyRecipe,
7
- td as tdRecipe,
8
- th as thRecipe,
9
- thead as theadRecipe,
10
- tr as trRecipe
11
- } from '@jpmorganchase/mosaic-theme';
12
-
13
- import { IsomorphicSuspense } from './IsomorphicSuspense';
14
-
15
- function TableHead({ headerGroups }) {
16
- return (
17
- <thead className={theadRecipe()}>
18
- {headerGroups.map((headerGroup, groupIndex) => (
19
- <tr
20
- className={trRecipe()}
21
- key={`headGroup${groupIndex}`}
22
- {...headerGroup.getHeaderGroupProps()}
23
- >
24
- {headerGroup.headers.map((column, columnIndex) => (
25
- <th
26
- className={thRecipe()}
27
- key={`headColumn${columnIndex}`}
28
- {...column.getHeaderProps()}
29
- >
30
- {column.render('Header')}
31
- </th>
32
- ))}
33
- </tr>
34
- ))}
35
- </thead>
36
- );
37
- }
38
-
39
- function TableBody({ getTableBodyProps, prepareRow, rows }) {
40
- return (
41
- <tbody className={tbodyRecipe()} {...getTableBodyProps()}>
42
- {rows.map((row, rowIndex) => {
43
- prepareRow(row);
44
- return (
45
- <tr className={trRecipe()} key={`bodyRow${rowIndex}`} {...row.getRowProps()}>
46
- {row.cells.map((cell, cellIndex) => (
47
- <td className={tdRecipe()} key={`bodyCell${cellIndex}`} {...cell.getCellProps()}>
48
- {cell.render('Cell')}
49
- </td>
50
- ))}
51
- </tr>
52
- );
53
- })}
54
- </tbody>
55
- );
56
- }
57
-
58
- export interface DataTableProps<RowData extends Record<string, unknown>> {
59
- /** Additional class name for root class override */
60
- className?: string;
61
- /** Column specs (refer to react-table API) */
62
- columns: Column<RowData>[];
63
- /** Data model (refer to react-table API) */
64
- data: Array<RowData>;
65
- /** Ref */
66
- ref?: Ref<HTMLDivElement>;
67
- /** If false, column headers will be hidden */
68
- showColumnHeaders?: boolean;
69
- /** Collection of react-table plugin hooks to be applied to the table (refer to react-table API) */
70
- plugins?: PluginHook<RowData>[];
71
- }
72
-
73
- const LazyTable = React.lazy(() =>
74
- import('react-table').then(({ useTable }) => ({
75
- default: React.forwardRef(
76
- ({ className, columns, data, plugins, showColumnHeaders }, ref: Ref<HTMLTableElement>) => {
77
- const { getTableProps, getTableBodyProps, headerGroups, prepareRow, rows } = useTable(
78
- {
79
- columns,
80
- data
81
- },
82
- ...plugins
83
- );
84
-
85
- return (
86
- <table className={classnames(className, tableRecipe())} {...getTableProps()} ref={ref}>
87
- {showColumnHeaders ? <TableHead headerGroups={headerGroups} /> : null}
88
- <TableBody getTableBodyProps={getTableBodyProps} prepareRow={prepareRow} rows={rows} />
89
- </table>
90
- );
91
- }
92
- )
93
- }))
94
- );
95
-
96
- const ForwardRefTable = <T extends Record<string, unknown>>(
97
- { className, columns, data, showColumnHeaders = true, plugins = [] }: DataTableProps<T>,
98
- ref: Ref<HTMLTableElement>
99
- ) => (
100
- <IsomorphicSuspense fallback={<span>Loading table...</span>}>
101
- <LazyTable
102
- className={className}
103
- columns={columns}
104
- data={data}
105
- plugins={plugins}
106
- ref={ref}
107
- showColumnHeaders={showColumnHeaders}
108
- />
109
- </IsomorphicSuspense>
110
- );
111
-
112
- export const DataTable = React.forwardRef(ForwardRefTable) as <T extends Record<string, unknown>>(
113
- p: DataTableProps<T> & { ref?: Ref<HTMLTableElement> }
114
- ) => ReactElement;
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
-
4
- import { EditionFilterView } from '../index';
5
-
6
- describe('GIVEN an EditionaFilterView', () => {
7
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
8
- observe: jest.fn(),
9
- unobserve: jest.fn(),
10
- disconnect: jest.fn()
11
- }));
12
- const singleGroupView = [1, 2].map(index => ({
13
- eyebrow: `EYEBROW${index}`,
14
- group: 'SINGLE_GROUP',
15
- link: `LINK_URL${index}`,
16
- publicationDate: `PUBLICATION_DATE${index}`,
17
- formattedDescription: `FORMATTED_DESCRIPTION${index}`,
18
- title: `TITLE${index}`
19
- }));
20
- const multiGroupView = [1, 2].map(index => ({
21
- eyebrow: `EYEBROW${index}`,
22
- group: `MULTI_GROUP${index}`,
23
- link: `LINK_URL${index}`,
24
- publicationDate: `PUBLICATION_DATE${index}`,
25
- formattedDescription: `FORMATTED_DESCRIPTION${index}`,
26
- title: `TITLE${index}`
27
- }));
28
- test('THEN the children are rendered', () => {
29
- // arrange
30
- render(<EditionFilterView className="custom-class" view={multiGroupView} />);
31
- // assert
32
- expect(screen.getByText('EYEBROW1')).toBeInTheDocument();
33
- expect(screen.getByText('FORMATTED_DESCRIPTION1')).toBeInTheDocument();
34
- expect(screen.getByText('FORMATTED_DESCRIPTION1')).toBeInTheDocument();
35
- expect(screen.getByText('TITLE1')).toBeInTheDocument();
36
- });
37
- test('THEN the filter view is not rendered for single group', () => {
38
- // arrange
39
- render(<EditionFilterView view={singleGroupView} />);
40
- // assert
41
- expect(screen.queryByText('All Results Displayed')).not.toBeInTheDocument();
42
- });
43
- test('THEN the filter view is rendered for multi-group', () => {
44
- // arrange
45
- render(<EditionFilterView view={multiGroupView} />);
46
- // assert
47
- expect(screen.getByText('All Results Displayed')).toBeInTheDocument();
48
- });
49
- });
@@ -1,108 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
-
4
- import { FilterResultCount, FilterView } from '../FilterView';
5
- import { FilterDropdown, FilterSortDropdown } from '../FilterToolbar';
6
- import { EditionTileLink } from '../EditionTileLink';
7
- import { FormattedContent } from '../FormattedContent';
8
- import styles from './styles.css';
9
-
10
- export const createCustomFilter = (view, filters) =>
11
- view.filter(({ group }) => filters.includes(group));
12
-
13
- export const createFiltersList = items =>
14
- items.reduce((allGroups, { group }) => {
15
- if (group && allGroups.indexOf(group) === -1) {
16
- return [...allGroups, group];
17
- }
18
- return allGroups;
19
- }, []);
20
-
21
- function editionSort(view: Edition[], sort = 'DESC'): Edition[] {
22
- return view.sort((sortableA, sortableB) => {
23
- const publicationDateA = new Date(sortableA.publicationDate);
24
- const publicationDateB = new Date(sortableB.publicationDate);
25
- if (sort === 'Newest') {
26
- return publicationDateB.valueOf() - publicationDateA.valueOf();
27
- }
28
- return publicationDateA.valueOf() - publicationDateB.valueOf();
29
- });
30
- }
31
-
32
- const itemToString = item => item;
33
- const labelButton = item => item;
34
-
35
- export type Edition = {
36
- eyebrow?: string;
37
- image?: string;
38
- group?: string;
39
- link: string;
40
- publicationDate: string;
41
- formattedDescription?: string;
42
- title?: string;
43
- };
44
-
45
- export type EditionFilterViewRenderer = (
46
- /** Edition data item */
47
- item: Edition,
48
- /** Edition item index in view */
49
- itemIndex: number
50
- ) => JSX.Element;
51
-
52
- export type EditionFilterViewProps = {
53
- /** Additional class name for root class override */
54
- className?: string;
55
- /** Data view of editions */
56
- view: Edition[];
57
- /** Item Renderer */
58
- ItemRenderer: EditionFilterViewRenderer;
59
- };
60
-
61
- export const DefaultEditionFilterViewRenderer: EditionFilterViewRenderer = (item, itemIndex) => (
62
- <EditionTileLink
63
- description={
64
- item.formattedDescription ? (
65
- <FormattedContent>{item.formattedDescription}</FormattedContent>
66
- ) : null
67
- }
68
- eyebrow={item.eyebrow}
69
- image={item.image}
70
- key={`editionTile-${itemIndex}`}
71
- link={item.link}
72
- title={item.title}
73
- />
74
- );
75
- export const EditionFilterView: React.FC<React.PropsWithChildren<EditionFilterViewProps>> = ({
76
- className,
77
- ItemRenderer = DefaultEditionFilterViewRenderer,
78
- view,
79
- ...rest
80
- }) => {
81
- const filtersList = createFiltersList(view);
82
- return (
83
- <FilterView<Edition>
84
- className={classnames(styles.root, className)}
85
- filter={createCustomFilter}
86
- itemRenderer={ItemRenderer}
87
- size="fullWidth"
88
- sort={editionSort}
89
- initialState={{ sort: 'Newest' }}
90
- view={view}
91
- enablePagination
92
- itemsPerPage={12}
93
- {...rest}
94
- >
95
- {filtersList.length > 1 ? (
96
- <>
97
- <FilterResultCount />
98
- <FilterDropdown source={filtersList} />
99
- </>
100
- ) : null}
101
- <FilterSortDropdown
102
- source={['Oldest', 'Newest']}
103
- itemToString={itemToString}
104
- labelButton={labelButton}
105
- />
106
- </FilterView>
107
- );
108
- };
@@ -1,8 +0,0 @@
1
- import { responsiveSprinkles } from '@jpmorganchase/mosaic-theme';
2
-
3
- export default {
4
- root: responsiveSprinkles({
5
- marginTop: ['x10', 'x10', 'x10', 'x10'],
6
- marginBottom: ['x20', 'x20', 'x25', 'x25']
7
- })
8
- };
@@ -1,90 +0,0 @@
1
- import React, { FC, ReactNode } from 'react';
2
-
3
- import { LinkBase } from '../LinkBase';
4
- import { LinkText } from '../LinkText';
5
- import { TileBase, useTileState } from '../TileBase';
6
- import { useImageComponent } from '../ImageProvider';
7
- import { useBreakpoint } from '../useBreakpoint';
8
- import styles, { imageRecipe, tileImageRecipe } from './styles.css';
9
-
10
- const PseudoLink = ({ children }) => {
11
- const {
12
- highlighted: [isHighlighted]
13
- } = useTileState();
14
- return (
15
- <LinkText endIcon="chevronRight" hovered={isHighlighted}>
16
- {children}
17
- </LinkText>
18
- );
19
- };
20
-
21
- export type EditionTileLinkProps = {
22
- /** Additional class name for root class override */
23
- className?: string;
24
- /** Link description */
25
- description?: ReactNode;
26
- /** Eyebrow text describing the content type */
27
- eyebrow?: string;
28
- /** Image associated with edition */
29
- image?: string;
30
- /** Placement of the image */
31
- imagePlacement?: 'left' | 'fullWidth';
32
- /** Link href */
33
- link: string;
34
- /** Edition title */
35
- title?: string;
36
- };
37
-
38
- const TileImage: FC<
39
- React.PropsWithChildren<Pick<EditionTileLinkProps, 'image' | 'imagePlacement'>>
40
- > = ({ image, imagePlacement }) => {
41
- const ImageComponent = useImageComponent();
42
- if (!image || !ImageComponent) {
43
- return null;
44
- }
45
- return (
46
- <div className={tileImageRecipe({ imagePlacement })}>
47
- <ImageComponent
48
- alt=""
49
- aria-describedby="tilecontent-description"
50
- className={imageRecipe({ imagePlacement })}
51
- fill
52
- src={image}
53
- />
54
- </div>
55
- );
56
- };
57
-
58
- export const EditionTileLink: React.FC<React.PropsWithChildren<EditionTileLinkProps>> = ({
59
- description,
60
- eyebrow = null,
61
- image,
62
- imagePlacement: imagePlacementProp,
63
- link,
64
- title,
65
- ...rest
66
- }) => {
67
- const breakpoint = useBreakpoint();
68
- const imagePlacementResponsive = breakpoint === 'mobile' ? 'fullWidth' : 'left';
69
- const imagePlacement = imagePlacementProp || imagePlacementResponsive;
70
- return (
71
- <TileBase className={styles.root} {...rest} size="fullWidth">
72
- <LinkBase
73
- className={styles.content}
74
- aria-labelledby="tilecontent-title"
75
- href={link}
76
- tabIndex={0}
77
- >
78
- {image ? <TileImage image={image} imagePlacement={imagePlacement} /> : null}
79
- <div>
80
- {eyebrow ? <p className={styles.eyebrow}>{eyebrow}</p> : null}
81
- {title ? <p className={styles.title}>{title}</p> : null}
82
- {description ? <div className={styles.description}>{description}</div> : null}
83
- <PseudoLink>
84
- <p className={styles.action}>Read More</p>
85
- </PseudoLink>
86
- </div>
87
- </LinkBase>
88
- </TileBase>
89
- );
90
- };
@@ -1,95 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
3
- import {
4
- action,
5
- caption,
6
- foregroundColor,
7
- heading,
8
- neutralBorder,
9
- paragraph,
10
- responsiveSprinkles
11
- } from '@jpmorganchase/mosaic-theme';
12
-
13
- export const tileImageRecipe = recipe({
14
- base: responsiveSprinkles({
15
- marginRight: ['none', 'x4', 'x4', 'x4'],
16
- marginBottom: ['x4', 'none', 'none', 'none']
17
- }),
18
- variants: {
19
- imagePlacement: {
20
- left: {
21
- width: '100px',
22
- height: '100px'
23
- },
24
- fullWidth: neutralBorder({ variant: 'high', borderBottomWidth: 'thick' })
25
- }
26
- },
27
- defaultVariants: {
28
- imagePlacement: 'left'
29
- }
30
- });
31
- export type TileImageVariants = RecipeVariants<typeof tileImageRecipe>;
32
-
33
- export const imageRecipe = recipe({
34
- variants: {
35
- imagePlacement: {
36
- left: style([
37
- {
38
- height: '100px',
39
- width: '100px'
40
- }
41
- ]),
42
- fullWidth: {
43
- width: '100%',
44
- height: '186px'
45
- }
46
- }
47
- },
48
- defaultVariants: {
49
- imagePlacement: 'left'
50
- }
51
- });
52
- export type ImageVariants = RecipeVariants<typeof imageRecipe>;
53
-
54
- export default {
55
- root: style([
56
- neutralBorder({ variant: 'low', borderBottomWidth: 'thin' }),
57
- foregroundColor({ variant: 'high' }),
58
- responsiveSprinkles({
59
- padding: ['x8', 'x8', 'x8', 'x8']
60
- })
61
- ]),
62
- content: style([
63
- {
64
- display: 'flex',
65
- width: '100%'
66
- },
67
- responsiveSprinkles({
68
- flexDirection: ['column', 'row', 'row', 'row']
69
- })
70
- ]),
71
- eyebrow: style([
72
- caption({ variant: 'caption2' }),
73
- responsiveSprinkles({
74
- marginBottom: ['x2', 'x2', 'x2', 'x2']
75
- })
76
- ]),
77
- title: style([
78
- heading({ variant: 'heading5' }),
79
- responsiveSprinkles({
80
- marginBottom: ['x2', 'x2', 'x2', 'x2']
81
- })
82
- ]),
83
- description: style([
84
- paragraph({ variant: 'paragraph4' }),
85
- responsiveSprinkles({
86
- marginBottom: ['x4', 'x4', 'x4', 'x4']
87
- })
88
- ]),
89
- action: style([
90
- action({ variant: 'action1' }),
91
- responsiveSprinkles({
92
- marginTop: ['x4', 'x4', 'x4', 'x4']
93
- })
94
- ])
95
- };