-
Notifications
You must be signed in to change notification settings - Fork 751
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
1b34b28
commit 78fc2d7
Showing
11 changed files
with
89 additions
and
178 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,32 @@ | ||
import styled, { DefaultTheme } from "styled-components"; | ||
import { TagProps, TagThemeVariant, variants } from "./types"; | ||
import getColor from "../../util/getColor"; | ||
import { TagProps } from "./types"; | ||
|
||
interface ThemedProps extends TagProps { | ||
theme: DefaultTheme; | ||
} | ||
|
||
const InnerIcon = styled.span` | ||
align-items: center; | ||
display: inline-flex; | ||
`; | ||
|
||
export const StartIcon = styled(InnerIcon)` | ||
margin-right: 0.5em; | ||
`; | ||
|
||
export const EndIcon = styled(InnerIcon)` | ||
margin-left: 0.5em; | ||
`; | ||
|
||
const getTagVariantProp = (prop: keyof TagThemeVariant) => ({ theme, variant = variants.PURPLE }: ThemedProps) => { | ||
return theme.tag[variant][prop]; | ||
}; | ||
|
||
const getBackgroundColor = (props: ThemedProps) => { | ||
if (props.outline) { | ||
return "transparent"; | ||
} | ||
|
||
return getTagVariantProp("background")(props); | ||
}; | ||
|
||
const getColor = (props: ThemedProps) => { | ||
const { variant = variants.PURPLE, outline } = props; | ||
|
||
if (outline) { | ||
return props.theme.tag[variant].colorOutline; | ||
} | ||
|
||
return getTagVariantProp("color")(props); | ||
}; | ||
|
||
const getBorder = (props: ThemedProps) => { | ||
const { variant = variants.PURPLE, theme, outline } = props; | ||
|
||
if (outline) { | ||
return `2px solid ${theme.tag[variant].borderColorOutline}`; | ||
} | ||
|
||
return "none"; | ||
}; | ||
const getThemeTextColor = ({ outline, variant = "primary", theme }: ThemedProps) => | ||
outline ? getColor(variant, theme) : "#ffffff"; | ||
|
||
export const StyledTag = styled.div<ThemedProps>` | ||
align-items: center; | ||
background-color: ${getBackgroundColor}; | ||
border: ${getBorder}; | ||
background-color: ${({ outline, theme, variant = "primary" }) => | ||
outline ? "transparent" : getColor(variant, theme)}; | ||
border: 2px solid ${({ variant = "primary", theme }) => getColor(variant, theme)}; | ||
border-radius: 16px; | ||
color: ${getColor}; | ||
color: ${getThemeTextColor}; | ||
display: inline-flex; | ||
font-size: 14px; | ||
font-weight: 400; | ||
height: 28px; | ||
line-height: 1.5; | ||
padding: 0 8px; | ||
white-space: nowrap; | ||
svg { | ||
fill: ${getColor}; | ||
fill: ${getThemeTextColor}; | ||
} | ||
`; | ||
|
||
export default null; |
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
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
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
Oops, something went wrong.