📝 docs: add segmented controls component to example page

This commit is contained in:
Wahyu Kurniawan 2024-02-22 02:19:14 +07:00
parent aabda9b486
commit 7bb5f9831c
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33
2 changed files with 68 additions and 0 deletions

View File

@ -13,10 +13,14 @@ import {
renderTabs, renderTabs,
renderVerticalTabs, renderVerticalTabs,
} from './renders/tabs'; } from './renders/tabs';
import { SegmentedControls } from 'components/shared/SegmentedControls';
import { SEGMENTED_CONTROLS_OPTIONS } from './renders/segmentedControls';
const Page = () => { const Page = () => {
const [singleDate, setSingleDate] = useState<Value>(); const [singleDate, setSingleDate] = useState<Value>();
const [dateRange, setDateRange] = useState<Value>(); const [dateRange, setDateRange] = useState<Value>();
const [selectedSegmentedControl, setSelectedSegmentedControl] =
useState<string>('Test 1');
return ( return (
<div className="relative h-full min-h-full"> <div className="relative h-full min-h-full">
@ -112,6 +116,26 @@ const Page = () => {
<h1 className="text-2xl font-bold">Vertical Tabs</h1> <h1 className="text-2xl font-bold">Vertical Tabs</h1>
{renderVerticalTabs()} {renderVerticalTabs()}
</div> </div>
<div className="w-full h border border-gray-200 px-20 my-10" />
{/* Segmented Controls */}
<div className="flex flex-col gap-10 items-center justify-between">
<h1 className="text-2xl font-bold">Segmented Controls</h1>
<div className="flex flex-col gap-10">
<SegmentedControls
options={SEGMENTED_CONTROLS_OPTIONS}
value={selectedSegmentedControl}
onChange={setSelectedSegmentedControl}
/>
<SegmentedControls
size="sm"
options={SEGMENTED_CONTROLS_OPTIONS}
value={selectedSegmentedControl}
onChange={setSelectedSegmentedControl}
/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,44 @@
import React from 'react';
import { Badge } from 'components/shared/Badge';
import { SegmentedControlsOption } from 'components/shared/SegmentedControls';
export const SEGMENTED_CONTROLS_OPTIONS: SegmentedControlsOption[] = [
{ label: 'Test 1', value: 'Test 1' },
{
label: 'Test 2',
value: 'Test 2',
leftIcon: (
<Badge size="xs" variant="tertiary">
1
</Badge>
),
},
{
label: 'Test 3',
value: 'Test 3',
rightIcon: (
<Badge size="xs" variant="tertiary">
1
</Badge>
),
},
{
label: 'Test 4',
value: 'Test 4',
leftIcon: (
<Badge size="xs" variant="tertiary">
1
</Badge>
),
rightIcon: (
<Badge size="xs" variant="tertiary">
1
</Badge>
),
},
{
label: 'Test 5',
value: 'Test 5',
disabled: true,
},
];