@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.
- package/package.json +8 -5
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -686
- package/src/Accordion/__tests__/index.test.tsx +0 -82
- package/src/Accordion/index.tsx +0 -88
- package/src/Accordion/styles.css.ts +0 -16
- package/src/AudioPlayer/__tests__/index.test.tsx +0 -19
- package/src/AudioPlayer/index.tsx +0 -163
- package/src/AudioPlayer/styles.css.ts +0 -65
- package/src/BrowserOnly.tsx +0 -17
- package/src/Button.tsx +0 -25
- package/src/Callout/__tests__/index.test.tsx +0 -102
- package/src/Callout/index.tsx +0 -62
- package/src/Callout/styles.css.ts +0 -77
- package/src/Card/index.tsx +0 -35
- package/src/Card/styles.css.ts +0 -23
- package/src/Cards.tsx +0 -25
- package/src/ComponentExample/index.tsx +0 -23
- package/src/ComponentExample/styles.css.ts +0 -25
- package/src/DataTable.tsx +0 -114
- package/src/EditionFilterView/__tests__/index.test.tsx +0 -49
- package/src/EditionFilterView/index.tsx +0 -108
- package/src/EditionFilterView/styles.css.ts +0 -8
- package/src/EditionTileLink/index.tsx +0 -90
- package/src/EditionTileLink/styles.css.ts +0 -95
- package/src/Feature/Feature.tsx +0 -92
- package/src/Feature/FeatureActions/index.tsx +0 -34
- package/src/Feature/FeatureActions/styles.css.ts +0 -15
- package/src/Feature/FeatureContent/index.tsx +0 -30
- package/src/Feature/FeatureContent/styles.css.ts +0 -13
- package/src/Feature/FeatureEyebrow/index.tsx +0 -19
- package/src/Feature/FeatureEyebrow/styles.css.ts +0 -11
- package/src/Feature/FeatureTitle/index.tsx +0 -18
- package/src/Feature/FeatureTitle/styles.css.ts +0 -9
- package/src/Feature/index.tsx +0 -10
- package/src/Feature/styles.css.ts +0 -58
- package/src/Features/index.tsx +0 -33
- package/src/Features/styles.css.ts +0 -10
- package/src/FilterToolbar/ContentArea/index.tsx +0 -12
- package/src/FilterToolbar/ContentArea/styles.css.ts +0 -16
- package/src/FilterToolbar/FilterDropdown/__tests__/index.test.tsx +0 -22
- package/src/FilterToolbar/FilterDropdown/index.tsx +0 -62
- package/src/FilterToolbar/FilterDropdown/styles.css.ts +0 -16
- package/src/FilterToolbar/PillGroup/__tests__/index.test.tsx +0 -26
- package/src/FilterToolbar/PillGroup/index.tsx +0 -36
- package/src/FilterToolbar/PillGroup/styles.css.ts +0 -17
- package/src/FilterToolbar/Search/__tests__/index.test.tsx +0 -34
- package/src/FilterToolbar/Search/index.tsx +0 -33
- package/src/FilterToolbar/Search/styles.css.ts +0 -9
- package/src/FilterToolbar/SortDropdown/__tests__/index.test.tsx +0 -22
- package/src/FilterToolbar/SortDropdown/defaultSort.js +0 -8
- package/src/FilterToolbar/SortDropdown/index.tsx +0 -53
- package/src/FilterToolbar/SortDropdown/styles.css.ts +0 -15
- package/src/FilterToolbar/Toolbar.tsx +0 -38
- package/src/FilterToolbar/ToolbarProvider.tsx +0 -94
- package/src/FilterToolbar/__tests__/Toolbar.test.tsx +0 -127
- package/src/FilterToolbar/__tests__/ToolbarProvider.test.tsx +0 -85
- package/src/FilterToolbar/index.tsx +0 -9
- package/src/FilterToolbar/styles.css.ts +0 -19
- package/src/FilterView/ContentArea/index.tsx +0 -24
- package/src/FilterView/ContentArea/styles.css.ts +0 -16
- package/src/FilterView/FilterView.tsx +0 -205
- package/src/FilterView/FilterViewProvider.tsx +0 -23
- package/src/FilterView/NoResults/index.tsx +0 -19
- package/src/FilterView/NoResults/styles.css.ts +0 -13
- package/src/FilterView/Pagination/index.tsx +0 -40
- package/src/FilterView/Pagination/styles.css.ts +0 -40
- package/src/FilterView/Pagination/usePagination.ts +0 -31
- package/src/FilterView/ResultCount/index.tsx +0 -23
- package/src/FilterView/ResultCount/styles.css.ts +0 -11
- package/src/FilterView/__tests__/index.test.tsx +0 -109
- package/src/FilterView/index.tsx +0 -5
- package/src/FilterView/useResultCount.tsx +0 -8
- package/src/FormattedContent.tsx +0 -75
- package/src/Grid/index.tsx +0 -29
- package/src/Grid/styles.css.ts +0 -13
- package/src/GridBase/index.tsx +0 -60
- package/src/GridBase/styles.css.ts +0 -19
- package/src/HelpLinks/index.tsx +0 -80
- package/src/HelpLinks/styles.css.ts +0 -32
- package/src/Hero/__tests__/index.test.tsx +0 -19
- package/src/Hero/index.tsx +0 -172
- package/src/Hero/styles.css.ts +0 -111
- package/src/Icon/index.tsx +0 -50
- package/src/ImageProvider.ts +0 -9
- package/src/Impact/index.tsx +0 -36
- package/src/Impact/styles.css.ts +0 -72
- package/src/Impacts.tsx +0 -25
- package/src/IsomorphicSuspense.tsx +0 -9
- package/src/Label/__tests__/index.test.tsx +0 -27
- package/src/Label/index.tsx +0 -42
- package/src/Label/styles.css.ts +0 -14
- package/src/Link/index.tsx +0 -83
- package/src/Link/styles.css.ts +0 -15
- package/src/LinkBase/index.tsx +0 -32
- package/src/LinkButton.css.ts +0 -19
- package/src/LinkButton.tsx +0 -22
- package/src/LinkProvider.ts +0 -9
- package/src/LinkText/index.tsx +0 -121
- package/src/LinkText/styles.css.ts +0 -30
- package/src/Links/index.tsx +0 -18
- package/src/Links/styles.css.ts +0 -13
- package/src/List/ListItem.tsx +0 -31
- package/src/List/OrderedList.tsx +0 -22
- package/src/List/UnorderedList.tsx +0 -35
- package/src/List/index.tsx +0 -3
- package/src/Markdown/AnchorHeading/__tests__/index.test.tsx +0 -56
- package/src/Markdown/AnchorHeading/index.css.ts +0 -64
- package/src/Markdown/AnchorHeading/index.tsx +0 -97
- package/src/Markdown/BlockQuote/index.css.ts +0 -6
- package/src/Markdown/BlockQuote/index.tsx +0 -21
- package/src/Markdown/Heading.tsx +0 -39
- package/src/Markdown/InlineCode.tsx +0 -10
- package/src/Markdown/Link.tsx +0 -11
- package/src/Markdown/Pre/index.css.ts +0 -35
- package/src/Markdown/Pre/index.tsx +0 -155
- package/src/Markdown/Table.tsx +0 -11
- package/src/Markdown/Tbody.tsx +0 -9
- package/src/Markdown/Td.tsx +0 -9
- package/src/Markdown/Th.tsx +0 -9
- package/src/Markdown/Thead.tsx +0 -9
- package/src/Markdown/ThematicBreak/index.css.ts +0 -5
- package/src/Markdown/ThematicBreak/index.tsx +0 -10
- package/src/Markdown/Tr.tsx +0 -9
- package/src/Markdown/__tests__/Heading.test.tsx +0 -56
- package/src/Markdown/index.tsx +0 -210
- package/src/Markdown/markdownElements.tsx +0 -52
- package/src/Markdown/withMarkdownSpacing/index.tsx +0 -33
- package/src/Markdown/withMarkdownSpacing/styles.css.ts +0 -7
- package/src/PageFilterView/index.tsx +0 -86
- package/src/PageFilterView/styles.css.ts +0 -8
- package/src/ReactLive/index.tsx +0 -71
- package/src/ReactLive/styles.css.ts +0 -28
- package/src/SecondaryNavbar/index.tsx +0 -55
- package/src/SecondaryNavbar/styles.css.ts +0 -27
- package/src/SectionHeading/__tests__/index.test.tsx +0 -20
- package/src/SectionHeading/index.tsx +0 -33
- package/src/SectionHeading/styles.css.ts +0 -15
- package/src/StickyHeader/index.tsx +0 -52
- package/src/StickyHeader/styles.css.ts +0 -17
- package/src/Story/index.tsx +0 -70
- package/src/Story/styles.css.ts +0 -37
- package/src/Tabs/index.tsx +0 -65
- package/src/Tabs/styles.css.ts +0 -7
- package/src/TabsBase/TabsBase.tsx +0 -89
- package/src/TabsBase/TabsButton.tsx +0 -30
- package/src/TabsBase/TabsLink.tsx +0 -30
- package/src/TabsBase/TabsMenuButton.tsx +0 -41
- package/src/TabsBase/index.ts +0 -4
- package/src/TabsBase/styles.css.ts +0 -64
- package/src/TabsBase/tabsMenuButton.css.ts +0 -25
- package/src/Tag/__tests__/index.test.tsx +0 -58
- package/src/Tag/index.tsx +0 -62
- package/src/Tag/styles.css.ts +0 -48
- package/src/ThemeProvider.tsx +0 -37
- package/src/TileBase/TileBase.tsx +0 -159
- package/src/TileBase/TileStateProvider.tsx +0 -52
- package/src/TileBase/index.ts +0 -2
- package/src/TileBase/styles.css.ts +0 -15
- package/src/TileButton/index.tsx +0 -68
- package/src/TileContent/index.tsx +0 -155
- package/src/TileContent/styles.css.ts +0 -229
- package/src/TileContentLabel/index.tsx +0 -74
- package/src/TileContentLabel/styles.css.ts +0 -22
- package/src/TileLink/index.tsx +0 -83
- package/src/TileLink/styles.css.ts +0 -9
- package/src/Tiles.tsx +0 -17
- package/src/Typography/Typography.tsx +0 -22
- package/src/Typography/index.tsx +0 -54
- package/src/Typography/withStyledTypography.tsx +0 -25
- package/src/VideoPlayer/__tests__/index.test.tsx +0 -13
- package/src/VideoPlayer/index.tsx +0 -179
- package/src/VideoPlayer/styles.css.ts +0 -87
- package/src/ViewStack/View.tsx +0 -19
- package/src/ViewStack/ViewStack.tsx +0 -50
- package/src/ViewStack/__tests__/index.test.tsx +0 -86
- package/src/ViewStack/index.tsx +0 -2
- package/src/__tests__/Button.test.tsx +0 -13
- package/src/__tests__/LinkButton.test.tsx +0 -16
- package/src/__tests__/ReactLive.test.tsx +0 -21
- package/src/canUseDOM.ts +0 -5
- package/src/common/types/index.ts +0 -52
- package/src/index.tsx +0 -59
- package/src/styles.ts +0 -45
- package/src/useBreakpoint.ts +0 -28
- package/src/useLockBodyScroll.ts +0 -16
- package/src/useOutsideClick.ts +0 -25
- package/src/useSize.ts +0 -32
- package/src/useSpacing.ts +0 -17
- package/src/utils/hasProtocol.ts +0 -1
- package/src/utils/index.ts +0 -1
- 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
|
-
});
|
package/src/Accordion/index.tsx
DELETED
|
@@ -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
|
-
};
|
package/src/BrowserOnly.tsx
DELETED
|
@@ -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
|
-
});
|
package/src/Callout/index.tsx
DELETED
|
@@ -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
|
-
};
|