// Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 'use client'; import * as React from 'react'; import { useTranslations } from 'next-intl'; import { Code } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Checkbox } from '@/components/ui/checkbox'; import { Button } from '@/components/ui/button'; export function ControlsTab() { const t = useTranslations('admin.demo.controls'); const [formData, setFormData] = React.useState({ name: '', category: 'database', allowNotify: true, channel: 'all', }); return (
{/* 控件展示 */} {t('formDemoTitle')} {t('formDemoDesc')} {/* 输入框 */}
setFormData((prev) => ({ ...prev, name: e.target.value })) } placeholder={t('taskNamePlaceholder')} className='h-8 text-xs shadow-none bg-background focus-visible:ring-1' />

{t('taskNameHint')}

{/* 下拉框 */}
{/* 多选框 Checkbox */}
setFormData((prev) => ({ ...prev, allowNotify: checked === true, })) } className='mt-0.5' />

{t('allowNotifyDesc')}

{/* 按钮变体 */}
{t('buttonStyles')}
{/* 控件设计规范说明 */} {t('formDesignSpec')}

{t('spec.unifiedHeight')}

输入框 ( Input ) 与下拉选择器 ( SelectTrigger ) 的高度应统一限制为小号高度{' '} h-8 ,字体大小使用{' '} text-xs ,并使用{' '} shadow-none {' '} 去除原生的重叠阴影。

{t('spec.checkboxAlignment')}

Checkbox 应在左侧垂直偏上对齐,使用容器{' '} flex items-start gap-2.5 {' '} 排列。Checkbox 组件本身添加{' '} mt-0.5 ,从而在多行描述文本的情况下依然保持良好的顶对齐,避免出现居中对齐导致的凌乱感。

{t('spec.buttonStrategy')}

普通主表单及新增/保存按钮,一律使用默认 Primary 按钮或次要{' '} {'variant="secondary"'} {' '} 按钮,小号高度统一采用{' '} h-8 text-xs 。线框按钮必须带有{' '} border-dashed shadow-none {' '} 类。

{`// 1. Label 与 Input 对齐`}
{`
`}
{`// 2. Checkbox 顶对齐`}
{`

多行说明内容

`}
); }