@times-components/ts-components 1.98.1 → 1.98.2-alpha.7

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 (59) hide show
  1. package/dist/assets/CloseIconBlack.d.ts +3 -0
  2. package/dist/assets/CloseIconBlack.js +5 -0
  3. package/dist/assets/EmailIcon.d.ts +3 -0
  4. package/dist/assets/EmailIcon.js +5 -0
  5. package/dist/assets/FilledArrowIcon.d.ts +3 -0
  6. package/dist/assets/FilledArrowIcon.js +5 -0
  7. package/dist/assets/index.d.ts +3 -0
  8. package/dist/assets/index.js +4 -0
  9. package/dist/components/banner/__tests__/banner.test.d.ts +1 -0
  10. package/dist/components/banner/__tests__/banner.test.js +11 -0
  11. package/dist/components/banner/banner.d.ts +8 -0
  12. package/dist/components/banner/banner.js +16 -0
  13. package/dist/components/banner/styles.d.ts +8 -0
  14. package/dist/components/banner/styles.js +73 -0
  15. package/dist/components/delayed-component/__tests__/delayed-component.test.d.ts +1 -0
  16. package/dist/components/delayed-component/__tests__/delayed-component.test.js +23 -0
  17. package/dist/components/delayed-component/delayed-component.d.ts +6 -0
  18. package/dist/components/delayed-component/delayed-component.js +11 -0
  19. package/dist/components/update-button/__tests__/update-button-with-delay.test.d.ts +1 -0
  20. package/dist/components/update-button/__tests__/update-button-with-delay.test.js +30 -0
  21. package/dist/components/update-button/__tests__/update-button.test.d.ts +1 -0
  22. package/dist/components/update-button/__tests__/update-button.test.js +27 -0
  23. package/dist/components/update-button/styles.d.ts +1 -0
  24. package/dist/components/update-button/styles.js +39 -0
  25. package/dist/components/update-button/update-button-with-delay.d.ts +12 -0
  26. package/dist/components/update-button/update-button-with-delay.js +27 -0
  27. package/dist/components/update-button/update-button.d.ts +6 -0
  28. package/dist/components/update-button/update-button.js +9 -0
  29. package/dist/fixtures/article-harness/__tests__/articleHarness.test.d.ts +1 -0
  30. package/dist/fixtures/article-harness/__tests__/articleHarness.test.js +11 -0
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.js +6 -2
  33. package/package.json +17 -16
  34. package/rnw.js +1 -1
  35. package/src/assets/CloseIconBlack.tsx +24 -0
  36. package/src/assets/EmailIcon.tsx +24 -0
  37. package/src/assets/FilledArrowIcon.tsx +17 -0
  38. package/src/assets/icons.stories.mdx +1 -0
  39. package/src/assets/index.tsx +3 -0
  40. package/src/components/banner/__tests__/__snapshots__/banner.test.tsx.snap +66 -0
  41. package/src/components/banner/__tests__/banner.test.tsx +13 -0
  42. package/src/components/banner/banner.stories.mdx +30 -0
  43. package/src/components/banner/banner.tsx +39 -0
  44. package/src/components/banner/styles.ts +80 -0
  45. package/src/components/delayed-component/__tests__/delayed-component.test.tsx +29 -0
  46. package/src/components/delayed-component/delayed-component.stories.mdx +38 -0
  47. package/src/components/delayed-component/delayed-component.tsx +16 -0
  48. package/src/components/update-button/__tests__/__snapshots__/update-button-with-delay.test.tsx.snap +23 -0
  49. package/src/components/update-button/__tests__/__snapshots__/update-button.test.tsx.snap +23 -0
  50. package/src/components/update-button/__tests__/update-button-with-delay.test.tsx +73 -0
  51. package/src/components/update-button/__tests__/update-button.test.tsx +31 -0
  52. package/src/components/update-button/styles.ts +40 -0
  53. package/src/components/update-button/update-button-with-delay.stories.mdx +40 -0
  54. package/src/components/update-button/update-button-with-delay.tsx +54 -0
  55. package/src/components/update-button/update-button.stories.mdx +32 -0
  56. package/src/components/update-button/update-button.tsx +17 -0
  57. package/src/fixtures/article-harness/__tests__/__snapshots__/articleHarness.test.tsx.snap +34 -0
  58. package/src/fixtures/article-harness/__tests__/articleHarness.test.tsx +11 -0
  59. package/src/index.ts +9 -1
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+
3
+ const CloseIconBlack: React.FC<any> = ({
4
+ width = 24,
5
+ height = 24,
6
+ color = '#000',
7
+ ...props
8
+ }) => (
9
+ <svg
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ width={width}
12
+ height={height}
13
+ viewBox="0 0 14 14"
14
+ fill="none"
15
+ {...props}
16
+ >
17
+ <path
18
+ d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z"
19
+ fill={color}
20
+ />
21
+ </svg>
22
+ );
23
+
24
+ export default CloseIconBlack;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+
3
+ const EmailIcon: React.FC<any> = ({
4
+ width = 24,
5
+ height = 24,
6
+ color = '#000',
7
+ ...props
8
+ }) => (
9
+ <svg
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ width={width}
12
+ height={height}
13
+ viewBox="0 0 24 24"
14
+ fill="none"
15
+ {...props}
16
+ >
17
+ <path
18
+ d="M22 9.98V19C22 20.1 21.1 21 20 21H4C2.9 21 2 20.1 2 19L2.01 7C2.01 5.9 2.9 5 4 5H14.1C14.04 5.32 14 5.66 14 6C14 6.34 14.04 6.68 14.1 7H4L12 12L15.67 9.71C16.14 10.14 16.69 10.47 17.3 10.69L12 14L4 9V19H20V10.9C20.74 10.75 21.42 10.42 22 9.98ZM16 6C16 7.66 17.34 9 19 9C20.66 9 22 7.66 22 6C22 4.34 20.66 3 19 3C17.34 3 16 4.34 16 6Z"
19
+ fill={color}
20
+ />
21
+ </svg>
22
+ );
23
+
24
+ export default EmailIcon;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ const FilledArrowIcon: React.FC = (props: any) => (
4
+ <svg
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ width={16}
7
+ height={16}
8
+ fill="none"
9
+ {...props}
10
+ >
11
+ <path
12
+ fill="currentcolor"
13
+ d="m3.166 8 .94.94 3.727-3.72v8.113h1.333V5.22l3.72 3.727.947-.947-5.334-5.333L3.166 8Z"
14
+ />
15
+ </svg>
16
+ );
17
+ export default FilledArrowIcon;
@@ -0,0 +1 @@
1
+ overrides={{size: "sizing050"}}
@@ -0,0 +1,3 @@
1
+ export { default as CloseIconBlack } from './CloseIconBlack';
2
+ export { default as EmailIcon } from './EmailIcon';
3
+ export { default as FilledArrowIcon } from './FilledArrowIcon';
@@ -0,0 +1,66 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Banner renders the banner 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="sc-bdVaJa VUwsZ"
7
+ >
8
+ <div
9
+ aria-label="Email verification banner"
10
+ class="sc-bwzfXH eWmkTr"
11
+ >
12
+ <div
13
+ class="sc-htpNat kKgziG"
14
+ role="region"
15
+ >
16
+ <div
17
+ class="sc-bxivhb iVoVQA"
18
+ >
19
+ <div
20
+ class="sc-ifAKCX fBzQxS"
21
+ >
22
+ <svg
23
+ fill="none"
24
+ height="24"
25
+ viewBox="0 0 24 24"
26
+ width="24"
27
+ xmlns="http://www.w3.org/2000/svg"
28
+ >
29
+ <path
30
+ d="M22 9.98V19C22 20.1 21.1 21 20 21H4C2.9 21 2 20.1 2 19L2.01 7C2.01 5.9 2.9 5 4 5H14.1C14.04 5.32 14 5.66 14 6C14 6.34 14.04 6.68 14.1 7H4L12 12L15.67 9.71C16.14 10.14 16.69 10.47 17.3 10.69L12 14L4 9V19H20V10.9C20.74 10.75 21.42 10.42 22 9.98ZM16 6C16 7.66 17.34 9 19 9C20.66 9 22 7.66 22 6C22 4.34 20.66 3 19 3C17.34 3 16 4.34 16 6Z"
31
+ fill="#000"
32
+ />
33
+ </svg>
34
+ <p
35
+ class="sc-EHOje dMjtnD"
36
+ >
37
+ Title
38
+ </p>
39
+ </div>
40
+ <button
41
+ class="sc-gzVnrw hWbcjJ"
42
+ >
43
+ <svg
44
+ fill="none"
45
+ height="14"
46
+ viewBox="0 0 14 14"
47
+ width="14"
48
+ xmlns="http://www.w3.org/2000/svg"
49
+ >
50
+ <path
51
+ d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z"
52
+ fill="#000"
53
+ />
54
+ </svg>
55
+ </button>
56
+ </div>
57
+ <p
58
+ class="sc-bZQynM jtrtRX"
59
+ >
60
+ Body
61
+ </p>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </DocumentFragment>
66
+ `;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render } from '@testing-library/react';
4
+ import { Banner } from '../banner';
5
+
6
+ describe('Banner', () => {
7
+ it('renders the banner', () => {
8
+ const { asFragment } = render(
9
+ <Banner title="Title" body="Body" onClose={jest.fn} />
10
+ );
11
+ expect(asFragment()).toMatchSnapshot();
12
+ });
13
+ });
@@ -0,0 +1,30 @@
1
+ import { Meta, Story, Props } from '@storybook/addon-docs'
2
+
3
+ import { Banner } from './banner';
4
+
5
+ <Meta
6
+ title="Components/Misc/Banner"
7
+ component={Banner}
8
+ />
9
+
10
+ # Banner component
11
+ The `Banner` component is used to show and hide related content.
12
+
13
+ This component takes in a two props, as below, to display text based content.
14
+
15
+ ## Props
16
+ <Props of={Banner} />
17
+
18
+ ## Code Example
19
+ `<Banner />`
20
+
21
+ ## View Component
22
+ Please click the 'Canvas' tab for a better viewing experience, where you can update the props and review at the different breakpoints by clicking the preview icon and selecting from our list of pre-defined breakpoints (XS, SM, MD, LG and XL).
23
+
24
+ export const BannerStory = ({ group }) => (
25
+ <Banner title="Banner title" body="Banner message" onClose={() => console.log('close')} />
26
+ );
27
+
28
+ <Story name="Banner">
29
+ {BannerStory.bind({})}
30
+ </Story>
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import {
3
+ Body,
4
+ CloseIconWrapper,
5
+ Title,
6
+ TitleWrapper,
7
+ Wrapper,
8
+ StyledBanner,
9
+ BannerWrapper,
10
+ BannerContentWrapper
11
+ } from './styles';
12
+ import { CloseIconBlack, EmailIcon } from '../../assets';
13
+
14
+ type Props = {
15
+ onClose: () => void;
16
+ title: string;
17
+ body: string;
18
+ };
19
+
20
+ export const Banner: React.FC<Props> = ({ title, body, onClose }) => {
21
+ return (
22
+ <BannerWrapper>
23
+ <StyledBanner aria-label="Email verification banner">
24
+ <BannerContentWrapper role="region">
25
+ <Wrapper>
26
+ <TitleWrapper>
27
+ <EmailIcon />
28
+ <Title>{title}</Title>
29
+ </TitleWrapper>
30
+ <CloseIconWrapper onClick={onClose}>
31
+ <CloseIconBlack width={14} height={14} />
32
+ </CloseIconWrapper>
33
+ </Wrapper>
34
+ <Body>{body}</Body>
35
+ </BannerContentWrapper>
36
+ </StyledBanner>
37
+ </BannerWrapper>
38
+ );
39
+ };
@@ -0,0 +1,80 @@
1
+ import styled from 'styled-components';
2
+ import { breakpoints } from '@times-components/ts-styleguide';
3
+
4
+ export const BannerWrapper = styled.div`
5
+ max-width: 498px;
6
+ box-shadow: 0px 16px 24px 0px rgba(17, 17, 17, 0.08);
7
+ z-index: 100;
8
+ width: 100%;
9
+ `;
10
+
11
+ export const StyledBanner = styled.div`
12
+ border-top: 3px solid #005c8a;
13
+ background-color: #fff;
14
+ flex-direction: column;
15
+ align-items: flex-start;
16
+ padding-left: 16px;
17
+ padding-block: 12px;
18
+ padding-right: 16px;
19
+ @media screen and (min-width: ${breakpoints.wide}px) {
20
+ padding-block: 10px;
21
+ }
22
+ @media screen and (min-width: ${breakpoints.medium}px) {
23
+ padding-right: 30px;
24
+ }
25
+ `;
26
+
27
+ export const BannerContentWrapper = styled.div`
28
+ flex-direction: inherit;
29
+ `;
30
+
31
+ export const Wrapper = styled.div`
32
+ display: flex;
33
+ justify-content: space-between;
34
+ align-items: center;
35
+ width: 100%;
36
+ margin-bottom: 12px;
37
+ @media screen and (min-width: ${breakpoints.medium}px) {
38
+ margin-bottom: 8px;
39
+ }
40
+ `;
41
+
42
+ export const TitleWrapper = styled.div`
43
+ display: flex;
44
+ align-items: center;
45
+ width: 100%;
46
+ `;
47
+
48
+ export const Title = styled.p`
49
+ color: #333;
50
+ font-weight: 700;
51
+ margin: 0 0 0 16px;
52
+ font-size: 24px;
53
+ line-height: 27px;
54
+ font-family: 'Times Modern';
55
+ letter-spacing: 0em;
56
+ @media (max-width: ${breakpoints.medium}px) {
57
+ font-size: 18px;
58
+ line-height: 20px;
59
+ }
60
+ `;
61
+
62
+ export const Body = styled.p`
63
+ color: #696969;
64
+ font-weight: 400;
65
+ margin: 0;
66
+ font-size: 16px;
67
+ line-height: 24px;
68
+ font-family: 'Roboto';
69
+ letter-spacing: 0em;
70
+ @media (max-width: ${breakpoints.medium}px) {
71
+ font-size: 14px;
72
+ line-height: 21px;
73
+ }
74
+ `;
75
+
76
+ export const CloseIconWrapper = styled.button`
77
+ background: #fff;
78
+ border: none;
79
+ cursor: pointer;
80
+ `;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, waitFor } from '@testing-library/react';
4
+ import { DelayedComponent } from '../delayed-component';
5
+
6
+ describe('DelayedComponent', () => {
7
+ it('should remove the component after the specified delay when initial state is true', async () => {
8
+ const { queryByText, getByText } = render(
9
+ <DelayedComponent initialState={true} delay={800}>
10
+ <div>Children</div>
11
+ </DelayedComponent>
12
+ );
13
+ expect(getByText('Children')).toBeVisible();
14
+ await waitFor(() => {
15
+ expect(queryByText('Children')).toBeFalsy();
16
+ });
17
+ });
18
+ it('should render the component after the specified delay when initial state is false', async () => {
19
+ const { queryByText, getByText } = render(
20
+ <DelayedComponent initialState={false} delay={800}>
21
+ <div>Children</div>
22
+ </DelayedComponent>
23
+ );
24
+ expect(queryByText('Children')).toBeFalsy();
25
+ await waitFor(() => {
26
+ expect(getByText('Children')).toBeVisible();
27
+ });
28
+ });
29
+ });
@@ -0,0 +1,38 @@
1
+ import { Meta, Story, Props } from '@storybook/addon-docs'
2
+
3
+ import { DelayedComponent } from './delayed-component.tsx';
4
+
5
+ <Meta
6
+ title="Components/Misc/DelayedComponent"
7
+ component={DelayedComponent}
8
+ />
9
+
10
+ # DelayedComponent component
11
+ The `DelayedComponent` component is a helper component used to delay the mount or dismount of the children passed to the component.
12
+
13
+ This component takes in three props: `initialState`, `delay` and `children`.
14
+ initialState - This used to set the initial component state, if it is meant to be displayed initially and removed after x amount of time intialState would be true. and Vice versa.
15
+ delay - This is the time in milliseconds it takes for the component to mount or unmount.
16
+
17
+ Given the nature of this component you may need to play around with the controls so that you can see what it's doing.
18
+
19
+
20
+
21
+ ## Props
22
+ <Props of={DelayedComponent} />
23
+
24
+ ## Code Example
25
+ `<DelayedComponent initialState={true} delay={8000}><div>Hello</div></DelayedComponent>`
26
+
27
+ ## View Component
28
+ Please click the 'Canvas' tab for a better viewing experience, where you can update the props and review at the different breakpoints by clicking the preview icon and selecting from our list of pre-defined breakpoints (XS, SM, MD, LG and XL).
29
+
30
+ export const DelayedComponentStory = ({ initialState, delay }) => (
31
+ <DelayedComponent initialState={initialState} delay={delay}><div style={{ fontSize: '20px', color: 'red'}}>I am a delayed component</div></DelayedComponent>
32
+ );
33
+
34
+ <Story name="DelayedComponent"
35
+ args={{ initialState: true, delay: 8000} }
36
+ >
37
+ {DelayedComponentStory.bind({})}
38
+ </Story>
@@ -0,0 +1,16 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ export const DelayedComponent: React.FC<{
4
+ delay: number;
5
+ initialState: boolean;
6
+ children: any;
7
+ }> = ({ delay, initialState, children }) => {
8
+ const [showElement, setShowElement] = useState(initialState);
9
+
10
+ useEffect(() => {
11
+ setTimeout(() => {
12
+ setShowElement(!initialState);
13
+ }, delay);
14
+ }, []);
15
+ return <>{showElement ? children : null}</>;
16
+ };
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Render UpdateButtonWithDelay should render the Update button component and the DelayComponent as expected when it has an update 1`] = `
4
+ <DocumentFragment>
5
+ <button
6
+ class="sc-bdVaJa kaAiuV"
7
+ >
8
+ <svg
9
+ data-testid="upward-arrow"
10
+ fill="none"
11
+ height="16"
12
+ width="16"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ >
15
+ <path
16
+ d="m3.166 8 .94.94 3.727-3.72v8.113h1.333V5.22l3.72 3.727.947-.947-5.334-5.333L3.166 8Z"
17
+ fill="currentcolor"
18
+ />
19
+ </svg>
20
+ New Updates
21
+ </button>
22
+ </DocumentFragment>
23
+ `;
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Render UpdateButton should render the component 1`] = `
4
+ <DocumentFragment>
5
+ <button
6
+ class="sc-bdVaJa kaAiuV"
7
+ >
8
+ <svg
9
+ data-testid="upward-arrow"
10
+ fill="none"
11
+ height="16"
12
+ width="16"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ >
15
+ <path
16
+ d="m3.166 8 .94.94 3.727-3.72v8.113h1.333V5.22l3.72 3.727.947-.947-5.334-5.333L3.166 8Z"
17
+ fill="currentcolor"
18
+ />
19
+ </svg>
20
+ New Updates
21
+ </button>
22
+ </DocumentFragment>
23
+ `;
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, waitFor } from '@testing-library/react';
4
+ import { UpdateButtonWithDelay, fetchData } from '../update-button-with-delay';
5
+
6
+ const handleClickMock = jest.fn();
7
+
8
+ const renderComponent = (
9
+ delay: number,
10
+ display: boolean,
11
+ label: string,
12
+ handleClick: any,
13
+ updatedTime: string,
14
+ articleId: string,
15
+ update: boolean
16
+ ) =>
17
+ render(
18
+ <UpdateButtonWithDelay
19
+ delay={delay}
20
+ display={display}
21
+ label={label}
22
+ handleClick={handleClick}
23
+ updatedTime={updatedTime}
24
+ articleId={articleId}
25
+ update={update}
26
+ />
27
+ );
28
+
29
+ describe('Render UpdateButtonWithDelay', () => {
30
+ it('should render the Update button component and the DelayComponent as expected when it has an update', async () => {
31
+ const { asFragment, getByRole, queryByTestId } = renderComponent(
32
+ 800,
33
+ true,
34
+ 'New Updates',
35
+ handleClickMock,
36
+ '2023-10-12T00:00:00.000Z',
37
+ '12345',
38
+ true
39
+ );
40
+ expect(asFragment()).toMatchSnapshot();
41
+ expect(getByRole('button')).toBeVisible();
42
+ await waitFor(() => {
43
+ expect(queryByTestId('button')).toBeFalsy();
44
+ });
45
+ });
46
+
47
+ it('should not render the Update button component and the DelayComponent as expected when it has an update', async () => {
48
+ const { unmount, queryByTestId } = renderComponent(
49
+ 500,
50
+ true,
51
+ 'Update Now',
52
+ handleClickMock,
53
+ '2023-10-12T00:00:00.000Z',
54
+ '12345',
55
+ false
56
+ );
57
+
58
+ await waitFor(
59
+ () => {
60
+ expect(queryByTestId('button')).toBeNull();
61
+ },
62
+ { timeout: 500 }
63
+ );
64
+
65
+ unmount();
66
+ });
67
+ it('should not error on fetch with a valid articleId', async () => {
68
+ await expect(fetchData('12345')).resolves.not.toThrowError();
69
+ });
70
+ it('should return the publishedTime on fetch with a valid articleId', async () => {
71
+ expect(fetchData('12345')).not.toBeUndefined();
72
+ });
73
+ });
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, fireEvent } from '@testing-library/react';
4
+
5
+ import { UpdateButton } from '../update-button';
6
+
7
+ const handleClickMock = jest.fn();
8
+
9
+ const renderComponent = (label: string, handleClick: any) =>
10
+ render(<UpdateButton label={label} handleClick={handleClick} />);
11
+
12
+ describe('Render UpdateButton', () => {
13
+ it('should render the component', () => {
14
+ const { asFragment } = renderComponent('New Updates', handleClickMock);
15
+ expect(asFragment()).toMatchSnapshot();
16
+ });
17
+ it('should render the label text you pass through', () => {
18
+ const { getByText } = renderComponent('Test New Updates', handleClickMock);
19
+ expect(getByText('Test New Updates')).toBeVisible();
20
+ });
21
+ it('should trigger an event on click', () => {
22
+ const { getByRole } = renderComponent('New Update', handleClickMock);
23
+ const Button = getByRole('button');
24
+ fireEvent.click(Button);
25
+ expect(handleClickMock).toHaveBeenCalled();
26
+ });
27
+ it('should render the upward facing arrow icon', () => {
28
+ const { getByTestId } = renderComponent('New Updates', handleClickMock);
29
+ expect(getByTestId('upward-arrow')).toBeVisible();
30
+ });
31
+ });
@@ -0,0 +1,40 @@
1
+ import styled from 'styled-components';
2
+
3
+ const styleMap = {
4
+ colors: {
5
+ interactiveNegative040: '#9f0000',
6
+ interactiveNegative050: '#800000',
7
+ inkInverse: '#FFFFFF'
8
+ },
9
+ spacing: {
10
+ space030: '12px',
11
+ space020: '8px'
12
+ }
13
+ };
14
+
15
+ export const StyledButton = styled.button`
16
+ border: none;
17
+ background-color: ${styleMap.colors.interactiveNegative040};
18
+ padding-block: ${styleMap.spacing.space020};
19
+ padding-inline: ${styleMap.spacing.space030};
20
+ font-family: Roboto;
21
+ font-size: 1.4000000000000001rem;
22
+ font-weight: 500;
23
+ letter-spacing: 0em;
24
+ color: ${styleMap.colors.inkInverse};
25
+ display: inline-grid;
26
+ grid-template-columns: repeat(2, auto);
27
+ column-gap: 8px;
28
+ place-content: center;
29
+ place-items: center;
30
+ cursor: pointer;
31
+ transition-property: background-color;
32
+ transition-duration: 200ms;
33
+ transition-timing-function: cubic-bezier(0, 0, 0.5, 1);
34
+ &:hover {
35
+ background-color: ${styleMap.colors.interactiveNegative050};
36
+ }
37
+ &:active {
38
+ background-color: ${styleMap.colors.interactiveNegative050};
39
+ }
40
+ `;
@@ -0,0 +1,40 @@
1
+ import { Meta, Story, Props } from '@storybook/addon-docs'
2
+
3
+ import { UpdateButtonWithDelay } from './update-button-with-delay.tsx';
4
+
5
+ <Meta
6
+ title="Components/Misc/UpdateButtonWithDelay"
7
+ component={UpdateButtonWithDelay}
8
+ />
9
+
10
+ # UpdateButtonWithDelay component
11
+ The `UpdateButtonWithDelay` component is used to highlight when there is an update in an article.
12
+
13
+ The `UpdateButtonWithDelay` component makes use of the `DelayedComponent` which will set the component to mount or unmount given a delay and intial state.
14
+
15
+ This component takes in a six props:
16
+ - `loading` to display the loading spinner.
17
+ - `delay` to determine the delay in milliseconds for mounting or unmounting the component.
18
+ - `display` which will determine if the component initially displays, or is rendered after the delay has passed.
19
+ - `label` this is for the text label in the button.
20
+ - `handleClick` determines the function called on interaction.
21
+ - `arrowUp` this is to render either the upward arrow icon or the downward icon (depending on where in the article the user is vs where the update is).
22
+
23
+ ## Props
24
+ <Props of={UpdateButtonWithDelay} />
25
+
26
+ ## Code Example
27
+ `<UpdateButtonWithDelay display={true} delay={8000} label='New updates', arrowUp={true} updatedTime="2023-12-12T12:00:00.000Z" articleId="12345"/>`
28
+
29
+ ## View Component
30
+ Please click the 'Canvas' tab for a better viewing experience, where you can update the props and review at the different breakpoints by clicking the preview icon and selecting from our list of pre-defined breakpoints (XS, SM, MD, LG and XL).
31
+
32
+ export const UpdateButtonWithDelayStory = ({ display, delay, label, arrowUp, updatedTime, articleId }) => (
33
+ <UpdateButtonWithDelay display={display} delay={delay} label={label} arrowUp={arrowUp} updatedTime={updatedTime} articleId={articleId} update={true}/>
34
+ );
35
+
36
+ <Story name="UpdateButtonWithDelay"
37
+ args={{ display: true, delay: 8000, label: 'New Updates', arrowUp: true, updatedTime: '2023-07-13T12:00:00.000Z', articleId: '12345'} }
38
+ >
39
+ {UpdateButtonWithDelayStory.bind({})}
40
+ </Story>