Add foundational components and logic for migration, UI design, and input handling
- Introduced foundational UI components (`Badge`, `LockCard`, `SectionHeader`, `AvatarIcon`, etc.) for flexible layouts and consistent design. - Added migration support with the `MigrationModal` component and backend integration for exporting/importing data between Electron and Tauri. - Extended form components with `TextAreaInput`, `OrderInput`, `ToggleField`, and `ToolbarSelect` for improved input handling. - Updated `ScribeShell` with migration popup logic to prompt users for data migration. - Integrated `AlertStack` for better alert handling and notification management. - Enhanced Rust/Tauri services with migration command implementations. - Added translations and styles for new components.
This commit is contained in:
72
components/form/OrderInput.tsx
Normal file
72
components/form/OrderInput.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import React, {ChangeEvent} from "react";
|
||||
import {Minus, Plus} from "lucide-react";
|
||||
import IconButton from "@/components/ui/IconButton";
|
||||
import TextInput from "@/components/form/TextInput";
|
||||
|
||||
interface OrderInputProps {
|
||||
value: string;
|
||||
setValue: (e: ChangeEvent<HTMLInputElement>) => void;
|
||||
placeholder: string;
|
||||
order: number;
|
||||
setOrder: (order: number) => void;
|
||||
onAdd: () => Promise<void>;
|
||||
isAddDisabled?: boolean;
|
||||
}
|
||||
|
||||
export default function OrderInput(
|
||||
{
|
||||
value,
|
||||
setValue,
|
||||
placeholder,
|
||||
order,
|
||||
setOrder,
|
||||
onAdd,
|
||||
isAddDisabled = false
|
||||
}: OrderInputProps) {
|
||||
|
||||
function decrementOrder(): void {
|
||||
if (order > 0) {
|
||||
setOrder(order - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function incrementOrder(): void {
|
||||
setOrder(order + 1);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
<IconButton
|
||||
icon={Minus}
|
||||
variant="muted"
|
||||
size="sm"
|
||||
onClick={decrementOrder}
|
||||
disabled={order <= 0}
|
||||
/>
|
||||
<span className="text-muted text-xs w-5 h-5 rounded-md bg-tertiary text-center leading-5">
|
||||
{order}
|
||||
</span>
|
||||
<IconButton
|
||||
icon={Plus}
|
||||
variant="muted"
|
||||
size="sm"
|
||||
onClick={incrementOrder}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<TextInput
|
||||
value={value}
|
||||
setValue={setValue}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
</div>
|
||||
<IconButton
|
||||
icon={Plus}
|
||||
variant="primary"
|
||||
onClick={onAdd}
|
||||
disabled={isAddDisabled}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user