Files
projectsend/resources/js/components/category-form.tsx
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

50 lines
1.9 KiB
TypeScript

import InputError from '@/components/input-error';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { useTranslation } from '@/hooks/use-translation';
import { categoryColor } from '@/lib/category-colors';
interface CategoryFormProps {
name: string;
color: string;
colors: string[];
onChange: (field: 'name' | 'color', value: string) => void;
errors: Partial<Record<string, string>>;
}
export function CategoryForm({ name, color, colors, onChange, errors }: CategoryFormProps) {
const { t } = useTranslation();
return (
<div className="grid max-w-md gap-6">
<div className="grid gap-2">
<Label htmlFor="name">{t('Name')}</Label>
<Input id="name" value={name} onChange={(e) => onChange('name', e.target.value)} required autoFocus />
<InputError message={errors.name} />
</div>
<div className="grid gap-2">
<Label>{t('Color')}</Label>
<div className="flex flex-wrap gap-2">
{colors.map((value) => {
const def = categoryColor(value);
return (
<button
key={value}
type="button"
onClick={() => onChange('color', value)}
aria-label={t(def.label)}
aria-pressed={color === value}
title={t(def.label)}
className={`size-6 rounded-full ${def.swatch} ${color === value ? 'ring-ring ring-2 ring-offset-2' : ''}`}
/>
);
})}
</div>
<InputError message={errors.color} />
</div>
</div>
);
}