mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
migrated embed
This commit is contained in:
98 files changed
+1979
-1376
No files matched your search
@@ -0,0 +1,51 @@
|
||||
.Root {
|
||||
--switch-thumb-size: var(--space-4);
|
||||
--switch-inset: var(--space-2);
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
box-sizing: border-box;
|
||||
width: calc(var(--switch-thumb-size) * 2.25 + 2 * var(--switch-inset));
|
||||
margin: 0;
|
||||
padding: var(--switch-inset);
|
||||
|
||||
border: none;
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--gray-a5);
|
||||
|
||||
cursor: pointer;
|
||||
transition: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
background-color: var(--accent-8);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 var(--space-1) var(--accent-6);
|
||||
}
|
||||
|
||||
&[data-disabled] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.Thumb {
|
||||
display: block;
|
||||
|
||||
width: var(--switch-thumb-size);
|
||||
height: var(--switch-thumb-size);
|
||||
|
||||
border-radius: var(--radius-max);
|
||||
background-color: var(--white-a12);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
transform: translateX(calc(var(--switch-thumb-size) * 1.25));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Switch as _Switch } from "radix-ui";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const _ = composeRadixComponents(_Switch, styles);
|
||||
|
||||
export interface SwitchProps {
|
||||
checked: boolean;
|
||||
onCheckedChange(checked: boolean): void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function Switch({ checked, onCheckedChange, disabled }: SwitchProps) {
|
||||
return (
|
||||
<_.Root
|
||||
checked={checked}
|
||||
onCheckedChange={onCheckedChange}
|
||||
disabled={disabled}
|
||||
>
|
||||
<_.Thumb />
|
||||
</_.Root>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user