-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7afbc11
commit 1dbeb7e
Showing
16 changed files
with
410 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Link as MuiLink, makeStyles, Theme } from '@material-ui/core'; | ||
import React, { Children, cloneElement, ReactElement, FC } from 'react'; | ||
|
||
import { ReactIconsConsumer } from './context'; | ||
import { SocialIconLinkProps, IconProps, ClassesOverride } from './types'; | ||
import { keyFor } from './utils'; | ||
|
||
export const ICON_DEFAULT_SIZE = 33; | ||
|
||
const useStyles = makeStyles<Theme, SocialIconLinkProps>({ | ||
root: ({ size = ICON_DEFAULT_SIZE, height = size, width = size }) => ({ | ||
width, | ||
height, | ||
display: 'inline-block', | ||
position: 'relative', | ||
overflow: 'hidden', | ||
verticalAlign: 'middle', | ||
}), | ||
}); | ||
|
||
export type LinkClassesOverrides = ClassesOverride<typeof useStyles>; | ||
|
||
interface Props extends SocialIconLinkProps { | ||
classes?: ClassesOverride<typeof useStyles>; | ||
} | ||
|
||
export const Link: FC<Props> = (props) => { | ||
const { href, network, classes: classesOverride, children, ...rest } = props; | ||
const classes = useStyles(props); | ||
|
||
const networkKey = (network || (href && keyFor(href)))?.toLowerCase(); | ||
|
||
return ( | ||
<ReactIconsConsumer> | ||
{(icons) => { | ||
const icon = (networkKey && icons[networkKey]) || icons.default; | ||
|
||
return ( | ||
<MuiLink href={href} className={classes.root} {...rest}> | ||
{Children.map(children, (child: ReactElement<IconProps>) => | ||
cloneElement(child, icon), | ||
)} | ||
</MuiLink> | ||
); | ||
}} | ||
</ReactIconsConsumer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { Icon, IconClassesOverrides } from './Icon'; | ||
import { Link, LinkClassesOverrides } from './Link'; | ||
import { SocialIconProps } from './types'; | ||
|
||
interface Props extends SocialIconProps { | ||
classes?: LinkClassesOverrides & IconClassesOverrides; | ||
} | ||
|
||
export const SocialIcon: FC<Props> = (props) => { | ||
return ( | ||
<Link {...props}> | ||
<Icon {...props} /> | ||
</Link> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,58 @@ | ||
import React, { CSSProperties, FC } from 'react'; | ||
import { makeStyles, Theme } from '@material-ui/core'; | ||
import React, { FC } from 'react'; | ||
import { ClassesOverride, IconProps } from './types'; | ||
|
||
import { socialSvgContent } from './styles'; | ||
import { Color, Icon as IconType } from './types'; | ||
const useStyles = makeStyles<Theme, Partial<IconProps>>((theme) => { | ||
const { shape } = theme; | ||
const variants = { | ||
rounded: shape.borderRadius, | ||
square: '0px', | ||
circle: '50%', | ||
}; | ||
|
||
interface StyleProps { | ||
fgColor: Color; | ||
} | ||
|
||
const getStyle = ({ fgColor }: StyleProps): CSSProperties => ({ | ||
...socialSvgContent, | ||
fill: fgColor || 'transparent', | ||
return { | ||
svg: ({ variant, radius }) => ({ | ||
borderRadius: radius || (variant && variants[variant]) || variants.circle, | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
fillRule: 'evenodd', | ||
}), | ||
background: { | ||
fill: 'transparent', | ||
}, | ||
mask: ({ color, bgColor = color }) => ({ | ||
fill: bgColor, | ||
}), | ||
icon: ({ fgColor }) => ({ | ||
fill: fgColor || 'transparent', | ||
}), | ||
}; | ||
}); | ||
|
||
interface Props extends StyleProps { | ||
icon: IconType['icon']; | ||
export type IconClassesOverrides = ClassesOverride<typeof useStyles>; | ||
|
||
interface Props extends Partial<IconProps> { | ||
classes?: IconClassesOverrides; | ||
} | ||
|
||
export const Icon: FC<Props> = ({ fgColor, icon, ...props }) => ( | ||
<g {...props} style={getStyle({ fgColor })}> | ||
<path d={icon} /> | ||
</g> | ||
); | ||
export const Icon: FC<Props> = (props) => { | ||
const classes = useStyles(props); | ||
const { icon, mask } = props; | ||
|
||
return ( | ||
<svg className={classes.svg} viewBox="0 0 64 64"> | ||
<g className={classes.background}> | ||
<circle cx="32" cy="32" r="31" /> | ||
</g> | ||
<g className={classes.icon}> | ||
<path d={icon} /> | ||
</g> | ||
<g className={classes.mask}> | ||
<path d={mask} /> | ||
</g> | ||
</svg> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from './context'; | ||
export * from './defaultIcons'; | ||
export * from './utils'; | ||
export * from './social-icon'; | ||
export * from './Icon'; | ||
export * from './Link'; | ||
export * from './SocialIcon'; | ||
export * from './types'; | ||
export * from './utils'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.