@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
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yarnPath: .yarn/releases/yarn-classic.cjs
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Indico Design System - codename Permafrost
|
|
2
|
+
|
|
3
|
+
## Module Organization
|
|
4
|
+
|
|
5
|
+
- Components and Stories are now in `src/stories`
|
|
6
|
+
- Global Styles `src/styles`
|
|
7
|
+
- Design Tokens `src/tokens`
|
|
8
|
+
|
|
9
|
+
## Storybook Dev Server Initialization
|
|
10
|
+
|
|
11
|
+
Install dependencies with a simple `yarn` command.
|
|
12
|
+
|
|
13
|
+
`yarn dev` runs the command `storybook dev -p 6006` which should boot the dev server and open the local host in a browser window.
|
|
14
|
+
|
|
15
|
+
## Additional scripts
|
|
16
|
+
|
|
17
|
+
Run the below like `yarn <my command>`
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
"build": "storybook build",
|
|
21
|
+
"test-storybook": "test-storybook",
|
|
22
|
+
"prepare": "husky install"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Concerning TODOS
|
|
26
|
+
|
|
27
|
+
Ideally, each component migrated from the Intake mono-repo (aka stratosphere) will have a corresponding JIRA ticket,
|
|
28
|
+
including ACs for potential refactor, updated documentation, and unit tests. However, the first migration of
|
|
29
|
+
core componenets has been fast-tracked to facilitate work on the Insights client MVP; therefore, these
|
|
30
|
+
components have not benefitted from the above and have `TODOS` indicating this. Corresponding JIRA tickets will follow.
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@indico-data/design-system",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"private": false,
|
|
6
|
+
"author": "",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "storybook dev -p 6006",
|
|
9
|
+
"build": "storybook build",
|
|
10
|
+
"test-storybook": "test-storybook",
|
|
11
|
+
"prepare": "husky install"
|
|
12
|
+
},
|
|
13
|
+
"lint-staged": {
|
|
14
|
+
"**/*": "prettier --write --ignore-unknown"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@babel/core": "^7.23.3",
|
|
18
|
+
"@babel/preset-env": "^7.23.3",
|
|
19
|
+
"@babel/preset-react": "^7.23.3",
|
|
20
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
21
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
|
22
|
+
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
|
23
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
|
24
|
+
"@indico-data/utils": "^0.0.5",
|
|
25
|
+
"@react-aria/button": "^3.9.0",
|
|
26
|
+
"@react-aria/focus": "^3.15.0",
|
|
27
|
+
"@types/react": "^18",
|
|
28
|
+
"@types/react-dom": "^18",
|
|
29
|
+
"babel-loader": "^9.1.3",
|
|
30
|
+
"babel-preset-react-app": "^10.0.1",
|
|
31
|
+
"classnames": "^2.3.2",
|
|
32
|
+
"date-fns": "^2.30.0",
|
|
33
|
+
"html-webpack-plugin": "^5.5.3",
|
|
34
|
+
"react": "^18",
|
|
35
|
+
"react-dom": "^18",
|
|
36
|
+
"react-router-dom": "^6.18.0",
|
|
37
|
+
"react-select": "^5.8.0",
|
|
38
|
+
"simple-zustand-devtools": "^1.1.0",
|
|
39
|
+
"styled-components": "^6.1.1",
|
|
40
|
+
"svgo": "^3.0.3",
|
|
41
|
+
"typescript": "^5.2.2",
|
|
42
|
+
"webpack": "^5",
|
|
43
|
+
"webpack-cli": "^5.1.4",
|
|
44
|
+
"webpack-dev-server": "^4.15.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@storybook/addon-a11y": "^7.5.3",
|
|
48
|
+
"@storybook/addon-docs": "^7.5.3",
|
|
49
|
+
"@storybook/addon-essentials": "^7.5.3",
|
|
50
|
+
"@storybook/addon-interactions": "^7.5.3",
|
|
51
|
+
"@storybook/addon-links": "^7.5.3",
|
|
52
|
+
"@storybook/addon-onboarding": "^1.0.8",
|
|
53
|
+
"@storybook/addon-styling": "^2.0.2-next.4",
|
|
54
|
+
"@storybook/addon-styling-webpack": "^0.0.5",
|
|
55
|
+
"@storybook/addon-themes": "^7.5.3",
|
|
56
|
+
"@storybook/blocks": "^7.5.3",
|
|
57
|
+
"@storybook/react": "^7.5.3",
|
|
58
|
+
"@storybook/react-webpack5": "^7.5.3",
|
|
59
|
+
"@storybook/test": "^7.6.0-alpha.4",
|
|
60
|
+
"@storybook/test-runner": "^0.15.1",
|
|
61
|
+
"@types/styled-components": "^5.1.30",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
63
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
64
|
+
"babel-plugin-styled-components": "^2.1.4",
|
|
65
|
+
"eslint": "^8.53.0",
|
|
66
|
+
"eslint-plugin-react": "^7.33.2",
|
|
67
|
+
"husky": "^8.0.3",
|
|
68
|
+
"lint-staged": "^15.1.0",
|
|
69
|
+
"prettier": "3.1.0",
|
|
70
|
+
"storybook": "^7.5.3",
|
|
71
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0"
|
|
72
|
+
},
|
|
73
|
+
"resolutions": {
|
|
74
|
+
"jackspeak": "2.1.1"
|
|
75
|
+
},
|
|
76
|
+
"volta": {
|
|
77
|
+
"node": "20.9.0"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Button } from '@/components';
|
|
5
|
+
import { Accordion } from './Accordion';
|
|
6
|
+
|
|
7
|
+
const content = (
|
|
8
|
+
<div>
|
|
9
|
+
<h2 style={{ marginBottom: '10px' }}>Lorem</h2>
|
|
10
|
+
<p style={{ marginBottom: '10px' }}>
|
|
11
|
+
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Recusandae, repudiandae ipsa
|
|
12
|
+
officiis dolores dolore iusto saepe harum maxime placeat ut culpa excepturi praesentium optio
|
|
13
|
+
minus velit odio voluptate veniam nulla.
|
|
14
|
+
</p>
|
|
15
|
+
<p style={{ marginBottom: '20px' }}>
|
|
16
|
+
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Recusandae, repudiandae ipsa
|
|
17
|
+
officiis dolores dolore iusto saepe harum maxime placeat ut culpa excepturi praesentium optio
|
|
18
|
+
minus velit odio voluptate veniam nulla. Lorem ipsum dolor sit, amet consectetur adipisicing
|
|
19
|
+
elit. Recusandae, repudiandae ipsa officiis dolores dolore iusto saepe harum maxime placeat ut
|
|
20
|
+
culpa excepturi praesentium optio minus velit odio voluptate veniam nulla. Lorem ipsum dolor
|
|
21
|
+
sit, amet consectetur adipisicing elit. Recusandae, repudiandae ipsa officiis dolores dolore
|
|
22
|
+
iusto saepe harum maxime placeat ut culpa excepturi praesentium optio minus velit odio
|
|
23
|
+
voluptate veniam nulla.
|
|
24
|
+
</p>
|
|
25
|
+
<Button onClick={() => {}}>Button</Button>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const meta = {
|
|
30
|
+
component: Accordion,
|
|
31
|
+
title: 'Accordion',
|
|
32
|
+
argTypes: {},
|
|
33
|
+
decorators: [
|
|
34
|
+
(Story) => (
|
|
35
|
+
<div style={{ display: 'flex' }}>
|
|
36
|
+
<Story content={content} />
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
],
|
|
40
|
+
} satisfies Meta<typeof Accordion>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
type Story = StoryObj<typeof Accordion>;
|
|
44
|
+
|
|
45
|
+
export const Normal: Story = {};
|
|
46
|
+
|
|
47
|
+
export const WithHeader: Story = { args: { header: 'Accordion Toggle' } };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const StyledAccordion = styled.details`
|
|
4
|
+
summary {
|
|
5
|
+
display: inherit;
|
|
6
|
+
padding: 0 12px;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.header-container,
|
|
11
|
+
h2 {
|
|
12
|
+
display: flex;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.toggle-icon {
|
|
16
|
+
height: 24px;
|
|
17
|
+
margin: 6px 0;
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
transition: 0.3s transform ease-in-out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
h2 {
|
|
23
|
+
align-items: center;
|
|
24
|
+
margin: 0 0 0 8px;
|
|
25
|
+
font-size: 22px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.content {
|
|
29
|
+
margin: 10px 0 10px 20px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&[open] > summary .toggle-icon {
|
|
33
|
+
transform: rotate(180deg);
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 '@/components';
|
|
6
|
+
import { PermafrostComponent } from '@/types';
|
|
7
|
+
|
|
8
|
+
import { StyledAccordion } from './Accordion.styles';
|
|
9
|
+
|
|
10
|
+
type Props = PermafrostComponent & {
|
|
11
|
+
content: React.ReactNode;
|
|
12
|
+
header?: React.ReactNode | string;
|
|
13
|
+
open?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Accordion = (props: Props) => {
|
|
17
|
+
const { className, content, header, id, open } = props;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<StyledAccordion className={className} id={id} open={open} data-cy={props['data-cy']}>
|
|
21
|
+
<summary>
|
|
22
|
+
<div className="header-container">
|
|
23
|
+
<Icon className="toggle-icon" name="chevron-up" size={[14]} />
|
|
24
|
+
{header ? <h2>{header}</h2> : null}
|
|
25
|
+
</div>
|
|
26
|
+
</summary>
|
|
27
|
+
<div className="content">{content}</div>
|
|
28
|
+
</StyledAccordion>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Accordion } from './Accordion';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { faIcons } from './faIcons';
|
|
5
|
+
import { indicons } from './indicons';
|
|
6
|
+
import { Icon, IconName } from './Icon';
|
|
7
|
+
import { IconContainer, SpecifiedSizeContainer } from './storyHelpers';
|
|
8
|
+
|
|
9
|
+
const indiconsOptions: IconName[] = Object.keys(indicons) as IconName[];
|
|
10
|
+
const faIconsOptions: IconName[] = Object.keys(faIcons) as IconName[];
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
|
+
component: Icon,
|
|
14
|
+
title: 'Icon',
|
|
15
|
+
argTypes: {
|
|
16
|
+
ariaLabel: { control: { disable: true } },
|
|
17
|
+
size: { description: '[value] or [height, width]' },
|
|
18
|
+
name: { control: { type: 'select', options: indiconsOptions } },
|
|
19
|
+
},
|
|
20
|
+
decorators: [
|
|
21
|
+
(Story) => (
|
|
22
|
+
<IconContainer>
|
|
23
|
+
<Story />
|
|
24
|
+
</IconContainer>
|
|
25
|
+
),
|
|
26
|
+
],
|
|
27
|
+
} satisfies Meta<typeof Icon>;
|
|
28
|
+
|
|
29
|
+
export default meta;
|
|
30
|
+
type Story = StoryObj<typeof Icon>;
|
|
31
|
+
|
|
32
|
+
export const General: Story = {
|
|
33
|
+
argTypes: { name: { control: { type: 'select', options: indiconsOptions } } },
|
|
34
|
+
args: {
|
|
35
|
+
name: indiconsOptions[0],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Indicon: Story = {
|
|
40
|
+
argTypes: { name: { control: { type: 'select', options: indiconsOptions } } },
|
|
41
|
+
args: { name: indiconsOptions[0] },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const FontAwesome: Story = {
|
|
45
|
+
argTypes: { name: { control: { type: 'select', options: faIconsOptions } } },
|
|
46
|
+
args: { name: faIconsOptions[27] },
|
|
47
|
+
};
|
|
48
|
+
export const SizeSpecified: Story = {
|
|
49
|
+
argTypes: { name: { control: { type: 'select', options: indiconsOptions } } },
|
|
50
|
+
args: { name: indiconsOptions[0] },
|
|
51
|
+
render: (args) => (
|
|
52
|
+
<SpecifiedSizeContainer>
|
|
53
|
+
<Icon {...args} size={[150]} />
|
|
54
|
+
<code>{'size = {[150]}'}</code>
|
|
55
|
+
|
|
56
|
+
<Icon {...args} size={[100, 100]} />
|
|
57
|
+
<code>{'size = {[100, 100]}'}</code>
|
|
58
|
+
</SpecifiedSizeContainer>
|
|
59
|
+
),
|
|
60
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
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 { faIcons } from './faIcons';
|
|
8
|
+
import { indicons } from './indicons';
|
|
9
|
+
|
|
10
|
+
const allIcons = {
|
|
11
|
+
...faIcons,
|
|
12
|
+
...indicons,
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type IconName = keyof typeof allIcons;
|
|
16
|
+
|
|
17
|
+
type Props = PermafrostComponent & {
|
|
18
|
+
ariaLabel?: string;
|
|
19
|
+
fill?: string;
|
|
20
|
+
name: IconName;
|
|
21
|
+
/* `[value]` or `[width, height]` */
|
|
22
|
+
size?: [string | number] | [string | number, string | number];
|
|
23
|
+
style?: any;
|
|
24
|
+
onClick?(): void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type IconComponentProps = {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
fill: string;
|
|
30
|
+
viewBox: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Generic icon component, hidden from Assistive Technology by default.
|
|
35
|
+
* If icon should be available to AT, pass the desired name into the `ariaLabel` prop.
|
|
36
|
+
*/
|
|
37
|
+
export function Icon({ style = {}, ...props }: Props): React.ReactElement | null {
|
|
38
|
+
const ariaLabel = props.ariaLabel
|
|
39
|
+
? { 'aria-label': props.ariaLabel }
|
|
40
|
+
: { 'aria-hidden': true, focusable: false };
|
|
41
|
+
const iconComponentProps: IconComponentProps = allIcons[props.name]?.props || null;
|
|
42
|
+
const dimensions =
|
|
43
|
+
props.size && props.size.length > 0
|
|
44
|
+
? returnDimensions(props.size)
|
|
45
|
+
: { width: '1em', height: '1em' };
|
|
46
|
+
|
|
47
|
+
if (!iconComponentProps) {
|
|
48
|
+
console.error(`${props.name} is not a valid icon name.`);
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<svg
|
|
55
|
+
{...iconComponentProps}
|
|
56
|
+
{...ariaLabel}
|
|
57
|
+
{...dimensions}
|
|
58
|
+
role="img"
|
|
59
|
+
className={props.className}
|
|
60
|
+
data-cy={props['data-cy']}
|
|
61
|
+
fill={props.fill || 'currentColor'}
|
|
62
|
+
id={props.id}
|
|
63
|
+
style={style}
|
|
64
|
+
onClick={props.onClick}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function returnDimensions(sizeProp: [string | number] | [string | number, string | number]) {
|
|
70
|
+
if (sizeProp.length > 1) {
|
|
71
|
+
return { width: sizeProp[0], height: sizeProp[1] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return { width: sizeProp[0], height: sizeProp[0] };
|
|
75
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
|
+
import {
|
|
5
|
+
faCheckSquare,
|
|
6
|
+
faDotCircle,
|
|
7
|
+
faFile,
|
|
8
|
+
faFileAlt,
|
|
9
|
+
faFilePdf,
|
|
10
|
+
faFileWord,
|
|
11
|
+
faSquare,
|
|
12
|
+
} from '@fortawesome/free-regular-svg-icons';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
faAngleDoubleLeft,
|
|
16
|
+
faArrowCircleRight,
|
|
17
|
+
faArrowDown,
|
|
18
|
+
faArrowLeft,
|
|
19
|
+
faArrowRight,
|
|
20
|
+
faArrowUp,
|
|
21
|
+
faBan,
|
|
22
|
+
faCaretDown,
|
|
23
|
+
faCaretUp,
|
|
24
|
+
faChartBar,
|
|
25
|
+
faCheck,
|
|
26
|
+
faCheckCircle,
|
|
27
|
+
faCircleNotch,
|
|
28
|
+
faClipboard,
|
|
29
|
+
faClock,
|
|
30
|
+
faClone,
|
|
31
|
+
faCloud,
|
|
32
|
+
faCog,
|
|
33
|
+
faCogs,
|
|
34
|
+
faCoins,
|
|
35
|
+
faCube,
|
|
36
|
+
faCut,
|
|
37
|
+
faDownload,
|
|
38
|
+
faExclamationCircle,
|
|
39
|
+
faExclamationTriangle,
|
|
40
|
+
faExternalLinkAlt,
|
|
41
|
+
faEyeDropper,
|
|
42
|
+
faFileDownload,
|
|
43
|
+
faFileExport,
|
|
44
|
+
faFileUpload,
|
|
45
|
+
faFilter,
|
|
46
|
+
faGhost,
|
|
47
|
+
faHatWizard,
|
|
48
|
+
faInfoCircle,
|
|
49
|
+
faKey,
|
|
50
|
+
faKeyboard,
|
|
51
|
+
faLayerGroup,
|
|
52
|
+
faPencilAlt,
|
|
53
|
+
faPlus,
|
|
54
|
+
faPlusSquare,
|
|
55
|
+
faQuestionCircle,
|
|
56
|
+
faRobot,
|
|
57
|
+
faSearch,
|
|
58
|
+
faSignOutAlt,
|
|
59
|
+
faSlidersH,
|
|
60
|
+
faSyncAlt,
|
|
61
|
+
faTag,
|
|
62
|
+
faTimes,
|
|
63
|
+
faTimesCircle,
|
|
64
|
+
faTint,
|
|
65
|
+
faToggleOff,
|
|
66
|
+
faToggleOn,
|
|
67
|
+
faTrash,
|
|
68
|
+
faTrashAlt,
|
|
69
|
+
faUndo,
|
|
70
|
+
faUser,
|
|
71
|
+
faUsers,
|
|
72
|
+
faMousePointer,
|
|
73
|
+
faStepForward,
|
|
74
|
+
faSearchMinus,
|
|
75
|
+
faSearchPlus,
|
|
76
|
+
faTable,
|
|
77
|
+
faImage,
|
|
78
|
+
faLink,
|
|
79
|
+
faList,
|
|
80
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
81
|
+
|
|
82
|
+
const faIcons = {
|
|
83
|
+
'fa-dot-circle': generateSvg(faDotCircle),
|
|
84
|
+
'fa-file': generateSvg(faFile),
|
|
85
|
+
'fa-file-alt': generateSvg(faFileAlt),
|
|
86
|
+
'fa-file-pdf': generateSvg(faFilePdf),
|
|
87
|
+
'fa-file-word': generateSvg(faFileWord),
|
|
88
|
+
'fa-check-square': generateSvg(faCheckSquare),
|
|
89
|
+
'fa-square': generateSvg(faSquare),
|
|
90
|
+
|
|
91
|
+
'fa-angle-double-left': generateSvg(faAngleDoubleLeft),
|
|
92
|
+
'fa-arrow-circle-right': generateSvg(faArrowCircleRight),
|
|
93
|
+
'fa-arrow-down': generateSvg(faArrowDown),
|
|
94
|
+
'fa-arrow-left': generateSvg(faArrowLeft),
|
|
95
|
+
'fa-arrow-right': generateSvg(faArrowRight),
|
|
96
|
+
'fa-arrow-up': generateSvg(faArrowUp),
|
|
97
|
+
'fa-ban': generateSvg(faBan),
|
|
98
|
+
'fa-caret-down': generateSvg(faCaretDown),
|
|
99
|
+
'fa-caret-up': generateSvg(faCaretUp),
|
|
100
|
+
'fa-chart-bar': generateSvg(faChartBar),
|
|
101
|
+
'fa-check': generateSvg(faCheck),
|
|
102
|
+
'fa-check-circle': generateSvg(faCheckCircle),
|
|
103
|
+
'fa-circle-notch': generateSvg(faCircleNotch),
|
|
104
|
+
'fa-clipboard': generateSvg(faClipboard),
|
|
105
|
+
'fa-clock': generateSvg(faClock),
|
|
106
|
+
'fa-clone': generateSvg(faClone),
|
|
107
|
+
'fa-cloud': generateSvg(faCloud),
|
|
108
|
+
'fa-cog': generateSvg(faCog),
|
|
109
|
+
'fa-cogs': generateSvg(faCogs),
|
|
110
|
+
'fa-coins': generateSvg(faCoins),
|
|
111
|
+
'fa-cube': generateSvg(faCube),
|
|
112
|
+
'fa-cut': generateSvg(faCut),
|
|
113
|
+
'fa-download': generateSvg(faDownload),
|
|
114
|
+
'fa-exclamation-circle': generateSvg(faExclamationCircle),
|
|
115
|
+
'fa-exclamation-triangle': generateSvg(faExclamationTriangle),
|
|
116
|
+
'fa-external-link-alt': generateSvg(faExternalLinkAlt),
|
|
117
|
+
'fa-eye-dropper': generateSvg(faEyeDropper),
|
|
118
|
+
'fa-file-download': generateSvg(faFileDownload),
|
|
119
|
+
'fa-file-export': generateSvg(faFileExport),
|
|
120
|
+
'fa-file-upload': generateSvg(faFileUpload),
|
|
121
|
+
'fa-filter': generateSvg(faFilter),
|
|
122
|
+
'fa-ghost': generateSvg(faGhost),
|
|
123
|
+
'fa-hat-wizard': generateSvg(faHatWizard),
|
|
124
|
+
'fa-info-circle': generateSvg(faInfoCircle),
|
|
125
|
+
'fa-key': generateSvg(faKey),
|
|
126
|
+
'fa-keyboard': generateSvg(faKeyboard),
|
|
127
|
+
'fa-layer-group': generateSvg(faLayerGroup),
|
|
128
|
+
'fa-pencil-alt': generateSvg(faPencilAlt),
|
|
129
|
+
'fa-plus': generateSvg(faPlus),
|
|
130
|
+
'fa-plus-square': generateSvg(faPlusSquare),
|
|
131
|
+
'fa-question-circle': generateSvg(faQuestionCircle),
|
|
132
|
+
'fa-robot': generateSvg(faRobot),
|
|
133
|
+
'fa-search': generateSvg(faSearch),
|
|
134
|
+
'fa-sign-out-alt': generateSvg(faSignOutAlt),
|
|
135
|
+
'fa-sliders-h': generateSvg(faSlidersH),
|
|
136
|
+
'fa-sync-alt': generateSvg(faSyncAlt),
|
|
137
|
+
'fa-tag': generateSvg(faTag),
|
|
138
|
+
'fa-times': generateSvg(faTimes),
|
|
139
|
+
'fa-times-circle': generateSvg(faTimesCircle),
|
|
140
|
+
'fa-tint': generateSvg(faTint),
|
|
141
|
+
'fa-toggle-off': generateSvg(faToggleOff),
|
|
142
|
+
'fa-toggle-on': generateSvg(faToggleOn),
|
|
143
|
+
'fa-trash': generateSvg(faTrash),
|
|
144
|
+
'fa-trash-alt': generateSvg(faTrashAlt),
|
|
145
|
+
'fa-undo': generateSvg(faUndo),
|
|
146
|
+
'fa-user': generateSvg(faUser),
|
|
147
|
+
'fa-users': generateSvg(faUsers),
|
|
148
|
+
'fa-mouse-pointer': generateSvg(faMousePointer),
|
|
149
|
+
'fa-step-forward': generateSvg(faStepForward),
|
|
150
|
+
'fa-search-minus': generateSvg(faSearchMinus),
|
|
151
|
+
'fa-search-plus': generateSvg(faSearchPlus),
|
|
152
|
+
'fa-table': generateSvg(faTable),
|
|
153
|
+
'fa-image': generateSvg(faImage),
|
|
154
|
+
'fa-link': generateSvg(faLink),
|
|
155
|
+
'fa-list': generateSvg(faList),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
function generateSvg(iconDefinition: IconDefinition): React.ReactElement {
|
|
159
|
+
const { icon } = iconDefinition;
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<svg fill="currentColor" viewBox={`0 0 ${icon[0]} ${icon[1]}`}>
|
|
163
|
+
<path d={`${icon[4]}`} />
|
|
164
|
+
</svg>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export { faIcons };
|