Skip to content

Commit f2df236

Browse files
authored
feat(icons): clear icons Cu 1x73an0 (#240)
1 parent fcc1242 commit f2df236

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+595
-843
lines changed

.storybook/preview.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import React from 'react';
22

3-
import { library } from '@fortawesome/fontawesome-svg-core';
4-
// Font Awesome icons
5-
import { fas } from '@fortawesome/free-solid-svg-icons';
6-
import { far } from '@fortawesome/free-regular-svg-icons';
7-
83
import ThemeProvider from '../src/theme/ThemeProvider';
94

10-
library.add(fas, far);
11-
125
export const parameters = {
136
actions: { argTypesRegex: '^on[A-Z].*' },
147
layout: 'centered',
@@ -17,7 +10,7 @@ export const parameters = {
1710

1811
export const decorators = [
1912
(Story) => (
20-
<ThemeProvider theme="default">
13+
<ThemeProvider>
2114
<Story />
2215
</ThemeProvider>
2316
),

package.json

-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@
9090
],
9191
"dependencies": {
9292
"@emotion/core": "^10.3.1",
93-
"@fortawesome/fontawesome-common-types": "^0.3.0",
94-
"@fortawesome/fontawesome-svg-core": "^1.3.0",
95-
"@fortawesome/free-regular-svg-icons": "^6.0.0",
96-
"@fortawesome/free-solid-svg-icons": "^6.0.0",
97-
"@fortawesome/react-fontawesome": "^0.1.17",
9893
"@rebass/forms": "^4.0.6",
9994
"@styled-system/css": "^5.1.5",
10095
"@tanem/react-nprogress": "^4.0.8",

src/@types/emotion-theming.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ITheme } from '../theme/types'
2+
3+
declare module 'emotion-theming' {
4+
export interface Theme extends ITheme {}
5+
export function useTheme(): ITheme;
6+
}

src/components/badges/badge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const Badge: FC<BadgeProps> = ({
5959
icon,
6060
...props
6161
}: BadgeProps) => {
62-
const theme = useTheme<ITheme>();
62+
const theme = useTheme();
6363

6464
const borderColor = getBorderColor(theme, variant);
6565
const borderStyle = loading

src/components/badges/project-badge.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Flex, FlexProps } from 'rebass';
33

44
// Components
55
import Value from '../typography/value';
6-
import Icon from '../icon';
6+
import GetIcon from '../icon/GetIcon';
7+
import { IconName } from '../icon/list';
78

89
export interface ProjectBadgeProps extends Omit<FlexProps, 'css'> {
910
value: string | number;
@@ -32,7 +33,7 @@ const ProjectBadge: FC<ProjectBadgeProps> = ({
3233
<Value as="span" lineHeight="13px">
3334
{value}
3435
</Value>
35-
{isLock && <Icon ml="5px" fontSize="10px" icon="lock" />}
36+
{isLock && <GetIcon ml="5px" fontSize="10px" icon={IconName.lock} />}
3637
</Flex>
3738
);
3839

src/components/button/button.stories.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { action } from '@storybook/addon-actions';
33
import React from 'react';
44
import { Story, Meta } from '@storybook/react/types-6-0';
5-
import { faCoffee } from '@fortawesome/free-solid-svg-icons';
65

76
import Button, { QuartzButtonProps } from '.';
7+
import { IconName } from '../icon';
88

99
export default {
1010
title: 'Quartz/Buttons',
@@ -66,11 +66,10 @@ Default.argTypes = {
6666
icon: {
6767
control: {
6868
type: 'select',
69-
options: [undefined, faCoffee],
69+
options: [undefined, IconName.upload],
7070
},
7171
type: {
72-
summary:
73-
'Put icon component from @fortawesome/free-solid-svg-icons package',
72+
summary: 'Put icon component from IconName',
7473
},
7574
},
7675
};

src/components/button/button.styles.ts

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export default {
2626

2727
'> span': {
2828
mr: '8px',
29+
display: 'flex',
30+
height: '15px',
31+
justifyContent: 'center',
32+
alignItems: 'center',
2933
},
3034
} as SxStyleProp;
3135

src/components/button/index.tsx

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import React, { FC } from 'react';
22
import { Button as RebassButton, ButtonProps } from 'rebass';
3-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4-
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
3+
import * as R from 'ramda';
54

65
// Styles
76
import styles, { spinnerColor } from './button.styles';
87
import Spinner from '../spinner';
98

9+
import { GetIcon, IconName } from '../icon';
10+
import { Color } from '../../theme/types';
11+
12+
type Intent = 'primary' | 'secondary' | 'ghost' | 'inline' | 'alert';
1013
export interface QuartzButtonProps extends Omit<ButtonProps, 'css'> {
1114
children: React.ReactNode;
12-
intent?: 'primary' | 'secondary' | 'ghost' | 'inline' | 'alert';
13-
icon?: IconDefinition;
15+
intent?: Intent;
16+
icon?: IconName;
1417
href?: string;
1518
isLoading?: boolean;
1619
loadingOnly?: boolean;
@@ -32,9 +35,7 @@ const Button: FC<QuartzButtonProps> = ({
3235
const component = (
3336
<RebassButton variant={intent} disabled={disabled || isLoading} {...test}>
3437
{icon && (!loadingOnly || !isLoading) && (
35-
<span>
36-
<FontAwesomeIcon icon={icon} size="sm" />
37-
</span>
38+
<GetIcon icon={icon} size="md" color={buttonIntentToColor(intent)} />
3839
)}
3940
{(!loadingOnly || !isLoading) && children}
4041
{isLoading && (
@@ -66,3 +67,16 @@ const Button: FC<QuartzButtonProps> = ({
6667
};
6768

6869
export default Button;
70+
71+
const intentToColor: { [intent in Intent]?: Color } = {
72+
primary: 'white',
73+
alert: 'labels.red',
74+
/* [others]: 'primary' */
75+
}
76+
77+
const buttonIntentToColor = (intent: Intent): Color => {
78+
const getColor = R.propOr(intent, 'primary');
79+
80+
return getColor(intentToColor);
81+
}
82+

src/components/callout/index.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { FC } from 'react';
22
import { Box, Flex, FlexProps, Text } from 'rebass';
33
import styles from './callout.styles';
4-
import icons from '../../sources/icons';
4+
import { Color } from '../../theme/types';
5+
import { GetIcon, IconName } from '../icon';
56

67
export enum CalloutTypes {
78
valid = 'valid',
@@ -10,6 +11,12 @@ export enum CalloutTypes {
1011
neutral = 'neutral',
1112
}
1213

14+
const calloutColors: Record<CalloutTypes, Color> = {
15+
valid: 'primary',
16+
error: 'labels.red',
17+
warning: 'labels.orange',
18+
neutral: 'black',
19+
};
1320
export interface ICalloutProps extends Omit<FlexProps, 'content' | 'css'> {
1421
type: CalloutTypes;
1522
content: string | React.ReactNode;
@@ -34,7 +41,7 @@ const Callout: FC<ICalloutProps> = ({
3441
maxWidth={cta ? '80%' : '100%'}
3542
>
3643
<Box mt="-2px" mb="-3px" mr="8px">
37-
{icons.info_block}
44+
<GetIcon color={calloutColors[type]} icon={IconName.info_block} />
3845
</Box>
3946
<Box as="pre">
4047
<Text

src/components/code-input/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import 'codemirror/theme/yeti.css';
1515
import Label, { LabelProps } from '../label';
1616
import Labeling from '../typography/labeling';
1717
import Tooltip from '../tooltip';
18-
import icons from '../../sources/icons';
1918
import { Intents } from '../intents';
2019
import InputInfo from '../input-info';
20+
import { GetIcon, IconName } from '../icon';
2121

2222
export interface InputProps {
2323
label?: string;
@@ -63,7 +63,7 @@ const CodeInput: FC<InputProps> = forwardRef(
6363
{tooltipInfo && (
6464
<Tooltip mainText={tooltipInfo}>
6565
<Box mt="-6px" mb="-3px">
66-
{icons.info_block}
66+
<GetIcon icon={IconName.info_block} />
6767
</Box>
6868
</Tooltip>
6969
)}

src/components/code/index.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Box, FlexProps, Flex } from 'rebass';
33
import SyntaxHighlighter from 'react-syntax-highlighter';
44
import { useTheme } from 'emotion-theming';
55
import Button from '../button';
6-
import { ITheme } from '../../theme/types';
76
import ExpandViewer from '../expand-viewer';
87

98
import styles, {
@@ -12,10 +11,10 @@ import styles, {
1211
lineNumberStyles,
1312
codeHeaderStyles,
1413
} from './code.styles';
15-
import icons from '../../sources/icons';
1614
import Value from '../typography/value';
1715
import { copyToClipboard, saveToFile } from '../../utils';
1816
import { PopupProps } from '../popup';
17+
import { GetIcon, IconName } from '../icon';
1918

2019
const CONTENT_UPPER_BOUND = 12;
2120

@@ -123,7 +122,7 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
123122
maxHeightOfCode,
124123
...props
125124
}) => {
126-
const theme = useTheme<ITheme>();
125+
const theme = useTheme();
127126

128127
return (
129128
<Flex width="100%" sx={styles} height="100%">
@@ -184,7 +183,7 @@ const DownloadButton: FC<
184183
return (
185184
<Box>
186185
<Button intent="ghost" sx={buttonsStyles} onClick={download}>
187-
{icons.download}
186+
<GetIcon icon={IconName.download} />
188187
<Value ml="5px" mt="1px">
189188
download
190189
</Value>
@@ -221,7 +220,7 @@ const CopyButton: FC<Pick<CodeProps, 'copyCallback' | 'content'>> = ({
221220
onClick={handleCopyClicked}
222221
disabled={copied}
223222
>
224-
{icons.copy}
223+
<GetIcon icon={IconName.copy} />
225224
<Value ml="5px" mt="1px">
226225
{copied ? 'copied' : 'copy'}
227226
</Value>

src/components/collapse/index.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Box, BoxProps, Flex } from 'rebass';
22
import React, { FC, memo, useEffect, useRef, useState } from 'react';
33

44
import Labeling from '../typography/labeling';
5-
import icons from '../../sources/icons';
65
import styles, { contentStyles, containerStyles } from './collapse.styles';
6+
import { GetIcon, IconName } from '../icon';
77

88
export interface CollapseProps extends Omit<BoxProps, 'css' | 'title'> {
99
title: React.ReactNode;
@@ -52,7 +52,12 @@ const Collapse: FC<CollapseProps> = ({
5252
<Box sx={containerStyles} {...props}>
5353
<Flex sx={styles(isOpen)} onClick={() => setOpen((state) => !state)}>
5454
<Flex>
55-
<Box>{isOpen ? icons.arrow_up : icons.arrow_down}</Box>
55+
<Box>
56+
<GetIcon
57+
color="primary"
58+
icon={isOpen ? IconName.arrow_up : IconName.arrow_down}
59+
/>
60+
</Box>
5661
{title}
5762
</Flex>
5863
{!!secondaryContent && <Labeling>{secondaryContent}</Labeling>}

src/components/compact-button/compact-button.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { FC, memo, CSSProperties } from 'react';
22
import { Button, ButtonProps, Flex, Box } from 'rebass';
3-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4-
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
3+
import { GetIcon, IconName } from '../icon';
54

65
import styles from './styles';
76

@@ -11,7 +10,7 @@ type LinkRelatedProps = Pick<Props, 'href' | 'newTab'>;
1110
export interface Props extends Omit<ButtonProps, 'css'> {
1211
newTab?: boolean;
1312
isActive?: boolean;
14-
icon?: IconDefinition;
13+
icon?: IconName;
1514
indicator?: Indicator;
1615
mode?: 'default' | 'highlight';
1716
}
@@ -56,7 +55,7 @@ const CompactButton: FC<Props> = ({
5655
sx={styles.flex}
5756
flexDirection={flexDirections[indicator ?? 'horizontal']}
5857
>
59-
{!!icon && <FontAwesomeIcon icon={icon} size="xs" />}
58+
{!!icon && <GetIcon icon={icon} size="xs" />}
6059
{indicator && !icon && <span data-active={isActive} />}
6160

6261
<Box>{children}</Box>

src/components/compact-button/index.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { Story, Meta } from '@storybook/react/types-6-0';
3-
import { faPlus } from '@fortawesome/free-solid-svg-icons';
43

54
import CompactButton, { CompactButtonProps } from '.';
5+
import { GetIcon, IconName } from '../icon';
66

77
export default {
88
title: 'Quartz/CompactButton',
@@ -44,10 +44,10 @@ CompactButtonTemplate.argTypes = {
4444
icon: {
4545
control: {
4646
type: 'select',
47-
options: [undefined, faPlus],
47+
options: [undefined, <GetIcon icon={IconName.plus} />],
4848
},
4949
type: {
50-
summary: 'Take icons from @fortawesome/free-solid-svg-icons',
50+
summary: 'Put icon component from IconName',
5151
},
5252
},
5353
};

src/components/datepicker/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'react-datepicker/dist/react-datepicker.min.css';
88
import styles from './datepicker.styles';
99
import Labeling from '../typography/labeling';
1010
import Value from '../typography/value';
11-
import ArrowsIcon from '../icons/arrows.icon';
11+
import { GetIcon, IconName } from '../icon';
1212

1313
export interface DatePickerProps {
1414
selectProps: SelectProps;
@@ -51,7 +51,7 @@ const DatePicker: FC<DatePickerProps & ReactDatePickerProps> = ({
5151
>
5252
{selectProps.value}
5353
</Value>
54-
<ArrowsIcon />
54+
<GetIcon icon={IconName.arrow_up_down} size='sm' mt="4px"/>
5555
</Flex>
5656
<Box alignSelf={datePickerAlign === 'right' ? 'flex-end' : 'flex-start'}>
5757
<ReactDatePicker

src/components/dropdown/dropdown.stories.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Box } from 'rebass';
55
import { Story, Meta } from '@storybook/react/types-6-0';
66

77
import Dropdown, { DropdownProps } from './index';
8+
import { IconName } from '../icon';
89

910
export default {
1011
title: 'Quartz/Dropdown',
@@ -32,7 +33,7 @@ Default.args = {
3233
},
3334
{
3435
value: 'Create New Project',
35-
icon: 'plus',
36+
icon: IconName.plus,
3637
metadata: {},
3738
onClick: action('onClick'),
3839
},

src/components/dropdown/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
21
import React, { FC, useRef } from 'react';
32

43
// Components
@@ -8,6 +7,7 @@ import List, { ListProps } from '../list/container';
87
import useOnClickOutside from '../../utils/useClickOutside';
98
// Types
109
import { DropdownItem } from './types';
10+
import { GetIcon } from '../icon';
1111

1212
export interface DropdownProps extends Omit<ListProps, 'css'> {
1313
items: DropdownItem[];
@@ -39,7 +39,7 @@ const Dropdown: FC<DropdownProps> = ({
3939
key={id || value}
4040
onClick={() => onClick(item)}
4141
>
42-
{icon && <FontAwesomeIcon icon={icon} />}
42+
{icon && <GetIcon icon={icon} size="sm" />}
4343
{value}
4444
</ListItem>
4545
);

0 commit comments

Comments
 (0)