Skip to content

Commit cdf1717

Browse files
authored
feat: Icon updates (#559)
1 parent dcb617c commit cdf1717

File tree

5 files changed

+84
-13
lines changed

5 files changed

+84
-13
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import createIcon from './createIcon'
2+
3+
export default createIcon(({ size, color, secondaryColor }) => (
4+
<svg
5+
width={size}
6+
height={size}
7+
viewBox="0 0 16 16"
8+
fill="none"
9+
xmlns="http://www.w3.org/2000/svg"
10+
>
11+
<path
12+
d="m6.25 3v6 1 2.5h3.5v-2.5-1-6z"
13+
fill={secondaryColor || 'transparent'}
14+
/>
15+
<path
16+
d="m11.313721 0h-6.627441l-4.68628 4.686279v6.627441l4.686279 4.686279h6.627441l4.686279-4.686279v-6.627441zm-2.563721 11.5h-1.5v-1.500061h1.5zm0-6.75v4.25h-1.5v-5h1.5z"
17+
fill={color}
18+
/>
19+
</svg>
20+
))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useTheme } from 'styled-components'
2+
3+
import createIcon from './createIcon'
4+
5+
export default createIcon(({ size, color, secondaryColor }) => {
6+
const theme = useTheme()
7+
8+
return (
9+
<svg
10+
width={size}
11+
fill="none"
12+
viewBox="0 0 16 16"
13+
xmlns="http://www.w3.org/2000/svg"
14+
>
15+
<path
16+
d="m8 11.2c-.6 0-1-.4-1-1v-2c-.6-.4-1-1-1-1.7 0-1.1.9-2 2-2s2 .9 2 2c0 .7-.4 1.4-1 1.7v2c0 .6-.4 1-1 1z"
17+
fill={secondaryColor || theme.colors['fill-one']}
18+
/>
19+
<path
20+
d="m15 7.3c0 4-3 7.8-7 8.7-4-.9-7-4.7-7-8.7v-4.4l7-2.9 7 2.9zm-6.2.8c.6-.3 1-.9 1-1.6 0-1-.8-1.8-1.8-1.8s-1.8.8-1.8 1.8c0 .7.4 1.3 1 1.6v2.2c0 .4.4.7.8.7s.8-.3.8-.8z"
21+
fill={color}
22+
/>
23+
</svg>
24+
)
25+
})

src/components/icons/createIcon.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import {
44
type IconProps as HonorableIconProps,
55
useTheme,
66
} from 'honorable'
7-
import PropTypes from 'prop-types'
87

98
type IconBaseProps = {
109
size?: number | string
1110
color?: string
1211
fullColor?: boolean
12+
secondaryColor?: string
1313
}
1414

1515
export type IconProps = HonorableIconProps & IconBaseProps
1616

17-
const propTypes = {
18-
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
19-
color: PropTypes.string,
20-
fullColor: PropTypes.bool,
21-
}
22-
2317
function createIcon(render: (props: IconBaseProps) => ReactNode) {
2418
function IconRef(
25-
{ size = 16, color = 'currentColor', fullColor, ...props }: IconProps,
19+
{
20+
size = 16,
21+
color = 'currentColor',
22+
fullColor,
23+
secondaryColor,
24+
...props
25+
}: IconProps,
2626
ref: Ref<any>
2727
) {
2828
const theme = useTheme()
@@ -35,15 +35,18 @@ function createIcon(render: (props: IconBaseProps) => ReactNode) {
3535
{...{ '& *': { transition: 'stroke 150ms linear, fill 150ms linear' } }}
3636
{...props}
3737
>
38-
{render({ size, color: workingColor, fullColor })}
38+
{render({
39+
size,
40+
color: workingColor,
41+
secondaryColor,
42+
fullColor,
43+
})}
3944
</HonorableIcon>
4045
)
4146
}
4247

4348
const ForwardedIcon = forwardRef(IconRef)
4449

45-
ForwardedIcon.propTypes = propTypes
46-
4750
return ForwardedIcon
4851
}
4952

src/icons.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { default as ArrowTopRightIcon } from './components/icons/ArrowTopRightIc
1010
export { default as AwsLogoIcon } from './components/icons/AwsLogoIcon'
1111
export { default as AzureLogoIcon } from './components/icons/AzureLogoIcon'
1212
export { default as BellIcon } from './components/icons/BellIcon'
13+
export { default as BlockedIcon } from './components/icons/BlockedIcon'
1314
export { default as BookIcon } from './components/icons/BookIcon'
1415
export { default as BotIcon } from './components/icons/BotIcon'
1516
export { default as BriefcaseIcon } from './components/icons/BriefcaseIcon'
@@ -141,6 +142,7 @@ export { default as SearchIcon } from './components/icons/SearchIcon'
141142
export { default as SendMessageIcon } from './components/icons/SendMessageIcon'
142143
export { default as ServersIcon } from './components/icons/ServersIcon'
143144
export { default as ShieldOutlineIcon } from './components/icons/ShieldOutlineIcon'
145+
export { default as ShieldLockIcon } from './components/icons/ShieldLockIcon'
144146
export { default as ShipIcon } from './components/icons/ShipIcon'
145147
export { default as SirenIcon } from './components/icons/SirenIcon'
146148
export { default as SlackLogoIcon } from './components/icons/SlackLogoIcon'

src/stories/Icons.stories.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ export default {
2525
type: 'select',
2626
},
2727
},
28+
secondaryColor: {
29+
options: [
30+
'',
31+
'fill-zero',
32+
'fill-one',
33+
'fill-two',
34+
'fill-three',
35+
'black',
36+
'white',
37+
'transparent',
38+
],
39+
control: {
40+
type: 'select',
41+
},
42+
},
2843
},
2944
}
3045

@@ -53,13 +68,19 @@ const AppIcon = styled.div<{ $backgroundColor: string }>(
5368
})
5469
)
5570

56-
function Template({ backgroundColor, ...args }: any) {
71+
function Template({ backgroundColor, color, secondaryColor, ...args }: any) {
5772
const theme = useTheme()
5873
const bgColor =
5974
(typeof (theme.colors as any)[backgroundColor] === 'string' &&
6075
(theme.colors as any)[backgroundColor]) ||
6176
backgroundColor
6277

78+
// @ts-ignore
79+
color = theme.colors[color] ?? (color || undefined)
80+
secondaryColor =
81+
// @ts-ignore
82+
theme.colors[secondaryColor as string] ?? (secondaryColor || undefined)
83+
6384
return (
6485
<div
6586
style={{
@@ -74,7 +95,7 @@ function Template({ backgroundColor, ...args }: any) {
7495
$backgroundColor={bgColor}
7596
>
7697
<div style={{ justifySelf: 'flex-end' }}>
77-
{createElement(icon as any, { ...args })}
98+
{createElement(icon as any, { color, secondaryColor, ...args })}
7899
</div>
79100
<span
80101
dangerouslySetInnerHTML={{

0 commit comments

Comments
 (0)