Export is PDF, RULE.md, and Print on US Letter, with every shared term, no member names, and a takeaway that points at Ask an organizer. Finished Rules keep type and place so the team can read folded counts without a database, Umami can sit beside the app with no cookies, and the person who holds the pen gets working PDF and RULE.md links 48 hours later.
297 lines
8.9 KiB
TypeScript
297 lines
8.9 KiB
TypeScript
"use client";
|
|
|
|
import Logo from "../../asset/Logo";
|
|
import Button from "../../buttons/Button";
|
|
import ListItem from "../../layout/ListItem";
|
|
import Popover from "../../modals/Popover";
|
|
import type { CreateFlowTopNavViewProps } from "./CreateFlowTopNav.types";
|
|
import { CREATE_FLOW_PAGE_GUTTER_CLASS } from "../../../(app)/create/components/createFlowLayoutTokens";
|
|
|
|
const outlineButtonClass =
|
|
"md:!text-x-small-label !text-xx-small-label !px-[var(--space-150)] md:!px-[var(--space-200)] !py-[6px] md:!py-[8px] !border md:!border-[1.5px]";
|
|
|
|
const exitButtonFigmaClass =
|
|
"!rounded-[var(--radius-full)] !border-[1.25px] !px-[var(--space-250)] !py-[var(--space-200)] md:!text-x-small-label";
|
|
|
|
function KebabIcon({ className = "" }: { className?: string }) {
|
|
return (
|
|
<svg
|
|
width="12"
|
|
height="12"
|
|
viewBox="0 0 16 16"
|
|
fill="none"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
className={`shrink-0 md:h-[14px] md:w-[14px] ${className}`}
|
|
aria-hidden="true"
|
|
>
|
|
<circle cx="4" cy="8" r="1.5" fill="currentColor" />
|
|
<circle cx="8" cy="8" r="1.5" fill="currentColor" />
|
|
<circle cx="12" cy="8" r="1.5" fill="currentColor" />
|
|
</svg>
|
|
);
|
|
}
|
|
|
|
export function CreateFlowTopNavView({
|
|
hasShare = false,
|
|
hasExport = false,
|
|
hasEdit = false,
|
|
hasDuplicate = false,
|
|
hasManageStakeholders = false,
|
|
saveDraftOnExit = false,
|
|
onShare,
|
|
onSelectExportFormat,
|
|
onEdit,
|
|
onDuplicate,
|
|
onManageStakeholders,
|
|
onExit,
|
|
duplicateLabel,
|
|
duplicateAriaLabel,
|
|
buttonPalette = "default",
|
|
className = "",
|
|
exitButtonText,
|
|
useKebabMenu,
|
|
exportMenuOpen,
|
|
setExportMenuOpen,
|
|
actionsMenuOpen,
|
|
setActionsMenuOpen,
|
|
exportWrapRef,
|
|
actionsWrapRef,
|
|
exportMenuId,
|
|
actionsMenuId,
|
|
actionMenuItems,
|
|
exportPopoverMenuAriaLabel,
|
|
exportPopoverPdfLabel,
|
|
exportPopoverMarkdownLabel,
|
|
exportPopoverPrintLabel,
|
|
moreOptionsAriaLabel,
|
|
actionsMenuAriaLabel,
|
|
shareLabel,
|
|
exportLabel,
|
|
editLabel,
|
|
manageStakeholdersLabel,
|
|
shareAriaLabel,
|
|
exportAriaLabel,
|
|
editAriaLabel,
|
|
manageStakeholdersAriaLabel,
|
|
bannerAriaLabel,
|
|
navAriaLabel,
|
|
}: CreateFlowTopNavViewProps) {
|
|
const hasSecondaryActions =
|
|
hasShare ||
|
|
hasExport ||
|
|
hasEdit ||
|
|
hasDuplicate ||
|
|
hasManageStakeholders;
|
|
|
|
const inlineActions = (
|
|
<>
|
|
{hasShare && (
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
onClick={onShare}
|
|
ariaLabel={shareAriaLabel}
|
|
className={outlineButtonClass}
|
|
>
|
|
{shareLabel}
|
|
</Button>
|
|
)}
|
|
|
|
{hasExport && onSelectExportFormat ? (
|
|
<div className="relative" ref={exportWrapRef}>
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
type="button"
|
|
ariaLabel={exportAriaLabel}
|
|
aria-haspopup="menu"
|
|
aria-expanded={exportMenuOpen}
|
|
aria-controls={exportMenuId}
|
|
onClick={() => setExportMenuOpen((o) => !o)}
|
|
className={`justify-center gap-[var(--space-050)] !pl-[var(--space-300)] !pr-[var(--space-150)] md:!pr-[var(--space-150)] ${outlineButtonClass}`}
|
|
>
|
|
<span>{exportLabel}</span>
|
|
<svg
|
|
width="12"
|
|
height="12"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={2}
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
className="shrink-0 md:h-[14px] md:w-[14px]"
|
|
aria-hidden="true"
|
|
>
|
|
<path d="M19 9l-7 7-7-7" />
|
|
</svg>
|
|
</Button>
|
|
{exportMenuOpen ? (
|
|
<div className="absolute right-0 top-[calc(100%+var(--space-200))] z-[300]">
|
|
<Popover
|
|
id={exportMenuId}
|
|
menuAriaLabel={exportPopoverMenuAriaLabel}
|
|
>
|
|
<ListItem
|
|
showDivider
|
|
leadingIcon="picture_as_pdf"
|
|
label={exportPopoverPdfLabel}
|
|
onClick={() => {
|
|
onSelectExportFormat("pdf");
|
|
setExportMenuOpen(false);
|
|
}}
|
|
/>
|
|
<ListItem
|
|
showDivider
|
|
leadingIcon="markdown_copy"
|
|
label={exportPopoverMarkdownLabel}
|
|
onClick={() => {
|
|
onSelectExportFormat("markdown");
|
|
setExportMenuOpen(false);
|
|
}}
|
|
/>
|
|
<ListItem
|
|
showDivider={false}
|
|
leadingIcon="print"
|
|
label={exportPopoverPrintLabel}
|
|
onClick={() => {
|
|
onSelectExportFormat("print");
|
|
setExportMenuOpen(false);
|
|
}}
|
|
/>
|
|
</Popover>
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
) : null}
|
|
|
|
{hasDuplicate && (
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
onClick={onDuplicate}
|
|
ariaLabel={
|
|
duplicateAriaLabel ?? duplicateLabel ?? editAriaLabel
|
|
}
|
|
className={outlineButtonClass}
|
|
>
|
|
{duplicateLabel ?? editLabel}
|
|
</Button>
|
|
)}
|
|
|
|
{hasEdit && !hasDuplicate && (
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
onClick={onEdit}
|
|
ariaLabel={editAriaLabel}
|
|
className={outlineButtonClass}
|
|
>
|
|
{editLabel}
|
|
</Button>
|
|
)}
|
|
|
|
{hasManageStakeholders && onManageStakeholders ? (
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
type="button"
|
|
onClick={onManageStakeholders}
|
|
ariaLabel={manageStakeholdersAriaLabel}
|
|
className={outlineButtonClass}
|
|
>
|
|
{manageStakeholdersLabel}
|
|
</Button>
|
|
) : null}
|
|
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
type="button"
|
|
onClick={() => void onExit?.({ saveDraft: saveDraftOnExit })}
|
|
ariaLabel={exitButtonText}
|
|
className={`shrink-0 ${exitButtonFigmaClass} !text-xx-small-label !py-[6px] md:!py-[8px]`}
|
|
>
|
|
{exitButtonText}
|
|
</Button>
|
|
</>
|
|
);
|
|
|
|
return (
|
|
<header
|
|
className={`bg-black w-full ${className}`}
|
|
role="banner"
|
|
aria-label={bannerAriaLabel}
|
|
>
|
|
<nav
|
|
className={`flex items-center justify-between mx-auto w-full max-w-[1920px] ${CREATE_FLOW_PAGE_GUTTER_CLASS} py-[var(--space-300)] md:py-[var(--space-400)]`}
|
|
role="navigation"
|
|
aria-label={navAriaLabel}
|
|
>
|
|
<Logo size="createFlow" wordmark palette={buttonPalette} />
|
|
|
|
<div className="flex flex-wrap items-center justify-end gap-[var(--space-300)]">
|
|
{useKebabMenu ? (
|
|
<div className="relative" ref={actionsWrapRef}>
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
type="button"
|
|
ariaLabel={moreOptionsAriaLabel}
|
|
aria-haspopup="menu"
|
|
aria-expanded={actionsMenuOpen}
|
|
aria-controls={actionsMenuId}
|
|
onClick={() => setActionsMenuOpen((open) => !open)}
|
|
className={`!px-[var(--space-250)] ${outlineButtonClass}`}
|
|
>
|
|
<KebabIcon />
|
|
</Button>
|
|
{actionsMenuOpen ? (
|
|
<div className="absolute right-0 top-[calc(100%+var(--space-200))] z-[300]">
|
|
<Popover id={actionsMenuId} menuAriaLabel={actionsMenuAriaLabel}>
|
|
{actionMenuItems.map((item, index) => (
|
|
<ListItem
|
|
key={item.id}
|
|
showDivider={index < actionMenuItems.length - 1}
|
|
leadingIcon={item.leadingIcon}
|
|
label={item.label}
|
|
onClick={() => {
|
|
item.onClick();
|
|
setActionsMenuOpen(false);
|
|
}}
|
|
/>
|
|
))}
|
|
</Popover>
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
) : hasSecondaryActions ? (
|
|
inlineActions
|
|
) : (
|
|
<Button
|
|
buttonType="outline"
|
|
palette={buttonPalette}
|
|
size="xsmall"
|
|
type="button"
|
|
onClick={() => void onExit?.({ saveDraft: saveDraftOnExit })}
|
|
ariaLabel={exitButtonText}
|
|
className={`shrink-0 ${exitButtonFigmaClass} !text-xx-small-label !py-[6px] md:!py-[8px]`}
|
|
>
|
|
{exitButtonText}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
);
|
|
}
|
|
|
|
CreateFlowTopNavView.displayName = "CreateFlowTopNavView";
|