Store appearance in k/v

This commit is contained in:
Gregory Schier
2023-03-16 11:01:30 -07:00
parent 0949de66bf
commit eee98f32b2
5 changed files with 40 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
import * as T from '@radix-ui/react-tabs';
import classnames from 'classnames';
import type { ReactNode } from 'react';
import { useState } from 'react';
import { Button } from '../Button';
import type { DropdownMenuRadioItem, DropdownMenuRadioProps } from '../Dropdown';
import { DropdownMenuRadio, DropdownMenuTrigger } from '../Dropdown';
@@ -13,6 +12,8 @@ import './Tabs.css';
interface Props {
defaultValue?: string;
label: string;
onChangeValue: (value: string) => void;
value: string;
tabs: {
value: string;
label: string;
@@ -27,12 +28,20 @@ interface Props {
children: ReactNode;
}
export function Tabs({ defaultValue, label, children, tabs, className, tabListClassName }: Props) {
const [value, setValue] = useState(defaultValue);
export function Tabs({
value,
onChangeValue,
defaultValue,
label,
children,
tabs,
className,
tabListClassName,
}: Props) {
return (
<T.Root
defaultValue={defaultValue}
onValueChange={setValue}
onValueChange={onChangeValue}
className={classnames(className, 'h-full grid grid-rows-[auto_minmax(0,1fr)] grid-cols-1')}
>
<T.List