Collection
Business / HR & People · v0.2.0Validated
Track a new hire’s progress, see blocked tasks and find the owner to follow up with.
New Hire Checklist · Preview
Loading widget…
Preparing source code…
Idle
Business / HR & People · v0.2.0Validated
Track a new hire’s progress, see blocked tasks and find the owner to follow up with.
Loading widget…
Preparing source code…
Load the Lumo theme once in your app entry point. The example uses the local Lumo workspace packages.
import "@lumo/tokens/tokens.css";
import { OnboardingWidget } from "@lumo/widgets/catalog/hr/onboarding";
export default function Example() {
return <OnboardingWidget />;
}Props for integrating the React component in your app.
snapshotOnboardingSnapshot | null (optional)onAction(action: OnboardingAction) => void | Promise<void>{
"snapshot": {
"hire": "Avery Chen",
"role": "Product design",
"tasks": [
{
"id": "badge",
"name": "Activate office badge",
"owner": "Workplace",
"status": "blocked",
"dueLabel": "Mon 09:00",
"blocker": "Photo approval pending"
}
]
}
}"use client";
import { ListChecks } from "lucide-react";
import { Progress } from "@lumo/ui";
import { WidgetOperations, type OperationRow } from "../../shared/WidgetOperations";
import { useOperationSnapshot } from "../../shared/operation-snapshot";
import shared from "../../shared/operations-list.module.css";
import { onboardingDemo } from "./onboarding.constants";
import type { OnboardingSnapshot, OnboardingAction, OnboardingTask } from "./onboarding.types";
export type { OnboardingSnapshot, OnboardingAction, OnboardingTask } from "./onboarding.types";
const status: Record<OnboardingTask["status"], NonNullable<OperationRow<never>["status"]>> = {
blocked: { label: "Blocked", tone: "danger" }, done: { label: "Done", tone: "success" },
active: { label: "In progress", tone: "info" }, todo: { label: "To do", tone: "neutral" },
};
export function OnboardingWidget({ snapshot, onAction }: {
index?: number; snapshot?: OnboardingSnapshot | null;
onAction?: (action: OnboardingAction) => void | Promise<void>;
} = {}) {
const { data, action } = useOperationSnapshot(snapshot, onboardingDemo, onAction, (state, request) => ({
...state, tasks: state.tasks.map(task => task.id === request.taskId ? { ...task, reminderSent: true } : task),
}));
const tasks = (data?.tasks ?? []).slice().sort((a, b) => Number(b.status === "blocked") - Number(a.status === "blocked"));
const done = tasks.filter(task => task.status === "done").length;
const blocked = tasks.filter(task => task.status === "blocked").length;
const rows = data ? tasks.map<OperationRow<OnboardingAction>>(task => ({
id: task.id, label: task.name, caption: task.blocker ?? task.owner, status: status[task.status],
details: [["Owner", task.owner ?? "Not assigned"], ["Due", task.dueLabel ?? "Not scheduled"],
...(task.reminderSent ? [["Reminder", "Sent"]] as const : [])],
actions: task.owner && task.status !== "done" && !task.reminderSent
? [{ label: "Remind owner", command: { type: "remind-owner", taskId: task.id } }] : [],
})) : null;
return <WidgetOperations title="Onboarding" icon={<ListChecks />} description={data && `${data.hire} · ${data.role}` || undefined}
rows={rows} empty="No onboarding tasks" onAction={action} summary={tasks.length ? <>
<strong>{done}/{tasks.length}</strong><span>complete{blocked > 0 && ` · ${blocked} blocked`}</span>
<Progress value={done} max={tasks.length} animateOnMount className={shared.patternRail} style={{ flexBasis: "100%" }} aria-label="Onboarding completion" />
</> : null} />;
}
lucide-reactmotionreactreact-dom