This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): ✨ created link card component
- Loading branch information
Showing
6 changed files
with
90 additions
and
19 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,51 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { useTheme } from 'emotion-theming'; | ||
import { ArrowRight } from 'react-feather'; | ||
import emoji from '../../utils/emoji'; | ||
import Link from '../Link'; | ||
import { shadowAround } from '../../styles'; | ||
import { decreaseIntensivity } from '../../utils/colors'; | ||
|
||
const BigLinkWrapper = styled.div` | ||
display: flex; | ||
cursor: pointer; | ||
width: 100%; | ||
padding: 16px; | ||
margin: 10px 0; | ||
border-radius: 4px; | ||
border: 1px solid transparent; | ||
align-items: center; | ||
transition: ${(props) => props.theme.transitions.hover}; | ||
&:hover { | ||
border: 1px solid ${(props) => props.theme.colors.primary}; | ||
} | ||
`; | ||
|
||
const LinkPath = styled.div` | ||
color: ${(props) => decreaseIntensivity(props.theme.colors.fontLight, 0.25)}; | ||
font-size: 9pt; | ||
padding-left: 16px; | ||
`; | ||
|
||
const Title = styled.div` | ||
flex: 1 0; | ||
padding: 0 14px; | ||
color: ${(props) => props.theme.colors.primary}; | ||
font-size: 12pt; | ||
font-weight: 500; | ||
`; | ||
|
||
export default ({ title, url }) => { | ||
const theme = useTheme(); | ||
const path = url.replace(/(https:\/\/)|(http:\/\/)/, ""); | ||
return ( | ||
<Link to={url}> | ||
<BigLinkWrapper css={shadowAround}> | ||
<ArrowRight color={theme.colors.primary} size={23} /> | ||
<Title>{emoji.emojify(title)}</Title> | ||
<LinkPath>{path}</LinkPath> | ||
</BigLinkWrapper> | ||
</Link> | ||
); | ||
}; |
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,19 @@ | ||
import colorfn from 'color'; | ||
|
||
export const increaseIntensivity = (color, factor) => { | ||
const clr = colorfn(color); | ||
const intensified = clr.isDark() ? clr.darken(factor) : clr.lighten(factor); | ||
return intensified.hex(); | ||
}; | ||
|
||
export const decreaseIntensivity = (color, factor) => { | ||
const clr = colorfn(color); | ||
const luminStd = 1 / clr.luminosity(); | ||
const fc = luminStd > 6 ? factor * 6 : factor * luminStd; | ||
const intensified = clr.isDark() ? clr.lighten(fc) : clr.darken(fc); | ||
return intensified.hex(); | ||
}; | ||
|
||
export const grayscaleCompatible = (color) => { | ||
return increaseIntensivity(colorfn(color).negate().grayscale().hex(), 0.7); | ||
}; |