Skip to content

Commit

Permalink
feat: export server style sheet (#27)
Browse files Browse the repository at this point in the history
* feat: export ServerStyleSheet for next.js

* feat: allow specifying width and height for icons
  • Loading branch information
wahidrahim committed Dec 22, 2021
1 parent c7c2163 commit dd90621
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/Icon/Icon.tsx
Expand Up @@ -7,9 +7,14 @@ export type IconVariant = 'basic' | 'circle';

export type IconProps = {
variant: IconVariant;
margin?: string;
icon: ComponentType;
size: string;
size:
| string
| {
width: string;
height: string;
};
margin?: string;
color?: string;
bg?: string;
scale?: number;
Expand All @@ -22,8 +27,8 @@ const Component = styled.span<Omit<IconProps, 'icon'>>(
display: 'inline-block',
margin: getMargin({ theme, margin }),
padding: 0,
width: size,
height: size,
width: typeof size === 'string' ? size : size.width,
height: typeof size === 'string' ? size : size.height,
...(bg && theme.COLOR[bg] ? { backgroundColor: theme.COLOR[bg] } : {}),
svg: {
display: 'block',
Expand All @@ -35,9 +40,7 @@ const Component = styled.span<Omit<IconProps, 'icon'>>(
'svg > *': {
...theme.ICON[variant]['svg > *'],
...(color || theme.ICON[variant].fill
? {
fill: color ? theme.COLOR[color] : theme.ICON[variant].fill,
}
? { fill: color ? theme.COLOR[color] : theme.ICON[variant].fill }
: {}),
},
}),
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Expand Up @@ -4,6 +4,7 @@ export {
createGlobalStyle,
GlobalStyleComponent,
ThemeProvider,
ServerStyleSheet,
} from 'styled-components';

// UTILS
Expand Down

0 comments on commit dd90621

Please sign in to comment.