import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; import type { ComponentChildren, FunctionalComponent } from "preact"; import { Notification } from "$lib/web.ts"; import { FeatherProps } from "preact-feather/types"; import { IconBaseProps } from "react-icons/types"; import { MiniEditor } from "./mini_editor.tsx"; export type ActionButton = { icon: FunctionalComponent; description: string; class?: string; callback: () => void; href?: string; mobile?: boolean; }; export function TopBar({ pageName, unsavedChanges, syncFailures, isLoading, isMobile, notifications, onRename, actionButtons, darkMode, vimMode, progressPerc, completer, lhs, onClick, rhs, pageNamePrefix, }: { pageName?: string; unsavedChanges: boolean; syncFailures: number; isLoading: boolean; isMobile: boolean; notifications: Notification[]; darkMode: boolean; vimMode: boolean; progressPerc?: number; onRename: (newName?: string) => Promise; onClick: () => void; completer: (context: CompletionContext) => Promise; actionButtons: ActionButton[]; lhs?: ComponentChildren; rhs?: ComponentChildren; pageNamePrefix?: string; }) { return (
1 ? "sb-sync-error" : undefined} onClick={onClick} > {lhs}
{pageNamePrefix}
{ if (newName !== pageName) { return onRename(newName); } else { return onRename(); } }} completer={completer} onEnter={(newName) => { onRename(newName); }} /> {notifications.length > 0 && (
{notifications.map((notification) => (
{notification.message}
))}
)}
{progressPerc !== undefined && (
{progressPerc}%
)} {actionButtons.map((actionButton) => { const button = ( ); return actionButton.href !== undefined ? {button} : button; })}
{rhs}
); }