mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-03 10:13:47 +10:00
Write becomes the Basics card, the outline of sections in print order and Add section. Entries open in place (one at a time, the editor selection), save as you type and show drafts as "Draft · not printed". Dates use a structured field with a Present switch and the review note for text that wasn't read exactly; descriptions use a restricted rich-text toolbar shown on focus. Sections and entries reorder by drag or Alt+Up/Down, rows carry the eye, count and every section option, and deleting shows Undo. Clicking the page opens the entry and scrolls it into view; focusing a field outlines its block. Phones push an open entry full screen. While a field has focus the preview waits for a pause in typing. The left section sidebar, the entry dialogs and the hidden-sections list are removed.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { ReactNode } from "react";
|
|
|
|
type EmptyDialog<T extends string> = { [K in T]: { type: K; data?: undefined } }[T];
|
|
|
|
export type DialogSchema =
|
|
| EmptyDialog<
|
|
| "auth.change-password"
|
|
| "auth.two-factor.enable"
|
|
| "auth.two-factor.disable"
|
|
| "api-key.create"
|
|
| "resume.create"
|
|
| "resume.import"
|
|
| "resume.template.gallery"
|
|
>
|
|
| {
|
|
type: "resume.update";
|
|
data: { id: string; name: string; slug: string; tags: string[] };
|
|
}
|
|
| {
|
|
type: "resume.duplicate";
|
|
data: { id: string; name: string; slug: string; tags: string[]; shouldRedirect?: boolean };
|
|
};
|
|
|
|
export type DialogType = DialogSchema["type"];
|
|
|
|
type DialogRendererEntry<T extends DialogType = DialogType> = {
|
|
type: T;
|
|
render: (dialog: Extract<DialogSchema, { type: T }>) => ReactNode;
|
|
};
|
|
|
|
export type AnyDialogRendererEntry = {
|
|
[T in DialogType]: DialogRendererEntry<T>;
|
|
}[DialogType];
|
|
|
|
export type DialogData<T extends DialogType> = Extract<DialogSchema, { type: T }>["data"];
|
|
|
|
type DialogPropsData<T extends DialogType> =
|
|
DialogData<T> extends undefined ? Record<string, never> : { data: DialogData<T> };
|
|
|
|
export type DialogProps<T extends DialogType> = DialogPropsData<T>;
|