我为此感到吃力,所以我要把它放在这里,以防其他人需要它:
Button.js
import styles from './Button.styles'
function Button(props) {
return (
<button css={styles.button(props)} {...props}>
{props.label}
</button>
)
}
Button.styles.js
export default {
button: (props) => (theme) => {
const { colors } = theme
return {
color: colors.pureWhite,
backgroundColor:
(props.primary && colors.primaryBlue) ||
(props.critical && colors.red)
}
}
}