revite/src/components/ui/Button.tsx

96 lines
1.9 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;
2021-07-05 17:49:57 -04:00
readonly plain?: boolean;
2021-07-05 06:25:20 -04:00
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;
2021-07-05 17:49:57 -04:00
display: flex;
height: 38px;
min-width: 96px;
align-items: center;
justify-content: center;
padding: 2px 16px;
font-size: .875rem;
2021-07-05 06:25:20 -04:00
font-family: inherit;
2021-07-05 17:49:57 -04:00
font-weight: 500;
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 17:49:57 -04:00
border-radius: 4px;
2021-07-05 06:25:20 -04:00
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 17:49:57 -04:00
${(props) =>
props.plain &&
css`
background: transparent !important;
&:hover {
text-decoration: underline;
}
&:disabled {
opacity: .5;
}
&:active {
background: var(--secondary-background);
}
`}
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
`;