-
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.
feat(tag): updates style to be color pill
Updates the styles to be a color pill closes #183
- Loading branch information
Showing
11 changed files
with
115 additions
and
36 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,31 +1,61 @@ | ||
import PropTypes from 'prop-types'; | ||
import Link from 'next/link'; | ||
import { rem } from 'polished'; | ||
import { css } from '@emotion/react'; | ||
import { rem, darken, lighten, readableColor } from 'polished'; | ||
import { css, useTheme } from '@emotion/react'; | ||
|
||
export function Tag({ tag }) { | ||
const linkSlug = tag.toLowerCase().replace(/ /g, '-'); | ||
const linkCss = css` | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: ${rem(20)}; | ||
padding: ${rem(4)} ${rem(8)}; | ||
border-radius: ${rem(12)}; | ||
font-size: ${rem(12)}; | ||
line-height: 1; | ||
text-decoration: none; | ||
transition: all 0.2s ease-in-out; | ||
&:hover { | ||
text-decoration: none; | ||
} | ||
`; | ||
|
||
export function Tag({ label, color }) { | ||
const theme = useTheme(); | ||
const linkSlug = label.toLowerCase().replace(/ /g, '-'); | ||
|
||
return ( | ||
<Link href={`/tags/${linkSlug}`} passHref> | ||
<a | ||
css={css` | ||
font-size: ${rem(12)}; | ||
line-height: 1.2; | ||
font-style: italic; | ||
${linkCss}; | ||
color: ${color ? readableColor(color) : theme.text.color.dark}; | ||
background-color: ${color || theme.colors.gray}; | ||
&:hover { | ||
color: ${color ? readableColor(color) : theme.text.color.dark}; | ||
background-color: ${lighten(0.1, color || theme.colors.gray)}; | ||
} | ||
&:active { | ||
background-color: ${darken(0.1, color || theme.colors.gray)}; | ||
} | ||
`} | ||
href={`/tags/${linkSlug}`} | ||
> | ||
{tag} | ||
{label} | ||
</a> | ||
</Link> | ||
); | ||
} | ||
|
||
Tag.propTypes = { | ||
tag: PropTypes.string.isRequired, | ||
label: PropTypes.string.isRequired, | ||
color: PropTypes.string, | ||
}; | ||
|
||
Tag.defaultProps = {}; | ||
Tag.defaultProps = { | ||
color: null, | ||
}; | ||
|
||
export default Tag; |
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
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
3014be1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://www.angusp.com as production
🚀 Deployed on https://6383de1aacf33a53b3a9c3bf--serene-ride-008670.netlify.app