mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
Initial commit
This commit is contained in:
10
src/components/ui/Banner.tsx
Normal file
10
src/components/ui/Banner.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
export const Banner = styled.div`
|
||||
padding: 8px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
|
||||
color: var(--accent);
|
||||
background: var(--primary-background);
|
||||
`;
|
||||
65
src/components/ui/Button.tsx
Normal file
65
src/components/ui/Button.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import styled, { css } from "styled-components";
|
||||
|
||||
interface Props {
|
||||
readonly contrast?: boolean;
|
||||
readonly error?: boolean;
|
||||
};
|
||||
|
||||
export const Button = styled.button<Props>`
|
||||
z-index: 1;
|
||||
padding: 8px;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
|
||||
transition: 0.2s ease opacity;
|
||||
transition: 0.2s ease background-color;
|
||||
|
||||
background: var(--primary-background);
|
||||
color: var(--foreground);
|
||||
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
background: var(--secondary-header);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: var(--primary-background);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: var(--secondary-background);
|
||||
}
|
||||
|
||||
${props => props.contrast && css`
|
||||
padding: 4px 8px;
|
||||
background: var(--secondary-header);
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-header);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: var(--secondary-header);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: var(--secondary-background);
|
||||
}
|
||||
`}
|
||||
|
||||
${props => props.error && css`
|
||||
color: white;
|
||||
background: var(--error);
|
||||
|
||||
&:hover {
|
||||
filter: brightness(1.2)
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: var(--error);
|
||||
}
|
||||
`}
|
||||
`;
|
||||
93
src/components/ui/Checkbox.tsx
Normal file
93
src/components/ui/Checkbox.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
import { Check } from '@styled-icons/feather';
|
||||
import styled, { css } from 'styled-components';
|
||||
import { VNode } from 'preact';
|
||||
|
||||
const CheckboxBase = styled.label`
|
||||
gap: 4px;
|
||||
z-index: 1;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
border-radius: 4px;
|
||||
align-items: center;
|
||||
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
user-select: none;
|
||||
|
||||
transition: .2s ease all;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const CheckboxContent = styled.span`
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
flex-direction: column;
|
||||
`;
|
||||
|
||||
const CheckboxDescription = styled.span`
|
||||
font-size: 0.8em;
|
||||
font-weight: 400;
|
||||
color: var(--secondary-foreground);
|
||||
`;
|
||||
|
||||
const Checkmark = styled.div<{ checked: boolean }>`
|
||||
margin: 4px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: grid;
|
||||
border-radius: 4px;
|
||||
place-items: center;
|
||||
background: var(--secondary-background);
|
||||
|
||||
svg {
|
||||
color: var(--secondary-background);
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
${ props => props.checked && css`
|
||||
background: var(--accent);
|
||||
` }
|
||||
`;
|
||||
|
||||
interface Props {
|
||||
checked: boolean;
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
children: VNode | string;
|
||||
description?: VNode | string;
|
||||
onChange: (state: boolean) => void;
|
||||
}
|
||||
|
||||
export function Checkbox(props: Props) {
|
||||
return (
|
||||
<CheckboxBase disabled={props.disabled}>
|
||||
<CheckboxContent>
|
||||
<span>{ props.children }</span>
|
||||
{props.description && (
|
||||
<CheckboxDescription>
|
||||
{props.description}
|
||||
</CheckboxDescription>
|
||||
)}
|
||||
</CheckboxContent>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={props.checked}
|
||||
onChange={() =>
|
||||
!props.disabled && props.onChange(!props.checked)
|
||||
}
|
||||
/>
|
||||
<Checkmark checked={props.checked}>
|
||||
<Check size={20} />
|
||||
</Checkmark>
|
||||
</CheckboxBase>
|
||||
)
|
||||
}
|
||||
8
src/components/ui/ComboBox.tsx
Normal file
8
src/components/ui/ComboBox.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
export const ComboBox = styled.select`
|
||||
padding: 8px;
|
||||
border-radius: 2px;
|
||||
color: var(--secondary-foreground);
|
||||
background: var(--secondary-background);
|
||||
`;
|
||||
33
src/components/ui/InputBox.tsx
Normal file
33
src/components/ui/InputBox.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import styled, { css } from "styled-components";
|
||||
|
||||
interface Props {
|
||||
readonly contrast?: boolean;
|
||||
};
|
||||
|
||||
export const InputBox = styled.input<Props>`
|
||||
z-index: 1;
|
||||
padding: 8px 16px;
|
||||
border-radius: 6px;
|
||||
color: var(--foreground);
|
||||
border: 2px solid transparent;
|
||||
background: var(--primary-background);
|
||||
transition: 0.2s ease background-color;
|
||||
transition: border-color .2s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
background: var(--secondary-background);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border: 2px solid var(--accent);
|
||||
}
|
||||
|
||||
${ props => props.contrast && css`
|
||||
color: var(--secondary-foreground);
|
||||
background: var(--secondary-background);
|
||||
|
||||
&:hover {
|
||||
background: var(--hover);
|
||||
}
|
||||
` }
|
||||
`;
|
||||
Reference in New Issue
Block a user