-
-
Save amowu/e864673f39c0928efec2c6def51d8a02 to your computer and use it in GitHub Desktop.
Styled Components example
This file contains hidden or 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
import styled from "styled-components"; | |
import { | |
theme | |
} from "ui"; | |
const { color, font, radius, transition } = theme; | |
export const Button = styled.button` | |
background-color: ${color.ghost}; | |
border: none; | |
appearance: none; | |
user-select: none; | |
border-radius: ${radius}; | |
color: ${color.base} | |
cursor: pointer; | |
display: inline-block; | |
font-family: inherit; | |
font-size: ${font.base}; | |
font-weight: bold; | |
outline: none; | |
position: relative; | |
text-align: center; | |
text-transform: uppercase; | |
transition: | |
transorm ${transition}, | |
opacity ${transition}; | |
white-space: nowrap; | |
width: ${props => props.width ? props.width : "auto"}; | |
&:hover, | |
&:focus { | |
outline: none; | |
} | |
&:hover { | |
color: ${color.silver}; | |
opacity: 0.8; | |
border-bottom: 3px solid rgba(0,0,0,0.2); | |
} | |
&:active { | |
border-bottom: 1px solid rgba(0,0,0,0.2); | |
transform: translateY(2px); | |
opacity: 0.95; | |
} | |
${props => props.disabled && ` | |
background-color: ${color.ghost}; | |
opacity: ${0.4}; | |
pointer-events: none; | |
cursor: not-allowed; | |
`} | |
${props => props.primary && ` | |
background-color: ${color.primary}; | |
color: ${color.white}; | |
border-color: ${color.primary}; | |
&:hover, | |
&:active { | |
background-color: ${color.primary}; | |
color: ${color.white}; | |
} | |
`} | |
${props => props.secondary && ` | |
background-color: ${color.secondary}; | |
color: ${color.white}; | |
border-color: ${color.secondary}; | |
&:hover, | |
&:active { | |
background-color: ${color.secondary}; | |
color: ${color.white}; | |
} | |
`} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment