import { Button } from "$components/Button"; import { FileAddIcon, FolderAddIcon, LibraryIcon, SearchIcon, StandardSiteIcon, Tangled } from "$icons"; import { formatCount } from "$utils/text"; import { useMemo } from "react"; type WelcomeMeta = { headline: string; description: string; locationSummary: string; documentSummary: string }; type WelcomeActionIcon = "create" | "search" | "tangled" | "standardSite"; type WelcomeAction = { title: string; description: string; icon: WelcomeActionIcon; onClick?: () => void; disabled?: boolean; iconClassName: string; iconContainerClassName: string; }; type WelcomeActionCardProps = WelcomeAction; type WelcomeScreenProps = { hasLocations: boolean; locationCount: number; documentCount: number; onCreateNewDocument?: () => void; onOpenExisting: () => void; onAddLocation: () => void; onOpenImportSheet?: () => void; onOpenStandardSiteImportSheet?: () => void; }; function ActionIcon({ icon, className = "" }: { icon: WelcomeActionIcon; className?: string }) { switch (icon) { case "create": return ; case "search": return ; case "tangled": return ; case "standardSite": return ; } } type WelcomeHeroProps = WelcomeMeta; function WelcomeSummaryCard({ label, value }: { label: string; value: string }) { return (
{label}
{value}
); } function WelcomeHero({ headline, description, locationSummary, documentSummary }: WelcomeHeroProps) { return (
Workspace Ready

{headline}

{description}

); } type WelcomeAsideProps = { hasLocations: boolean; onAddLocation: () => void }; function WelcomeAside({ hasLocations, onAddLocation }: WelcomeAsideProps) { const copy = hasLocations ? "Use the quick actions to stay in flow." : "Once a location is added, Commonplace can create drafts locally and route imports into that workspace."; const label = hasLocations ? "Add another location" : "Add your first location"; return ( ); } function WelcomeActionCard( { title, description, icon, onClick, disabled = false, iconClassName, iconContainerClassName }: WelcomeActionCardProps, ) { return ( ); } function WelcomeActions({ actions }: { actions: WelcomeAction[] }) { return (
{actions.map((action) => )}
); } function WelcomeFrame( { meta, hasLocations, onAddLocation, actions }: { meta: WelcomeMeta } & WelcomeAsideProps & { actions: WelcomeAction[]; }, ) { return (
); } export function WelcomeScreen( { hasLocations, locationCount, documentCount, onCreateNewDocument, onOpenExisting, onAddLocation, onOpenImportSheet, onOpenStandardSiteImportSheet, }: WelcomeScreenProps, ) { const meta = useMemo( () => ({ headline: hasLocations ? "Welcome" : "Start by adding a location.", description: hasLocations ? "Create a fresh draft, reopen something from your library, or pull material in from an external source." : "Commonplace needs a location before it can create drafts, save notes, or import anything into your workspace.", locationSummary: hasLocations ? `${formatCount(locationCount, "location", "locations")} connected` : "No locations connected", documentSummary: hasLocations ? `${formatCount(documentCount, "document", "documents")}` : "Import available after connecting a location", }), [hasLocations, locationCount, documentCount], ); const actions = useMemo( () => [{ title: "Create new", description: hasLocations ? "Open a blank draft in the selected location." : "Add a location first so the draft has somewhere to live.", icon: "create", onClick: onCreateNewDocument, disabled: !hasLocations || !onCreateNewDocument, iconClassName: "text-accent-blue", iconContainerClassName: "bg-layer-03", }, { title: "Open existing", description: hasLocations ? "Search your library and jump straight into an existing document." : "Connect a location first to browse or search stored work.", icon: "search", onClick: onOpenExisting, disabled: !hasLocations, iconClassName: "text-text-primary", iconContainerClassName: "bg-layer-03", }, { title: "Import from Tangled", description: "Pull in strings from Tangled and save them as local documents.", icon: "tangled", onClick: onOpenImportSheet, disabled: !hasLocations || !onOpenImportSheet, iconClassName: "text-accent-magenta", iconContainerClassName: "bg-layer-03", }, { title: "Import Standard.Site Documents", description: "Bring public posts into Commonplace for local editing and revision.", icon: "standardSite", onClick: onOpenStandardSiteImportSheet, disabled: !hasLocations || !onOpenStandardSiteImportSheet, iconClassName: "text-accent-green", iconContainerClassName: "bg-layer-03", }], [hasLocations, onCreateNewDocument, onOpenExisting, onOpenImportSheet, onOpenStandardSiteImportSheet], ); return (
); }