@indico-data/design-system 1.0.1
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/.babelrc +27 -0
- package/.eslintignore +6 -0
- package/.eslintrc.js +63 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +3 -0
- package/.prettierrc +6 -0
- package/.stackblitzrc +4 -0
- package/.storybook/indico-data-logo.svg +1 -0
- package/.storybook/main.ts +36 -0
- package/.storybook/preview-head.html +19 -0
- package/.storybook/preview.ts +24 -0
- package/.storybook/themes.js +24 -0
- package/.yarn/releases/yarn-classic.cjs +179386 -0
- package/.yarnrc.yml +1 -0
- package/README.md +30 -0
- package/package.json +79 -0
- package/src/components/Accordion/Accordion.stories.tsx +47 -0
- package/src/components/Accordion/Accordion.styles.ts +35 -0
- package/src/components/Accordion/Accordion.tsx +30 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +60 -0
- package/src/components/Icon/Icon.tsx +75 -0
- package/src/components/Icon/faIcons.tsx +168 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Icon/indicons.tsx +699 -0
- package/src/components/Icon/storyHelpers.tsx +87 -0
- package/src/components/ListTable/Header/Header.styles.ts +62 -0
- package/src/components/ListTable/Header/Header.tsx +67 -0
- package/src/components/ListTable/Header/index.ts +1 -0
- package/src/components/ListTable/ListTable.stories.tsx +301 -0
- package/src/components/ListTable/ListTable.styles.ts +76 -0
- package/src/components/ListTable/ListTable.tsx +135 -0
- package/src/components/ListTable/index.ts +1 -0
- package/src/components/ListTable/mock-data/index.ts +1 -0
- package/src/components/ListTable/mock-data/mock-data.ts +291 -0
- package/src/components/Pagination/Pagination.stories.tsx +45 -0
- package/src/components/Pagination/Pagination.styles.ts +51 -0
- package/src/components/Pagination/Pagination.tsx +118 -0
- package/src/components/Pagination/index.ts +1 -0
- package/src/components/basic-section/Section/Section.stories.tsx +14 -0
- package/src/components/basic-section/Section/Section.styles.ts +8 -0
- package/src/components/basic-section/Section/Section.tsx +30 -0
- package/src/components/basic-section/Section/index.ts +1 -0
- package/src/components/basic-section/SectionBlock/SectionBlock.styles.ts +15 -0
- package/src/components/basic-section/SectionBlock/SectionBlock.tsx +37 -0
- package/src/components/basic-section/SectionBlock/index.ts +1 -0
- package/src/components/basic-section/SectionBody/SectionBody.stories.tsx +16 -0
- package/src/components/basic-section/SectionBody/SectionBody.styles.ts +18 -0
- package/src/components/basic-section/SectionBody/SectionBody.tsx +30 -0
- package/src/components/basic-section/SectionBody/index.ts +1 -0
- package/src/components/basic-section/SectionHeader/SectionHeader.stories.tsx +17 -0
- package/src/components/basic-section/SectionHeader/SectionHeader.styles.ts +5 -0
- package/src/components/basic-section/SectionHeader/SectionHeader.tsx +35 -0
- package/src/components/basic-section/SectionHeader/index.ts +1 -0
- package/src/components/basic-section/SectionTable/SectionTable.styles.ts +237 -0
- package/src/components/basic-section/SectionTable/SectionTable.tsx +229 -0
- package/src/components/basic-section/SectionTable/index.ts +1 -0
- package/src/components/basic-section/index.ts +5 -0
- package/src/components/buttons/Button/Button.stories.tsx +80 -0
- package/src/components/buttons/Button/Button.styles.ts +99 -0
- package/src/components/buttons/Button/Button.tsx +74 -0
- package/src/components/buttons/Button/index.ts +1 -0
- package/src/components/buttons/IconButton/IconButton.stories.tsx +96 -0
- package/src/components/buttons/IconButton/IconButton.styles.ts +78 -0
- package/src/components/buttons/IconButton/IconButton.tsx +109 -0
- package/src/components/buttons/IconButton/index.ts +1 -0
- package/src/components/buttons/commonStyles.ts +108 -0
- package/src/components/buttons/index.ts +2 -0
- package/src/components/buttons/types.ts +2 -0
- package/src/components/dropdowns/BorderSelect/BorderSelect.stories.tsx +22 -0
- package/src/components/dropdowns/BorderSelect/BorderSelect.styles.ts +73 -0
- package/src/components/dropdowns/BorderSelect/BorderSelect.tsx +85 -0
- package/src/components/dropdowns/BorderSelect/index.ts +1 -0
- package/src/components/dropdowns/MultiCombobox/MultiCombobox.stories.tsx +146 -0
- package/src/components/dropdowns/MultiCombobox/MultiCombobox.styles.ts +89 -0
- package/src/components/dropdowns/MultiCombobox/MultiCombobox.tsx +123 -0
- package/src/components/dropdowns/MultiCombobox/index.ts +1 -0
- package/src/components/dropdowns/Select/Select.stories.tsx +54 -0
- package/src/components/dropdowns/Select/Select.styles.ts +73 -0
- package/src/components/dropdowns/Select/Select.tsx +69 -0
- package/src/components/dropdowns/Select/index.ts +1 -0
- package/src/components/dropdowns/SingleCombobox/SingleCombobox.stories.tsx +61 -0
- package/src/components/dropdowns/SingleCombobox/SingleCombobox.styles.ts +56 -0
- package/src/components/dropdowns/SingleCombobox/SingleCombobox.tsx +103 -0
- package/src/components/dropdowns/SingleCombobox/index.ts +1 -0
- package/src/components/dropdowns/commonStyles.ts +65 -0
- package/src/components/dropdowns/index.ts +4 -0
- package/src/components/dropdowns/types.ts +45 -0
- package/src/components/dropdowns/useCombobox.ts +32 -0
- package/src/components/dropdowns/utils.tsx +25 -0
- package/src/components/index.ts +9 -0
- package/src/components/inputs/EditableInput/EditableInput.stories.tsx +26 -0
- package/src/components/inputs/EditableInput/EditableInput.styles.ts +21 -0
- package/src/components/inputs/EditableInput/EditableInput.tsx +103 -0
- package/src/components/inputs/EditableInput/index.ts +1 -0
- package/src/components/inputs/NumberInput/NumberInput.stories.tsx +72 -0
- package/src/components/inputs/NumberInput/NumberInput.styles.ts +66 -0
- package/src/components/inputs/NumberInput/NumberInput.tsx +153 -0
- package/src/components/inputs/NumberInput/index.ts +1 -0
- package/src/components/inputs/SearchInput/SearchInput.stories.tsx +17 -0
- package/src/components/inputs/SearchInput/SearchInput.styles.ts +25 -0
- package/src/components/inputs/SearchInput/SearchInput.tsx +47 -0
- package/src/components/inputs/SearchInput/index.ts +1 -0
- package/src/components/inputs/TextInput/TextInput.stories.tsx +104 -0
- package/src/components/inputs/TextInput/TextInput.styles.ts +74 -0
- package/src/components/inputs/TextInput/TextInput.tsx +116 -0
- package/src/components/inputs/TextInput/index.ts +1 -0
- package/src/components/inputs/index.ts +4 -0
- package/src/components/inputs/inputsCommon.styles.ts +61 -0
- package/src/components/loading-indicators/BarSpinner/BarSpinner.stories.tsx +14 -0
- package/src/components/loading-indicators/BarSpinner/BarSpinner.styles.ts +53 -0
- package/src/components/loading-indicators/BarSpinner/BarSpinner.tsx +21 -0
- package/src/components/loading-indicators/BarSpinner/index.ts +1 -0
- package/src/components/loading-indicators/CirclePulse/CirclePulse.stories.tsx +22 -0
- package/src/components/loading-indicators/CirclePulse/CirclePulse.styles.ts +81 -0
- package/src/components/loading-indicators/CirclePulse/CirclePulse.tsx +61 -0
- package/src/components/loading-indicators/CirclePulse/index.ts +1 -0
- package/src/components/loading-indicators/CircleSpinner/CircleSpinner.stories.tsx +16 -0
- package/src/components/loading-indicators/CircleSpinner/CircleSpinner.tsx +37 -0
- package/src/components/loading-indicators/CircleSpinner/index.ts +1 -0
- package/src/components/loading-indicators/LoadingList/LoadingList.stories.tsx +14 -0
- package/src/components/loading-indicators/LoadingList/LoadingList.styles.ts +42 -0
- package/src/components/loading-indicators/LoadingList/LoadingList.tsx +9 -0
- package/src/components/loading-indicators/LoadingList/index.ts +1 -0
- package/src/components/loading-indicators/PercentageRing/PercentageRing.stories.tsx +18 -0
- package/src/components/loading-indicators/PercentageRing/PercentageRing.styles.ts +27 -0
- package/src/components/loading-indicators/PercentageRing/PercentageRing.tsx +76 -0
- package/src/components/loading-indicators/PercentageRing/index.ts +1 -0
- package/src/components/loading-indicators/RandomLoadingMessage/RandomLoadingMessage.stories.tsx +16 -0
- package/src/components/loading-indicators/RandomLoadingMessage/RandomLoadingMessage.tsx +18 -0
- package/src/components/loading-indicators/RandomLoadingMessage/index.ts +1 -0
- package/src/components/loading-indicators/RandomLoadingMessage/random-messages.js +67 -0
- package/src/components/loading-indicators/index.ts +6 -0
- package/src/components/user-feedback/Shrug/Shrug.stories.tsx +38 -0
- package/src/components/user-feedback/Shrug/Shrug.styles.ts +23 -0
- package/src/components/user-feedback/Shrug/Shrug.tsx +44 -0
- package/src/components/user-feedback/Shrug/index.ts +1 -0
- package/src/components/user-feedback/index.ts +1 -0
- package/src/index.tsx +18 -0
- package/src/styles/globals/buttons.ts +154 -0
- package/src/styles/globals/forms.ts +103 -0
- package/src/styles/globals/index.tsx +25 -0
- package/src/styles/globals/layout.ts +25 -0
- package/src/styles/globals/lists.ts +23 -0
- package/src/styles/globals/margin-padding.ts +33 -0
- package/src/styles/globals/media.ts +13 -0
- package/src/styles/globals/tables.ts +34 -0
- package/src/styles/globals/typography.ts +95 -0
- package/src/styles/globals/utility-classes.ts +76 -0
- package/src/tokens/animation.ts +6 -0
- package/src/tokens/breakpoints.ts +11 -0
- package/src/tokens/colors.ts +279 -0
- package/src/tokens/index.ts +20 -0
- package/src/tokens/margin.ts +5 -0
- package/src/tokens/numbers.js +41 -0
- package/src/tokens/padding.ts +5 -0
- package/src/tokens/spacings.ts +5 -0
- package/src/tokens/typography.ts +37 -0
- package/src/types.ts +6 -0
- package/tsconfig.json +13 -0
- package/webpack.config.js +35 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { COLORS, TYPOGRAPHY } from '@/tokens';
|
|
4
|
+
|
|
5
|
+
export const inputCommon = css`
|
|
6
|
+
background-color: transparent;
|
|
7
|
+
color: ${COLORS.defaultFontColor};
|
|
8
|
+
|
|
9
|
+
border-radius: 0;
|
|
10
|
+
border: 0 solid currentColor;
|
|
11
|
+
border-bottom-width: 1px;
|
|
12
|
+
|
|
13
|
+
&:focus,
|
|
14
|
+
&:hover,
|
|
15
|
+
&.filled {
|
|
16
|
+
border-color: ${COLORS.lightFontColor};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:required {
|
|
20
|
+
border-bottom-color: ${COLORS.curiousBlue};
|
|
21
|
+
|
|
22
|
+
+ label:after {
|
|
23
|
+
content: '*';
|
|
24
|
+
margin-left: 4px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:disabled {
|
|
29
|
+
border-style: dotted;
|
|
30
|
+
border-bottom-color: ${COLORS.lightGray};
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export const labelCommon = css`
|
|
39
|
+
font-size: ${TYPOGRAPHY.fontSize.base};
|
|
40
|
+
font-weight: bold;
|
|
41
|
+
color: ${COLORS.lightFontColor};
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const inputInfoCommon = css`
|
|
45
|
+
margin-top: 13px;
|
|
46
|
+
font-size: ${TYPOGRAPHY.fontSize.subheadSmall};
|
|
47
|
+
|
|
48
|
+
.prompt {
|
|
49
|
+
color: ${COLORS.curiousBlue};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.error {
|
|
53
|
+
color: ${COLORS.red};
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const placeholderCommon = css`
|
|
58
|
+
&::placeholder {
|
|
59
|
+
opacity: 0.42;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { BarSpinner } from './BarSpinner';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: BarSpinner,
|
|
7
|
+
title: 'Loading/BarSpinner',
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} satisfies Meta<typeof BarSpinner>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof BarSpinner>;
|
|
13
|
+
|
|
14
|
+
export const Normal: Story = {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { COLORS } from '@/tokens';
|
|
4
|
+
|
|
5
|
+
const moveBg = keyframes`
|
|
6
|
+
from {
|
|
7
|
+
transform: translateX(0);
|
|
8
|
+
}
|
|
9
|
+
to {
|
|
10
|
+
transform: translateX(46px);
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const StyledBarSpinner = styled.div`
|
|
15
|
+
display: inline-block;
|
|
16
|
+
width: 200px;
|
|
17
|
+
height: 14px; /* Can be anything */
|
|
18
|
+
position: relative;
|
|
19
|
+
border-radius: 25px;
|
|
20
|
+
|
|
21
|
+
> span {
|
|
22
|
+
display: block;
|
|
23
|
+
height: 100%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-radius: 25px;
|
|
26
|
+
position: relative;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
background-color: ${COLORS.curiousBlue};
|
|
29
|
+
|
|
30
|
+
&:after {
|
|
31
|
+
content: '';
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
left: -46px;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
background: repeating-linear-gradient(
|
|
38
|
+
-55deg,
|
|
39
|
+
transparent 1px,
|
|
40
|
+
rgba(255, 255, 255, 0.25) 2px,
|
|
41
|
+
rgba(255, 255, 255, 0.25) 11px,
|
|
42
|
+
transparent 12px,
|
|
43
|
+
transparent 20px
|
|
44
|
+
);
|
|
45
|
+
animation-name: ${moveBg};
|
|
46
|
+
animation-duration: 1s;
|
|
47
|
+
animation-timing-function: linear;
|
|
48
|
+
animation-iteration-count: infinite;
|
|
49
|
+
border-radius: 20px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { PermafrostComponent } from '@/types';
|
|
6
|
+
|
|
7
|
+
import { StyledBarSpinner } from './BarSpinner.styles';
|
|
8
|
+
|
|
9
|
+
type Props = PermafrostComponent & {
|
|
10
|
+
width?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function BarSpinner(props: Props): React.ReactElement {
|
|
14
|
+
const { className, id, width = '100%' } = props;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<StyledBarSpinner className={className} data-cy={props['data-cy']} id={id} style={{ width }}>
|
|
18
|
+
<span />
|
|
19
|
+
</StyledBarSpinner>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BarSpinner } from './BarSpinner';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { CirclePulse } from './CirclePulse';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: CirclePulse,
|
|
7
|
+
title: 'Loading/CirclePulse',
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} satisfies Meta<typeof CirclePulse>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof CirclePulse>;
|
|
13
|
+
|
|
14
|
+
export const Normal: Story = {};
|
|
15
|
+
|
|
16
|
+
export const CustomColor: Story = {
|
|
17
|
+
args: { color: '#f0f' },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const WithRandomMessage: Story = {
|
|
21
|
+
args: { showRandomMessage: true },
|
|
22
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { COLORS, TYPOGRAPHY } from '@/tokens';
|
|
4
|
+
|
|
5
|
+
const ripple = (size: string) => keyframes`
|
|
6
|
+
0% {
|
|
7
|
+
width: 0;
|
|
8
|
+
height: 0;
|
|
9
|
+
opacity: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
20% {
|
|
13
|
+
opacity: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
100% {
|
|
17
|
+
width: ${size};
|
|
18
|
+
height: ${size};
|
|
19
|
+
opacity: 0;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const animationSpeed = 1.4;
|
|
24
|
+
|
|
25
|
+
export const StyledLoadingIndicator = styled.div<{
|
|
26
|
+
overallSize: string;
|
|
27
|
+
rippleSize: string;
|
|
28
|
+
}>`
|
|
29
|
+
display: grid;
|
|
30
|
+
place-items: center;
|
|
31
|
+
|
|
32
|
+
width: ${(props) => props.overallSize};
|
|
33
|
+
height: ${(props) => props.overallSize};
|
|
34
|
+
|
|
35
|
+
margin-left: auto;
|
|
36
|
+
margin-right: auto;
|
|
37
|
+
|
|
38
|
+
&:before,
|
|
39
|
+
&:after {
|
|
40
|
+
content: '';
|
|
41
|
+
border: 4px solid currentColor;
|
|
42
|
+
border-radius: 50%;
|
|
43
|
+
|
|
44
|
+
grid-area: 1 / 1;
|
|
45
|
+
|
|
46
|
+
animation: ${(props) => ripple(props.rippleSize)} ${animationSpeed}s
|
|
47
|
+
cubic-bezier(0, 0.2, 0.8, 1) infinite;
|
|
48
|
+
|
|
49
|
+
@media (prefers-reduced-motion) {
|
|
50
|
+
animation-duration: ${animationSpeed * 2}s;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:after {
|
|
55
|
+
animation-delay: -${animationSpeed / 2}s;
|
|
56
|
+
|
|
57
|
+
@media (prefers-reduced-motion) {
|
|
58
|
+
animation-delay: -${animationSpeed}s;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export const StyledMessageLoadingIndicator = styled.div<{ overallSize: string }>`
|
|
64
|
+
display: block;
|
|
65
|
+
|
|
66
|
+
> * {
|
|
67
|
+
margin-left: auto;
|
|
68
|
+
margin-right: auto;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.message {
|
|
72
|
+
text-align: center;
|
|
73
|
+
display: block;
|
|
74
|
+
width: ${(props) => props.overallSize};
|
|
75
|
+
margin-top: -50px;
|
|
76
|
+
|
|
77
|
+
color: ${COLORS.lightFontColor};
|
|
78
|
+
font-size: ${TYPOGRAPHY.fontSize.base};
|
|
79
|
+
font-style: italic;
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { COLORS } from '@/tokens';
|
|
6
|
+
import { PermafrostComponent } from '@/types';
|
|
7
|
+
import { RandomLoadingMessage } from '../RandomLoadingMessage';
|
|
8
|
+
|
|
9
|
+
import { StyledLoadingIndicator, StyledMessageLoadingIndicator } from './CirclePulse.styles';
|
|
10
|
+
|
|
11
|
+
type Props = PermafrostComponent & {
|
|
12
|
+
color?: string;
|
|
13
|
+
overallSize?: string | number;
|
|
14
|
+
rippleSize?: string | number;
|
|
15
|
+
showRandomMessage?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function CirclePulse(props: Props): React.ReactElement {
|
|
19
|
+
const {
|
|
20
|
+
className,
|
|
21
|
+
color,
|
|
22
|
+
id,
|
|
23
|
+
overallSize = '200px',
|
|
24
|
+
rippleSize = '76px',
|
|
25
|
+
showRandomMessage,
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
const loadingIndicator = () => {
|
|
29
|
+
return (
|
|
30
|
+
<StyledLoadingIndicator
|
|
31
|
+
aria-hidden={true}
|
|
32
|
+
className={className}
|
|
33
|
+
data-cy={props['data-cy']}
|
|
34
|
+
id={id}
|
|
35
|
+
overallSize={returnSizeString(overallSize)}
|
|
36
|
+
rippleSize={returnSizeString(rippleSize)}
|
|
37
|
+
style={color ? { color } : { color: COLORS.curiousBlue }}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
if (showRandomMessage) {
|
|
43
|
+
return (
|
|
44
|
+
<StyledMessageLoadingIndicator overallSize={returnSizeString(overallSize)}>
|
|
45
|
+
{loadingIndicator()}
|
|
46
|
+
|
|
47
|
+
<RandomLoadingMessage />
|
|
48
|
+
</StyledMessageLoadingIndicator>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return loadingIndicator();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function returnSizeString(size: string | number): string {
|
|
56
|
+
if (typeof size === 'number') {
|
|
57
|
+
return `${size}px`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return size;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CirclePulse } from './CirclePulse';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { CircleSpinner } from './CircleSpinner';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: CircleSpinner,
|
|
7
|
+
title: 'Loading/CircleSpinner',
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} satisfies Meta<typeof CircleSpinner>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof CircleSpinner>;
|
|
13
|
+
|
|
14
|
+
export const Normal: Story = {
|
|
15
|
+
args: {},
|
|
16
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Icon } from '../../Icon';
|
|
6
|
+
import { PermafrostComponent } from '@/types';
|
|
7
|
+
|
|
8
|
+
type Props = PermafrostComponent & {
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
size?: string;
|
|
11
|
+
style?: { [key: string]: string };
|
|
12
|
+
fill?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function CircleSpinner(props: Props): React.ReactElement {
|
|
16
|
+
const { className, fill, id, size, style, ariaLabel = 'Loading...' } = props;
|
|
17
|
+
|
|
18
|
+
const loaderSize = size || '12px';
|
|
19
|
+
const loaderStyle = {
|
|
20
|
+
position: 'relative',
|
|
21
|
+
top: '1px',
|
|
22
|
+
...style,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Icon
|
|
27
|
+
name="fa-circle-notch"
|
|
28
|
+
className={`spin ${className || ''}`}
|
|
29
|
+
data-cy={props['data-cy']}
|
|
30
|
+
id={id}
|
|
31
|
+
size={[loaderSize]}
|
|
32
|
+
style={loaderStyle}
|
|
33
|
+
fill={fill || 'currentColor'}
|
|
34
|
+
ariaLabel={ariaLabel}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CircleSpinner } from './CircleSpinner';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { LoadingList } from './LoadingList';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: LoadingList,
|
|
7
|
+
title: 'Loading/LoadingList',
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} satisfies Meta<typeof LoadingList>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof LoadingList>;
|
|
13
|
+
|
|
14
|
+
export const Normal: Story = {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { COLORS } from '@/tokens';
|
|
4
|
+
|
|
5
|
+
const loadingAnimation = keyframes`
|
|
6
|
+
0% {
|
|
7
|
+
background-position: 100% 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
100% {
|
|
11
|
+
background-position: 0 0;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const StyledLoadingList = styled.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
height: 40vh;
|
|
19
|
+
|
|
20
|
+
background-image: repeating-linear-gradient(
|
|
21
|
+
to bottom,
|
|
22
|
+
${COLORS.ebony} 0px,
|
|
23
|
+
${COLORS.ebony} 60px,
|
|
24
|
+
${COLORS.clay} 60px,
|
|
25
|
+
${COLORS.clay} 65px
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
&:before {
|
|
29
|
+
content: '';
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
height: 100%;
|
|
34
|
+
width: 100%;
|
|
35
|
+
|
|
36
|
+
opacity: 0.75;
|
|
37
|
+
|
|
38
|
+
background-image: linear-gradient(to right, transparent, ${COLORS.clay}, transparent);
|
|
39
|
+
background-size: 400% 100%;
|
|
40
|
+
animation: ${loadingAnimation} 2s ease infinite;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { StyledLoadingList } from './LoadingList.styles';
|
|
6
|
+
|
|
7
|
+
export const LoadingList = () => {
|
|
8
|
+
return <StyledLoadingList />;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoadingList } from './LoadingList';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { PercentageRing } from './PercentageRing';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
component: PercentageRing,
|
|
7
|
+
title: 'Loading/PercentageRing',
|
|
8
|
+
argTypes: {},
|
|
9
|
+
} satisfies Meta<typeof PercentageRing>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof PercentageRing>;
|
|
13
|
+
|
|
14
|
+
export const Normal: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
value: 0.23,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const StyledPercentageRing = styled.div`
|
|
4
|
+
position: relative;
|
|
5
|
+
|
|
6
|
+
svg {
|
|
7
|
+
transform: rotate(-90deg);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
div {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
|
|
19
|
+
margin-top: -0.05em;
|
|
20
|
+
margin-left: 0.1em;
|
|
21
|
+
|
|
22
|
+
span {
|
|
23
|
+
font-size: 0.6em;
|
|
24
|
+
margin-top: -0.5em;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { COLORS } from '@/tokens';
|
|
6
|
+
import { PermafrostComponent } from '@/types';
|
|
7
|
+
|
|
8
|
+
import { StyledPercentageRing } from './PercentageRing.styles';
|
|
9
|
+
|
|
10
|
+
type Props = PermafrostComponent & {
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
foregroundColor?: string;
|
|
13
|
+
ringRadius?: number;
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
/** an integer between 0 and 1 */
|
|
16
|
+
value: number;
|
|
17
|
+
valueFontSize?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function PercentageRing(props: Props) {
|
|
21
|
+
const {
|
|
22
|
+
backgroundColor = COLORS.clay,
|
|
23
|
+
className,
|
|
24
|
+
foregroundColor = COLORS.baliHai,
|
|
25
|
+
id,
|
|
26
|
+
ringRadius = 35,
|
|
27
|
+
strokeWidth = 5,
|
|
28
|
+
value = 0,
|
|
29
|
+
valueFontSize = 20,
|
|
30
|
+
} = props;
|
|
31
|
+
|
|
32
|
+
const ringCircumference = 2 * Math.PI * (ringRadius - strokeWidth / 2);
|
|
33
|
+
const valueCircumference = ringCircumference - value * ringCircumference;
|
|
34
|
+
const diameter = ringRadius * 2;
|
|
35
|
+
const circleRadius = ringRadius - strokeWidth / 2;
|
|
36
|
+
|
|
37
|
+
// ensure we don’t display a value greater than 100% to the user
|
|
38
|
+
const displayValue = Math.round(Math.min(value, 1) * 100);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<StyledPercentageRing className={className} data-cy={props['data-cy']} id={id}>
|
|
42
|
+
<div
|
|
43
|
+
style={{
|
|
44
|
+
fontSize: valueFontSize,
|
|
45
|
+
width: diameter,
|
|
46
|
+
height: diameter,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
{displayValue}
|
|
50
|
+
<span>%</span>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<svg
|
|
54
|
+
height={diameter}
|
|
55
|
+
width={diameter}
|
|
56
|
+
fill="none"
|
|
57
|
+
strokeWidth={strokeWidth}
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
focusable="false"
|
|
60
|
+
>
|
|
61
|
+
<g>
|
|
62
|
+
<circle r={circleRadius} cx={ringRadius} cy={ringRadius} stroke={backgroundColor} />
|
|
63
|
+
|
|
64
|
+
<circle
|
|
65
|
+
r={circleRadius}
|
|
66
|
+
cx={ringRadius}
|
|
67
|
+
cy={ringRadius}
|
|
68
|
+
stroke={foregroundColor}
|
|
69
|
+
strokeDasharray={ringCircumference}
|
|
70
|
+
strokeDashoffset={valueCircumference}
|
|
71
|
+
/>
|
|
72
|
+
</g>
|
|
73
|
+
</svg>
|
|
74
|
+
</StyledPercentageRing>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PercentageRing } from './PercentageRing';
|
package/src/components/loading-indicators/RandomLoadingMessage/RandomLoadingMessage.stories.tsx
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
import { RandomLoadingMessage } from './RandomLoadingMessage';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: RandomLoadingMessage,
|
|
9
|
+
title: 'Loading/RandomLoadingMessage',
|
|
10
|
+
argTypes: {},
|
|
11
|
+
} satisfies Meta<typeof RandomLoadingMessage>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof RandomLoadingMessage>;
|
|
15
|
+
|
|
16
|
+
export const Normal: Story = {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import MESSAGES from './random-messages';
|
|
3
|
+
|
|
4
|
+
export const RandomLoadingMessage = () => {
|
|
5
|
+
const [randomMessage, changeRandomMessage] = useState<string>(
|
|
6
|
+
MESSAGES[Math.floor(Math.random() * MESSAGES.length)],
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const timer = setTimeout(() => {
|
|
11
|
+
changeRandomMessage(MESSAGES[Math.floor(Math.random() * MESSAGES.length)]);
|
|
12
|
+
}, 3000);
|
|
13
|
+
|
|
14
|
+
return () => clearTimeout(timer);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return <span className="message">{randomMessage}...</span>;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RandomLoadingMessage } from './RandomLoadingMessage';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const MESSAGES = [
|
|
2
|
+
'Charging the flux capacitor',
|
|
3
|
+
'Spinning up the hamster wheel',
|
|
4
|
+
'Flushing the pipes',
|
|
5
|
+
'Counting all the beans',
|
|
6
|
+
'Take a deep breath and enjoy this beautiful moment',
|
|
7
|
+
'Counting digits in pi (almost done)',
|
|
8
|
+
'Folding time and space',
|
|
9
|
+
'Oiling the gears',
|
|
10
|
+
'Peeling the data fruits',
|
|
11
|
+
'Activating the oscillation overthruster',
|
|
12
|
+
'Gleaming the cube',
|
|
13
|
+
'Reticulating splines',
|
|
14
|
+
'Playing a quick game of squash',
|
|
15
|
+
'Making the sausage',
|
|
16
|
+
'Building the matrix',
|
|
17
|
+
'Drawing fractals',
|
|
18
|
+
'Testing memory (what did you have for breakfast?)',
|
|
19
|
+
'Priming data pumps',
|
|
20
|
+
'Whacking datamoles',
|
|
21
|
+
'Finding Nemo',
|
|
22
|
+
'Running spin cycle',
|
|
23
|
+
'Chasing down a dream',
|
|
24
|
+
'Twiddling the knobs',
|
|
25
|
+
'Assembling lines',
|
|
26
|
+
'Making the donuts',
|
|
27
|
+
'Gathering magic',
|
|
28
|
+
'Rolling stones',
|
|
29
|
+
'Busting all the moves',
|
|
30
|
+
'Augmenting reality',
|
|
31
|
+
'Leveling up',
|
|
32
|
+
'Obviating frequencies',
|
|
33
|
+
'Declaring variables',
|
|
34
|
+
'Boosting thrusters',
|
|
35
|
+
'Blazing the saddles',
|
|
36
|
+
'Flipping some bits',
|
|
37
|
+
'Unclogging the internet',
|
|
38
|
+
'Turning it off and back on again',
|
|
39
|
+
'Entering the ThunderDome',
|
|
40
|
+
'Rolling logs',
|
|
41
|
+
'Dangling particles',
|
|
42
|
+
'Catching moonbeams',
|
|
43
|
+
'Digging for treasure',
|
|
44
|
+
'Reconbulating the conbulator',
|
|
45
|
+
'Machine learning',
|
|
46
|
+
'Magicing',
|
|
47
|
+
'Tuning the forks',
|
|
48
|
+
'Fiddling widgets',
|
|
49
|
+
'Feeding the data monkeys',
|
|
50
|
+
'Regularizing expressions',
|
|
51
|
+
'Ramping up the synergy',
|
|
52
|
+
'Inflating point flotations',
|
|
53
|
+
'Entering orbit around alpha centuri',
|
|
54
|
+
'Squeezing data tubes',
|
|
55
|
+
'Making a list and checking it twice',
|
|
56
|
+
'Unkinking the data tubes',
|
|
57
|
+
'Turning on the data hose',
|
|
58
|
+
'Preparing for liftoff',
|
|
59
|
+
'Replacing the hamsters',
|
|
60
|
+
'Changing the batteries',
|
|
61
|
+
'Waking up our engineers',
|
|
62
|
+
'Contemplating the meaning of life',
|
|
63
|
+
'Downloading fresh dog memes',
|
|
64
|
+
'Springing the chickens',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export default MESSAGES;
|