import { Children } from "../../types/Preact"; import styled, { css } from "styled-components"; import { CircleFill } from "@styled-icons/bootstrap"; interface Props { children: Children; description?: Children; checked: boolean; disabled?: boolean; onSelect: () => void; } interface BaseProps { selected: boolean; } const RadioBase = styled.label` gap: 4px; z-index: 1; padding: 4px; display: flex; cursor: pointer; align-items: center; font-size: 1rem; font-weight: 600; user-select: none; border-radius: 4px; transition: 0.2s ease all; &:hover { background: var(--hover); } > input { display: none; } > div { margin: 4px; width: 24px; height: 24px; display: grid; border-radius: 50%; place-items: center; background: var(--foreground); svg { color: var(--foreground); stroke-width: 2; } } ${(props) => props.selected && css` color: white; cursor: default; background: var(--accent); > div { background: white; } > div svg { color: var(--accent); } &:hover { background: var(--accent); } `} `; const RadioDescription = styled.span` font-size: 0.8em; font-weight: 400; color: var(--secondary-foreground); ${(props) => props.selected && css` color: white; `} `; export default function Radio(props: Props) { return ( !props.disabled && props.onSelect && props.onSelect() } >
{props.children} {props.description && ( {props.description} )}
); }