revite/src/components/ui/Button.tsx

72 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 {
2021-07-05 06:25:20 -04:00
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-07-05 06:25:20 -04:00
z-index: 1;
padding: 8px;
font-size: 16px;
text-align: center;
font-family: inherit;
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
transition: 0.2s ease opacity;
transition: 0.2s ease background-color;
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
background: var(--primary-background);
color: var(--foreground);
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
border-radius: 6px;
cursor: pointer;
border: none;
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:hover {
background: var(--secondary-header);
}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:disabled {
background: var(--primary-background);
}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:active {
background: var(--secondary-background);
}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
${(props) =>
props.contrast &&
css`
padding: 4px 8px;
background: var(--secondary-header);
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:hover {
background: var(--primary-header);
}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:disabled {
background: var(--secondary-header);
}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
&:active {
background: var(--secondary-background);
}
`}
2021-06-18 07:05:01 -04:00
2021-07-05 06:25:20 -04:00
${(props) =>
props.error &&
css`
color: white;
background: var(--error);
2021-06-18 10:57:08 -04:00
2021-07-05 06:25:20 -04:00
&:hover {
filter: brightness(1.2);
background: var(--error);
}
2021-06-18 10:57:08 -04:00
2021-07-05 06:25:20 -04:00
&:disabled {
background: var(--error);
}
`}
2021-06-18 07:05:01 -04:00
`;