revite/src/components/ui/Button.tsx

70 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-06-18 07:05:01 -04:00
import styled, { css } from "styled-components";
interface Props {
readonly contrast?: boolean;
readonly error?: boolean;
2021-06-18 10:46:30 -04:00
}
2021-06-18 07:05:01 -04:00
2021-06-18 10:18:10 -04:00
export default styled.button<Props>`
2021-06-18 10:57:08 -04:00
z-index: 1;
padding: 8px;
font-size: 16px;
text-align: center;
2021-06-18 07:05:01 -04:00
2021-06-18 10:57:08 -04:00
transition: 0.2s ease opacity;
transition: 0.2s ease background-color;
2021-06-18 07:05:01 -04:00
2021-06-18 10:57:08 -04:00
background: var(--primary-background);
2021-06-18 07:05:01 -04:00
color: var(--foreground);
2021-06-18 10:57:08 -04:00
border-radius: 6px;
cursor: pointer;
2021-06-18 07:05:01 -04:00
border: none;
2021-06-18 10:57:08 -04:00
&:hover {
background: var(--secondary-header);
}
2021-06-18 07:05:01 -04:00
&:disabled {
background: var(--primary-background);
}
&:active {
background: var(--secondary-background);
}
2021-06-18 10:57:08 -04:00
${(props) =>
props.contrast &&
css`
padding: 4px 8px;
2021-06-18 07:05:01 -04:00
background: var(--secondary-header);
2021-06-18 10:57:08 -04:00
&:hover {
background: var(--primary-header);
}
2021-06-18 07:05:01 -04:00
2021-06-18 10:57:08 -04:00
&:disabled {
background: var(--secondary-header);
}
2021-06-18 07:05:01 -04:00
2021-06-18 10:57:08 -04:00
&:active {
background: var(--secondary-background);
}
`}
2021-06-18 07:05:01 -04:00
2021-06-18 10:57:08 -04:00
${(props) =>
props.error &&
css`
color: white;
2021-06-18 07:05:01 -04:00
background: var(--error);
2021-06-18 10:57:08 -04:00
&:hover {
filter: brightness(1.2);
}
&:disabled {
background: var(--error);
}
`}
2021-06-18 07:05:01 -04:00
`;