Add hover styles to button. Make input use shared variables for padding, border-radius

This commit is contained in:
Lindsey 2021-09-20 11:21:43 -04:00
parent 0e800a3a05
commit b29027dd42
4 changed files with 29 additions and 9 deletions

View File

@ -48,7 +48,7 @@ function App() {
<input type="text" name="testInput2" style={{ width: "100%" }} /> <input type="text" name="testInput2" style={{ width: "100%" }} />
<Spacer /> <Spacer />
<SpaceBetweenContainer> <SpaceBetweenContainer>
<Button variant="secondary" onClick={() => {}}> <Button variant="primary" onClick={() => {}}>
Hello World Hello World
</Button> </Button>
<Button variant="secondary" onClick={() => {}}> <Button variant="secondary" onClick={() => {}}>

View File

@ -23,4 +23,6 @@ export const typography = {
export const input = { export const input = {
padding: "2rem", padding: "2rem",
borderRadius: "12px",
fontSize: "1.6rem",
}; };

View File

@ -1,6 +1,7 @@
import React, { FC, ReactNode } from "react"; import React, { FC, ReactNode } from "react";
import styled from "styled-components"; import styled, { css } from "styled-components";
import CSS from "csstype"; import CSS from "csstype";
import { darken } from "polished";
import { color, typography } from "../shared/styles"; import { color, typography } from "../shared/styles";
@ -41,12 +42,29 @@ const StyledButton = styled.button<ButtonProps>`
transition: all 150ms ease-out; transition: all 150ms ease-out;
transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
color: ${(props) =>
props.variant === "primary" ? color.white : color.black};
background-color: ${(props) =>
props.variant === "primary" ? color.primary : color.secondary};
&:hover { &:hover {
transform: translateY(-2px); transform: translateY(-2px);
} }
${(props) =>
props.variant === "primary" &&
css`
color: ${color.white};
background-color: ${color.primary};
&:hover {
background-color: ${darken(0.05, color.primary)};
}
`}
${(props) =>
props.variant === "secondary" &&
css`
color: ${color.black};
background-color: ${color.secondary};
&:hover {
background-color: ${darken(0.1, color.secondary)};
}
`}
`; `;

View File

@ -45,12 +45,12 @@ const Input: FC<InputProps> = ({
export default Input; export default Input;
const StyledInput = styled.input<InputProps>` const StyledInput = styled.input<InputProps>`
border-radius: 12px; border-radius: ${input.borderRadius};
border: none; border: none;
padding: ${input.padding}; padding: ${input.padding};
width: 100%; width: 100%;
font-size: 1.6rem; font-size: ${input.fontSize};
font-family: ${typography.primary}; font-family: ${typography.primary};
font-weight: ${typography.weight.regular}; font-weight: ${typography.weight.regular};