@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,82 +0,0 @@
1
- import React from 'react';
2
- import { render, waitFor, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { within } from '@testing-library/dom';
5
-
6
- import { Accordion, AccordionDetails, AccordionSection, AccordionSummary } from '../index';
7
-
8
- describe('GIVEN an `Accordion` component', () => {
9
- test('THEN should render a default state', () => {
10
- const { getAllByRole, queryAllByRole } = render(
11
- <Accordion>
12
- <AccordionSection>
13
- <AccordionSummary>SUMMARY 1</AccordionSummary>
14
- <AccordionDetails role="tabpanel">CONTENT 1</AccordionDetails>
15
- </AccordionSection>
16
- <AccordionSection>
17
- <AccordionSummary>SUMMARY 2</AccordionSummary>
18
- <AccordionDetails role="tabpanel">CONTENT 2</AccordionDetails>
19
- </AccordionSection>
20
- <AccordionSection>
21
- <AccordionSummary>SUMMARY 3</AccordionSummary>
22
- <AccordionDetails role="tabpanel">CONTENT 3</AccordionDetails>
23
- </AccordionSection>
24
- </Accordion>
25
- );
26
- // assert
27
- expect(getAllByRole('button').length).toEqual(3);
28
- expect(queryAllByRole('tabpanel').length).toEqual(0);
29
- });
30
-
31
- test('THEN should show and hide panels when the tab is clicked', async () => {
32
- render(
33
- <Accordion>
34
- <AccordionSection>
35
- <AccordionSummary>SUMMARY 1</AccordionSummary>
36
- <AccordionDetails role="tabpanel">CONTENT 1</AccordionDetails>
37
- </AccordionSection>
38
- <AccordionSection>
39
- <AccordionSummary>SUMMARY 2</AccordionSummary>
40
- <AccordionDetails role="tabpanel">CONTENT 2</AccordionDetails>
41
- </AccordionSection>
42
- <AccordionSection>
43
- <AccordionSummary>SUMMARY 3</AccordionSummary>
44
- <AccordionDetails role="tabpanel">CONTENT 3</AccordionDetails>
45
- </AccordionSection>
46
- </Accordion>
47
- );
48
- // assert
49
- expect(screen.queryAllByRole('button').length).toEqual(3);
50
- expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'false');
51
- expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-expanded', 'false');
52
- expect(screen.getAllByRole('button')[2]).toHaveAttribute('aria-expanded', 'false');
53
- expect(screen.queryAllByRole('tabpanel').length).toEqual(0); // nothing visible
54
-
55
- // act - click to open tab 2
56
- let tab2 = screen.getAllByRole('button')[1];
57
- userEvent.click(tab2);
58
- // assert
59
- await waitFor(() =>
60
- expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-expanded', 'true')
61
- );
62
- await waitFor(() => expect(screen.queryAllByRole('tabpanel').length).toEqual(1));
63
- expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'false');
64
- expect(screen.getAllByRole('button')[2]).toHaveAttribute('aria-expanded', 'false');
65
-
66
- const visiblePanelContent = within(screen.queryAllByRole('tabpanel')[0]).getByText('CONTENT 2');
67
- expect(visiblePanelContent).toBeDefined();
68
-
69
- // act - click to close tab 2
70
- tab2 = screen.getAllByRole('button')[1];
71
- userEvent.click(tab2);
72
-
73
- // assert
74
- await waitFor(() =>
75
- expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-expanded', 'false')
76
- );
77
- await waitFor(() => expect(screen.queryAllByRole('tabpanel').length).toEqual(0));
78
- expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'false');
79
- expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-expanded', 'false');
80
- expect(screen.getAllByRole('button')[2]).toHaveAttribute('aria-expanded', 'false');
81
- });
82
- });
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
- import {
4
- AccordionGroup,
5
- Accordion as SaltAccordion,
6
- AccordionHeader,
7
- AccordionPanel,
8
- type AccordionPanelProps,
9
- type AccordionHeaderProps
10
- } from '@salt-ds/core';
11
- import type { AccordionGroupProps as SaltAccordionGroupProps } from '@salt-ds/core';
12
- import styles from './styles.css';
13
-
14
- export interface Panel {
15
- expanded: boolean;
16
- summary: React.ReactNode;
17
- content: React.ReactNode;
18
- }
19
-
20
- export { Accordion as AccordionSection } from '@salt-ds/core';
21
-
22
- export const AccordionDetails = ({ className, ...rest }: AccordionPanelProps) => (
23
- <AccordionPanel className={classnames(styles.content, className)} {...rest} />
24
- );
25
-
26
- export const AccordionSummary = ({ className, ...rest }: AccordionHeaderProps) => (
27
- <AccordionHeader className={classnames(styles.summary, className)} {...rest} />
28
- );
29
-
30
- export interface AccordionProps extends SaltAccordionGroupProps {
31
- panels?: Panel[];
32
- }
33
-
34
- /**
35
- * Renders an Accordion. The Accordion component consists of a series of collapsible panels.
36
- * Use to maximise space and allow the user to show and hide content.
37
- * @example
38
- * ```tsx
39
- * <Accordion
40
- * panels={[
41
- * {
42
- * summary: 'Eliminate multiple identity credentials',
43
- * content: 'Your content will appear in its own expanded panel',
44
- * expanded: true
45
- * },
46
- * {
47
- * summary: 'Passwords and security questions',
48
- * content: 'Your content will appear in its own expanded panel',
49
- * expanded: false
50
- * }
51
- * ]}
52
- * />
53
- * ```
54
- *
55
- * or use it as a compound component and render richer content
56
- *
57
- * <Accordion>
58
- * <AccordionSection>
59
- * <AccordionSummary>
60
- * Summary Text
61
- * <AccordionSummary>
62
- * <AccordionDetails>
63
- * Accordion section detail
64
- * <AccordionDetails>
65
- * </AccordionSection>
66
- * </Accordion>
67
- */
68
- export const Accordion: React.FC<React.PropsWithChildren<AccordionProps>> = ({
69
- children,
70
- panels,
71
- ...rest
72
- }) => {
73
- let accordionChildren = children;
74
- /** Panels props to be deprecated in the future and create as a compound component */
75
- if (panels) {
76
- accordionChildren = panels.map((panelItem, panelIndex) => (
77
- <SaltAccordion
78
- defaultExpanded={panelItem.expanded}
79
- key={`panelItem-${panelIndex}`}
80
- value={`panelItem-${panelIndex}`}
81
- >
82
- <AccordionSummary>{panelItem.summary}</AccordionSummary>
83
- <AccordionDetails>{panelItem.content}</AccordionDetails>
84
- </SaltAccordion>
85
- ));
86
- }
87
- return <AccordionGroup {...rest}>{accordionChildren}</AccordionGroup>;
88
- };
@@ -1,16 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { heading, link, paragraph } from '@jpmorganchase/mosaic-theme';
3
-
4
- const styles = {
5
- summary: style([
6
- heading({ variant: 'heading6' }),
7
- link({ variant: 'selectable' }),
8
- {
9
- alignItems: 'center',
10
- display: 'flex'
11
- }
12
- ]),
13
- content: style([paragraph({ variant: 'paragraph2' })])
14
- };
15
-
16
- export default styles;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
-
4
- import { AudioPlayer } from '../index';
5
-
6
- describe('GIVEN an Audio Player', () => {
7
- test('THEN it has a title', () => {
8
- // arrange
9
- render(<AudioPlayer src="" title="A title" skipDuration={15} />);
10
- // assert
11
- expect(screen.getByText('A title')).toBeInTheDocument();
12
- });
13
- test('THEN the audio element has a src attribute defined', () => {
14
- // arrange
15
- render(<AudioPlayer src="https://abcd" title="A title" skipDuration={15} />);
16
- // assert
17
- expect(screen.getByLabelText('audio')).toHaveAttribute('src', 'https://abcd');
18
- });
19
- });
@@ -1,163 +0,0 @@
1
- import React, { useEffect, useState, useCallback } from 'react';
2
-
3
- import { ButtonBar, OrderedButton, Slider } from '@salt-ds/lab';
4
- import { Icon } from '../Icon';
5
-
6
- import { Caption3, Caption6 } from '../Typography';
7
- import styles from './styles.css';
8
-
9
- export interface AudioPlayerProps {
10
- src: string;
11
- skipDuration: 5 | 10 | 15;
12
- title?: string;
13
- }
14
-
15
- function timeFormat(durationS): string {
16
- const date = new Date(0);
17
- date.setSeconds(durationS);
18
- const timeString = date.toISOString().substring(11, 19);
19
- return timeString;
20
- }
21
-
22
- const forwardIconByVariant = {
23
- 5: 'forward5',
24
- 10: 'forward10',
25
- 15: 'forward15',
26
- 20: 'forward20'
27
- };
28
-
29
- const replayIconByVariant = {
30
- 5: 'replay5',
31
- 10: 'replay10',
32
- 15: 'replay15',
33
- 30: 'replay30'
34
- };
35
-
36
- export const AudioPlayer: React.FC<AudioPlayerProps> = ({ src, title, skipDuration = 15 }) => {
37
- const [audioElem, setAudioElem] = useState<HTMLAudioElement | null>(null);
38
- const [isPlaying, setIsPlaying] = useState(false);
39
- const [mute, setMute] = useState(false);
40
- const [playDisabled, setPlayDisabled] = useState(true);
41
- const [durationString, setDurationString] = useState('00:00:00');
42
- const [timeNowString, setTimeNowString] = useState('00:00:00');
43
- const [durationSeconds, setDurationSeconds] = useState(0);
44
- const [timeNowSeconds, setTimeNowSeconds] = useState(0);
45
-
46
- const audioRef = useCallback(audioNode => {
47
- setAudioElem(audioNode);
48
- }, []);
49
-
50
- const timeUpdate = useCallback(() => {
51
- if (audioElem) {
52
- const currentTimeFormatted = timeFormat(audioElem.currentTime);
53
- setTimeNowString(currentTimeFormatted);
54
- setTimeNowSeconds(audioElem.currentTime);
55
- }
56
- }, [audioElem]);
57
-
58
- const onLoad = useCallback(() => {
59
- if (audioElem) {
60
- const durationFormatted = timeFormat(audioElem.duration);
61
- setDurationString(durationFormatted);
62
- setDurationSeconds(audioElem.duration);
63
- setPlayDisabled(false);
64
- }
65
- }, [audioElem]);
66
-
67
- useEffect(() => {
68
- if (audioElem) {
69
- audioElem.addEventListener('timeupdate', timeUpdate);
70
- audioElem.addEventListener('loadedmetadata', onLoad);
71
- }
72
- return () => {
73
- if (audioElem) {
74
- audioElem.removeEventListener('timeupdate', timeUpdate);
75
- audioElem.removeEventListener('loadedmetadata', onLoad);
76
- }
77
- };
78
- }, [audioElem, onLoad, timeUpdate]);
79
-
80
- const handleFastforward = () => {
81
- if (audioElem) {
82
- audioElem.currentTime += skipDuration;
83
- }
84
- };
85
-
86
- const handleRewind = () => {
87
- if (audioElem) {
88
- audioElem.currentTime -= skipDuration;
89
- }
90
- };
91
-
92
- const handlePlay = () => {
93
- if (isPlaying) {
94
- audioElem?.pause();
95
- setIsPlaying(false);
96
- } else {
97
- audioElem?.play();
98
- setIsPlaying(true);
99
- }
100
- };
101
-
102
- const handleMute = () => {
103
- if (audioElem?.volume) {
104
- audioElem.volume = 0;
105
- setMute(true);
106
- } else if (audioElem) {
107
- audioElem.volume = 1;
108
- setMute(false);
109
- }
110
- };
111
-
112
- const handleSliderInput = e => {
113
- if (audioElem) {
114
- audioElem.currentTime = e;
115
- timeUpdate();
116
- }
117
- };
118
-
119
- return (
120
- <div className={styles.root}>
121
- <audio ref={audioRef} aria-label="audio" src={`${src}`} />
122
- <Caption3 className={styles.title}>{title}</Caption3>
123
- <div className={styles.sliderContainer}>
124
- <Caption6>{timeNowString}</Caption6>
125
- <Slider
126
- className={styles.slider}
127
- min={0}
128
- max={durationSeconds}
129
- value={timeNowSeconds}
130
- onChange={handleSliderInput}
131
- />
132
- <Caption6>{durationString}</Caption6>
133
- </div>
134
-
135
- <ButtonBar className={styles.buttonBar} stackAtBreakpoint={0} disableAutoAlignment={true}>
136
- <div>
137
- <a href={src} download target="_blank" rel="noreferrer">
138
- <OrderedButton variant="secondary" className={styles.button}>
139
- <Icon name="download" />
140
- </OrderedButton>
141
- </a>
142
- </div>
143
- <OrderedButton className={styles.button} variant="secondary" onClick={handleRewind}>
144
- <Icon name={replayIconByVariant[skipDuration]} />
145
- </OrderedButton>
146
- <OrderedButton
147
- className={styles.button}
148
- variant="secondary"
149
- onClick={handlePlay}
150
- disabled={playDisabled}
151
- >
152
- {isPlaying ? <Icon name="pauseSolid" /> : <Icon name="playSolid" />}
153
- </OrderedButton>
154
- <OrderedButton className={styles.button} variant="secondary" onClick={handleFastforward}>
155
- <Icon name={forwardIconByVariant[skipDuration]} />
156
- </OrderedButton>
157
- <OrderedButton variant="secondary" onClick={handleMute} className={styles.button}>
158
- {mute ? <Icon name="volumeOff" /> : <Icon name="volumeUp" />}
159
- </OrderedButton>
160
- </ButtonBar>
161
- </div>
162
- );
163
- };
@@ -1,65 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import {
3
- backgroundColor,
4
- responsiveStyle,
5
- responsiveSprinkles,
6
- vars
7
- } from '@jpmorganchase/mosaic-theme';
8
-
9
- export default {
10
- root: style([
11
- style({
12
- position: 'relative',
13
- left: '0px',
14
- top: '0px',
15
- display: 'flex',
16
- flexDirection: 'column',
17
- margin: vars.space.vertical.x4
18
- }),
19
- responsiveSprinkles({ padding: ['x2', 'x2', 'x4', 'x4'] }),
20
- backgroundColor({ variant: 'emphasis' })
21
- ]),
22
- title: style({
23
- display: 'flex',
24
- position: 'relative',
25
- justifyContent: 'center',
26
- alignItems: 'center',
27
- flexDirection: 'row'
28
- }),
29
- sliderContainer: style({
30
- display: 'flex',
31
- position: 'relative',
32
- justifyContent: 'center',
33
- alignItems: 'center',
34
- flexDirection: 'row',
35
- margin: vars.space.vertical.x2,
36
- ':hover': {
37
- cursor: 'pointer'
38
- }
39
- }),
40
- slider: style([
41
- responsiveStyle({
42
- mobile: { width: '145px' },
43
- tablet: { width: '350px' },
44
- web: { width: '280px' },
45
- desktop: { width: '350px' }
46
- }),
47
- style({
48
- position: 'relative',
49
- top: '-7px',
50
- margin: vars.space.horizontal.x2
51
- })
52
- ]),
53
- buttonBar: style({
54
- position: 'relative',
55
- justifyContent: 'center !important',
56
- alignItems: 'center',
57
- flexDirection: 'row'
58
- }),
59
- button: style({
60
- height: '32px',
61
- width: '32px',
62
- color: 'inherit',
63
- fill: 'currentColor'
64
- })
65
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
-
3
- import { canUseDOM } from './canUseDOM';
4
-
5
- export function BrowserOnly({
6
- children,
7
- fallback
8
- }: {
9
- children?: () => JSX.Element;
10
- fallback?: JSX.Element;
11
- }): JSX.Element | null {
12
- if (!canUseDOM || children == null) {
13
- return fallback || null;
14
- }
15
-
16
- return <>{children()}</>;
17
- }
package/src/Button.tsx DELETED
@@ -1,25 +0,0 @@
1
- import React, { type Ref, type ReactNode, forwardRef } from 'react';
2
- import classnames from 'clsx';
3
- import { Button as SaltButton, ButtonProps as SaltButtonProps } from '@salt-ds/core';
4
- import { button as buttonStyles } from '@jpmorganchase/mosaic-theme';
5
-
6
- export interface ButtonProps extends Omit<SaltButtonProps, 'variant'> {
7
- variant?: 'regular' | 'secondary' | 'cta';
8
- children?: ReactNode;
9
- }
10
-
11
- export const Button = forwardRef(
12
- (
13
- { children, className, variant = 'regular', ...rest }: ButtonProps,
14
- ref: Ref<HTMLButtonElement>
15
- ) => (
16
- <SaltButton
17
- ref={ref}
18
- className={classnames(buttonStyles({ variant }), className)}
19
- variant={variant === 'regular' ? 'primary' : variant}
20
- {...rest}
21
- >
22
- {children}
23
- </SaltButton>
24
- )
25
- );
@@ -1,102 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
-
4
- import { Callout } from '../index';
5
- import style from '../styles.css';
6
-
7
- describe('GIVEN a Callout', () => {
8
- describe('WHEN PROP: `title` is used', () => {
9
- test('THEN the Callout has a title', () => {
10
- // arrange
11
- render(<Callout title="A title" />);
12
- // assert
13
- expect(screen.getByText('A title')).toBeInTheDocument();
14
- });
15
- });
16
- describe('WHEN PROP: `className` is used', () => {
17
- test('THEN the root element has that class name', () => {
18
- // arrange
19
- render(<Callout title="A title" className="custom-class" />);
20
- // assert
21
- expect(screen.getByText('A title').parentElement).toHaveClass('custom-class');
22
- });
23
- });
24
- describe('WHEN PROP: `children` is used', () => {
25
- test('THEN the children are rendered within the Callout', () => {
26
- // arrange
27
- render(
28
- <Callout title="A title">
29
- <p id="children-elem">Custom children content</p>
30
- </Callout>
31
- );
32
- // assert
33
- expect(screen.queryByText('Custom children content')).toBeInTheDocument();
34
- });
35
- });
36
-
37
- describe('AND WHEN PROP: `variant` is NOT used', () => {
38
- test('THEN the Callout title is "Note"', () => {
39
- // arrange
40
- render(<Callout />);
41
- // assert
42
- const titleElem = screen.getByText('Note');
43
- expect(titleElem).toBeInTheDocument();
44
- expect(titleElem.parentElement).toHaveClass(style.noteBorder);
45
- });
46
- });
47
-
48
- describe('AND WHEN PROP: `variant` is "caution"', () => {
49
- test('THEN the Callout title is "Caution"', () => {
50
- // arrange
51
- render(<Callout variant="caution" />);
52
- // assert
53
- const titleElem = screen.getByText('Caution');
54
- expect(titleElem).toBeInTheDocument();
55
- expect(titleElem.parentElement).toHaveClass(style.cautionBorder);
56
- });
57
- });
58
-
59
- describe('AND WHEN PROP: `variant` is "important"', () => {
60
- test('THEN the Callout title is "Important"', () => {
61
- // arrange
62
- render(<Callout variant="important" />);
63
- // assert
64
- const titleElem = screen.getByText('Important');
65
- expect(titleElem).toBeInTheDocument();
66
- expect(titleElem.parentElement).toHaveClass(style.importantBorder);
67
- });
68
- });
69
-
70
- describe('AND WHEN PROP: `variant` is "note"', () => {
71
- test('THEN the Callout title is "Note"', () => {
72
- // arrange
73
- render(<Callout variant="note" />);
74
- // assert
75
- const titleElem = screen.getByText('Note');
76
- expect(titleElem).toBeInTheDocument();
77
- expect(titleElem.parentElement).toHaveClass(style.noteBorder);
78
- });
79
- });
80
-
81
- describe('AND WHEN PROP: `variant` is "tip"', () => {
82
- test('THEN the Callout title is "Tip"', () => {
83
- // arrange
84
- render(<Callout variant="tip" />);
85
- // assert
86
- const titleElem = screen.getByText('Tip');
87
- expect(titleElem).toBeInTheDocument();
88
- expect(titleElem.parentElement).toHaveClass(style.tipBorder);
89
- });
90
- });
91
-
92
- describe('AND WHEN PROP: `variant` is "warning"', () => {
93
- test('THEN the Callout title is "Warning"', () => {
94
- // arrange
95
- render(<Callout variant="warning" />);
96
- // assert
97
- const titleElem = screen.getByText('Warning');
98
- expect(titleElem).toBeInTheDocument();
99
- expect(titleElem.parentElement).toHaveClass(style.warningBorder);
100
- });
101
- });
102
- });
@@ -1,62 +0,0 @@
1
- import React from 'react';
2
- import classnames from 'clsx';
3
- import { Icon } from '../Icon';
4
-
5
- import styles from './styles.css';
6
-
7
- type Variant = 'caution' | 'important' | 'note' | 'tip' | 'warning';
8
- /**
9
- * The props type for [[`Callout`]].
10
- */
11
- export interface CalloutProps {
12
- /** The content of the callout. */
13
- children?: React.ReactNode;
14
- /** Additional class name for root class override. */
15
- className?: string;
16
- /** Title override. */
17
- title?: string;
18
- /**
19
- * The variant of the alert.
20
- *
21
- * @defaultValue `note`
22
- */
23
- variant?: Variant;
24
- }
25
-
26
- const iconByVariant = {
27
- caution: { title: 'Caution', name: 'warningSolid' },
28
- important: { title: 'Important', name: 'infoSolid' },
29
- note: { title: 'Note', name: 'infoSolid' },
30
- tip: { title: 'Tip', name: 'helpSolid' },
31
- warning: { title: 'Warning', name: 'errorSolid' }
32
- };
33
-
34
- /**
35
- * Renders a callout. Callouts sit within bodies of text and use visual cues to draw user attention to an important piece of information.
36
- *
37
- * @example
38
- * ```tsx
39
- * <Callout variant="tip">
40
- * Multiline Message text lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit
41
- * amet. Multiline Message text lorem ipsum dolor sit amet
42
- * </Callout>
43
- * ```
44
- *
45
- */
46
- export const Callout: React.FC<CalloutProps> = ({
47
- children,
48
- className,
49
- variant = 'note',
50
- title: titleProp,
51
- ...rest
52
- }: CalloutProps) => {
53
- const { name: iconName, title } = iconByVariant[variant.toLowerCase()];
54
- const titleText = titleProp !== undefined ? titleProp : title;
55
- return (
56
- <div className={classnames(styles.root, styles[`${variant}Border`], className)} {...rest}>
57
- <Icon className={classnames(styles.icon, styles[variant])} size={2} name={iconName} />
58
- <span className={styles.title}>{titleText}</span>
59
- <div className={styles.content}>{children}</div>
60
- </div>
61
- );
62
- };