d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
97 lines
3.5 KiB
TypeScript
97 lines
3.5 KiB
TypeScript
'use client';
|
|
|
|
import { Button } from '@/components/actions/Button';
|
|
import { Accordion } from '@/components/controls/Accordion';
|
|
import { SegmentedControl } from '@/components/controls/SegmentedControl';
|
|
import { Tabs } from '@/components/controls/Tabs';
|
|
import { Alert } from '@/components/feedback/Alert';
|
|
import { Checkbox, Switch } from '@/components/forms/ChoiceControls';
|
|
import { FormField } from '@/components/forms/FormField';
|
|
import { TextInput } from '@/components/forms/TextInput';
|
|
import { DropdownMenu } from '@/components/overlays/DropdownMenu';
|
|
import { Dialog } from '@/components/overlays/Dialog';
|
|
import type { ComponentLabCopy } from '@/content/development/component-lab';
|
|
import { useRef, useState } from 'react';
|
|
import styles from './page.module.css';
|
|
|
|
export function ComponentLabInteractive({ copy }: { copy: ComponentLabCopy }) {
|
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
const [segment, setSegment] = useState('comfortable');
|
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
return (
|
|
<div className={styles.interactiveGrid}>
|
|
<section className={styles.group} aria-labelledby="lab-actions">
|
|
<h2 id="lab-actions">Actions</h2>
|
|
<div className={styles.cluster}>
|
|
<Button>{copy.actions.primary}</Button>
|
|
<Button intent="conversion">{copy.actions.conversion}</Button>
|
|
<Button loading>{copy.actions.loading}</Button>
|
|
<Button disabled>{copy.actions.disabled}</Button>
|
|
<Button ref={triggerRef} intent="secondary" onClick={() => setDialogOpen(true)}>
|
|
{copy.dialog.open}
|
|
</Button>
|
|
<DropdownMenu
|
|
label={copy.menu.label}
|
|
items={[
|
|
{ id: 'review', label: copy.menu.first, onSelect: () => undefined },
|
|
{
|
|
id: 'archive',
|
|
label: copy.menu.second,
|
|
onSelect: () => undefined,
|
|
destructive: true,
|
|
},
|
|
]}
|
|
/>
|
|
</div>
|
|
</section>
|
|
<section className={styles.group} aria-labelledby="lab-form">
|
|
<h2 id="lab-form">Form controls</h2>
|
|
<FormField
|
|
id="fixture-email"
|
|
label={copy.form.label}
|
|
supportingText={copy.form.supporting}
|
|
error={copy.form.error}
|
|
required
|
|
>
|
|
<TextInput
|
|
id="fixture-email"
|
|
type="email"
|
|
placeholder={copy.form.placeholder}
|
|
invalid
|
|
describedBy="fixture-email-help fixture-email-error"
|
|
/>
|
|
</FormField>
|
|
<Checkbox label={copy.form.checkbox} />
|
|
<Switch label={copy.form.switch} />
|
|
<SegmentedControl
|
|
label="Density"
|
|
value={segment}
|
|
onChange={setSegment}
|
|
options={[
|
|
{ value: 'comfortable', label: 'Comfortable' },
|
|
{ value: 'compact', label: 'Compact' },
|
|
]}
|
|
/>
|
|
</section>
|
|
<section className={styles.group} aria-labelledby="lab-controls">
|
|
<h2 id="lab-controls">Selection and disclosure</h2>
|
|
<Tabs label={copy.tabs.label} items={copy.tabs.items} />
|
|
<Accordion items={copy.accordion.items} />
|
|
</section>
|
|
<Alert tone="warning" title={copy.alert.title}>
|
|
{copy.alert.body}
|
|
</Alert>
|
|
<Dialog
|
|
open={dialogOpen}
|
|
onOpenChange={setDialogOpen}
|
|
title={copy.dialog.title}
|
|
description={copy.dialog.description}
|
|
closeLabel={copy.dialog.close}
|
|
returnFocusRef={triggerRef}
|
|
>
|
|
<p>{copy.dialog.content}</p>
|
|
</Dialog>
|
|
</div>
|
|
);
|
|
}
|