Pin page actions to the fixed topbar
Each page rendered its primary actions inside the scrolling body, so they drifted away on scroll and diverged from the design, which places them in the topbar next to the breadcrumbs. Introduce a TopbarSlotContext that the Shell publishes from its topbar action area, and a TopbarActions portal that Home, Team, Work, Files, Social and Approvals use to render their controls there.
This commit is contained in:
1 parent
c43f29299f
commit
5f70480907
10 files changed
+95
-92
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import type {
|
import type {
|
||||||
AgentRecord,
|
AgentRecord,
|
||||||
ApprovalRecord,
|
ApprovalRecord,
|
||||||
@@ -57,18 +58,14 @@ export function ApprovalsPage({ snapshot, actions }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<RiskMenu filter={filter} onChange={setFilter} />
|
||||||
<h1 className="page-h1">Approvals</h1>
|
<Button tone="primary" onClick={approveAllLowRisk}>Approve all low risk</Button>
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>
|
</TopbarActions>
|
||||||
{pending.length} pending · {approved7d} approved this week
|
<h1 className="page-h1">Approvals</h1>
|
||||||
</p>
|
<p className="page-sub">
|
||||||
</div>
|
{pending.length} pending · {approved7d} approved this week
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
|
</p>
|
||||||
<RiskMenu filter={filter} onChange={setFilter} />
|
|
||||||
<Button tone="primary" onClick={approveAllLowRisk}>Approve all low risk</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))", gap: 12, marginBottom: 24 }}>
|
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))", gap: 12, marginBottom: 24 }}>
|
||||||
<StatTile label="Pending" value={String(pending.length)} tone="amber" />
|
<StatTile label="Pending" value={String(pending.length)} tone="amber" />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Avatar, Button, Icon, IconButton, Pill, Segmented } from "../shared/ui";
|
import { Avatar, Button, Icon, IconButton, Pill, Segmented } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import type {
|
import type {
|
||||||
AgentRecord,
|
AgentRecord,
|
||||||
EmployeeRecord,
|
EmployeeRecord,
|
||||||
@@ -56,28 +57,24 @@ export function FilesPage({ snapshot, actions }: PageProps) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div style={{ minWidth: 0 }}>
|
<div style={{ minWidth: 0 }}>
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<Button tone="ghost"><Icon name="filter" size={13} /></Button>
|
||||||
<h1 className="page-h1">Files</h1>
|
<Segmented<ViewMode>
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>
|
value={view}
|
||||||
{visibleFiles.length} {visibleFiles.length === 1 ? "file" : "files"} · {formatBytes(totalBytes)}
|
onChange={setView}
|
||||||
</p>
|
options={[
|
||||||
</div>
|
{ id: "grid", label: "Grid" },
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6, alignItems: "center" }}>
|
{ id: "list", label: "List" },
|
||||||
<Button tone="ghost"><Icon name="filter" size={13} /></Button>
|
]}
|
||||||
<Segmented<ViewMode>
|
/>
|
||||||
value={view}
|
<Button tone="primary" onClick={() => void actions.run(() => window.agentCompany.importFile({ orgId }))}>
|
||||||
onChange={setView}
|
<Icon name="upload" size={13} /> Upload
|
||||||
options={[
|
</Button>
|
||||||
{ id: "grid", label: "Grid" },
|
</TopbarActions>
|
||||||
{ id: "list", label: "List" },
|
<h1 className="page-h1">Files</h1>
|
||||||
]}
|
<p className="page-sub">
|
||||||
/>
|
{visibleFiles.length} {visibleFiles.length === 1 ? "file" : "files"} · {formatBytes(totalBytes)}
|
||||||
<Button tone="primary" onClick={() => void actions.run(() => window.agentCompany.importFile({ orgId }))}>
|
</p>
|
||||||
<Icon name="upload" size={13} /> Upload
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{pinnedFiles.length > 0 && section.kind === "all" && (
|
{pinnedFiles.length > 0 && section.kind === "all" && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import type {
|
import type {
|
||||||
AgentRecord,
|
AgentRecord,
|
||||||
ApprovalRecord,
|
ApprovalRecord,
|
||||||
@@ -39,16 +40,12 @@ export function HomePage({ snapshot, actions }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<Button tone="ghost" onClick={() => void actions.reload()} title="Refresh"><Icon name="refresh" size={13} /></Button>
|
||||||
<h1 className="page-h1">{greeting}, {firstName}</h1>
|
<Button tone="primary" onClick={() => setNewTaskOpen(true)}><Icon name="plus" size={13} /> New task</Button>
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>{summaryText}</p>
|
</TopbarActions>
|
||||||
</div>
|
<h1 className="page-h1">{greeting}, {firstName}</h1>
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
|
<p className="page-sub">{summaryText}</p>
|
||||||
<Button tone="ghost" onClick={() => void actions.reload()} title="Refresh"><Icon name="refresh" size={13} /></Button>
|
|
||||||
<Button tone="primary" onClick={() => setNewTaskOpen(true)}><Icon name="plus" size={13} /> New task</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ display: "grid", gridTemplateColumns: "minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr)", gap: 12, marginBottom: 12 }}>
|
<div style={{ display: "grid", gridTemplateColumns: "minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr)", gap: 12, marginBottom: 12 }}>
|
||||||
<TodayCard date={today} tasks={agendaTasks} agents={agents} employee={employee} approvals={pendingApprovals} />
|
<TodayCard date={today} tasks={agendaTasks} agents={agents} employee={employee} approvals={pendingApprovals} />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState, type FormEvent } from "react";
|
import { useMemo, useState, type FormEvent } from "react";
|
||||||
import { Avatar, Button, Field, Icon, IconButton, Pill } from "../shared/ui";
|
import { Avatar, Button, Field, Icon, IconButton, Pill } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import { Dialog } from "../shared/Dialog";
|
import { Dialog } from "../shared/Dialog";
|
||||||
import {
|
import {
|
||||||
SOCIAL_PLATFORM,
|
SOCIAL_PLATFORM,
|
||||||
@@ -76,21 +77,17 @@ export function SocialPage({ snapshot, actions }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<Button onClick={() => setConnectOpen(true)}><Icon name="plus" size={13} /> Connect account</Button>
|
||||||
<h1 className="page-h1">Social</h1>
|
<Button tone="primary" onClick={() => setDraftOpen(true)} disabled={accounts.length === 0}>
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>
|
<Icon name="sparkle" size={13} /> Draft post
|
||||||
{accounts.length} {accounts.length === 1 ? "account" : "accounts"} · {scheduled.length} scheduled
|
</Button>
|
||||||
{operatorName ? ` · managed by ${operatorName}` : ""}
|
</TopbarActions>
|
||||||
</p>
|
<h1 className="page-h1">Social</h1>
|
||||||
</div>
|
<p className="page-sub">
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
|
{accounts.length} {accounts.length === 1 ? "account" : "accounts"} · {scheduled.length} scheduled
|
||||||
<Button onClick={() => setConnectOpen(true)}><Icon name="plus" size={13} /> Connect account</Button>
|
{operatorName ? ` · managed by ${operatorName}` : ""}
|
||||||
<Button tone="primary" onClick={() => setDraftOpen(true)} disabled={accounts.length === 0}>
|
</p>
|
||||||
<Icon name="sparkle" size={13} /> Draft post
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{accounts.length > 0 && (
|
{accounts.length > 0 && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState, type FormEvent } from "react";
|
import { useMemo, useState, type FormEvent } from "react";
|
||||||
import { Avatar, Button, Field, Icon, IconButton, Pill } from "../shared/ui";
|
import { Avatar, Button, Field, Icon, IconButton, Pill } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import { Dialog } from "../shared/Dialog";
|
import { Dialog } from "../shared/Dialog";
|
||||||
import type { AgentRecord, EmployeeRecord, ProviderRecord } from "../../../shared/domain";
|
import type { AgentRecord, EmployeeRecord, ProviderRecord } from "../../../shared/domain";
|
||||||
import type { PageProps } from "./types";
|
import type { PageProps } from "./types";
|
||||||
@@ -49,22 +50,18 @@ export function TeamPage({ snapshot, actions }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<Button tone="ghost" onClick={() => cycleFilter(filter, setFilter)} title="Filter">
|
||||||
<h1 className="page-h1">Team</h1>
|
<Icon name="filter" size={13} /> {filterLabel(filter)}
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>
|
</Button>
|
||||||
{employees.length + agents.length} {employees.length + agents.length === 1 ? "member" : "members"} ·
|
<Button tone="primary" onClick={() => setHireOpen(true)}><Icon name="plus" size={13} /> Hire</Button>
|
||||||
{" "}{employees.length} {employees.length === 1 ? "human" : "humans"} ·
|
</TopbarActions>
|
||||||
{" "}{agents.length} {agents.length === 1 ? "agent" : "agents"}
|
<h1 className="page-h1">Team</h1>
|
||||||
</p>
|
<p className="page-sub">
|
||||||
</div>
|
{employees.length + agents.length} {employees.length + agents.length === 1 ? "member" : "members"} ·
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
|
{" "}{employees.length} {employees.length === 1 ? "human" : "humans"} ·
|
||||||
<Button tone="ghost" onClick={() => cycleFilter(filter, setFilter)} title="Filter">
|
{" "}{agents.length} {agents.length === 1 ? "agent" : "agents"}
|
||||||
<Icon name="filter" size={13} /> {filterLabel(filter)}
|
</p>
|
||||||
</Button>
|
|
||||||
<Button tone="primary" onClick={() => setHireOpen(true)}><Icon name="plus" size={13} /> Hire</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section className="card" style={{ padding: 32, marginBottom: 28 }}>
|
<section className="card" style={{ padding: 32, marginBottom: 28 }}>
|
||||||
<div className="section-label">Org</div>
|
<div className="section-label">Org</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Avatar, Button, Icon, IconButton, Pill, Segmented } from "../shared/ui";
|
import { Avatar, Button, Icon, IconButton, Pill, Segmented } from "../shared/ui";
|
||||||
|
import { TopbarActions } from "../shared/TopbarActions";
|
||||||
import {
|
import {
|
||||||
TASK_STATUS,
|
TASK_STATUS,
|
||||||
type AgentRecord,
|
type AgentRecord,
|
||||||
@@ -54,19 +55,15 @@ export function WorkPage({ snapshot, actions }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page-wide">
|
<div className="page-wide">
|
||||||
<div className="row" style={{ marginBottom: 24 }}>
|
<TopbarActions>
|
||||||
<div>
|
<Segmented value={view} onChange={setView} options={VIEW_OPTIONS} />
|
||||||
<h1 className="page-h1">Work</h1>
|
<Button tone="ghost"><Icon name="filter" size={13} /></Button>
|
||||||
<p className="page-sub" style={{ marginBottom: 0 }}>
|
<Button tone="primary" onClick={() => setNewTaskOpen(true)}><Icon name="plus" size={13} /> New task</Button>
|
||||||
{tasks.length} {tasks.length === 1 ? "task" : "tasks"} · {agents.length} {agents.length === 1 ? "assignee" : "assignees"}
|
</TopbarActions>
|
||||||
</p>
|
<h1 className="page-h1">Work</h1>
|
||||||
</div>
|
<p className="page-sub">
|
||||||
<div style={{ marginLeft: "auto", display: "flex", gap: 6, alignItems: "center" }}>
|
{tasks.length} {tasks.length === 1 ? "task" : "tasks"} · {agents.length} {agents.length === 1 ? "assignee" : "assignees"}
|
||||||
<Segmented value={view} onChange={setView} options={VIEW_OPTIONS} />
|
</p>
|
||||||
<Button tone="ghost"><Icon name="filter" size={13} /></Button>
|
|
||||||
<Button tone="primary" onClick={() => setNewTaskOpen(true)}><Icon name="plus" size={13} /> New task</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{view === "board" && (
|
{view === "board" && (
|
||||||
<BoardView
|
<BoardView
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Avatar, Icon, IconButton } from "./ui";
|
|||||||
import type { IconName } from "./Icon";
|
import type { IconName } from "./Icon";
|
||||||
import { OrgSwitcher } from "./OrgSwitcher";
|
import { OrgSwitcher } from "./OrgSwitcher";
|
||||||
import { SearchDialog } from "./SearchDialog";
|
import { SearchDialog } from "./SearchDialog";
|
||||||
|
import { TopbarSlotContext } from "./topbar-context";
|
||||||
|
|
||||||
export type RouteId =
|
export type RouteId =
|
||||||
| "home"
|
| "home"
|
||||||
@@ -35,7 +36,6 @@ export function Shell({
|
|||||||
snapshot,
|
snapshot,
|
||||||
route,
|
route,
|
||||||
setRoute,
|
setRoute,
|
||||||
actions,
|
|
||||||
onSwitchOrg,
|
onSwitchOrg,
|
||||||
onDeleteOrg,
|
onDeleteOrg,
|
||||||
onNewOrg,
|
onNewOrg,
|
||||||
@@ -44,13 +44,13 @@ export function Shell({
|
|||||||
snapshot: AppSnapshot;
|
snapshot: AppSnapshot;
|
||||||
route: RouteId;
|
route: RouteId;
|
||||||
setRoute: (route: RouteId) => void;
|
setRoute: (route: RouteId) => void;
|
||||||
actions?: ReactNode;
|
|
||||||
onSwitchOrg: (orgId: string) => void;
|
onSwitchOrg: (orgId: string) => void;
|
||||||
onDeleteOrg: (orgId: string) => void;
|
onDeleteOrg: (orgId: string) => void;
|
||||||
onNewOrg: () => void;
|
onNewOrg: () => void;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const [searchOpen, setSearchOpen] = useState(false);
|
const [searchOpen, setSearchOpen] = useState(false);
|
||||||
|
const [actionsSlot, setActionsSlot] = useState<HTMLElement | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handler = (event: KeyboardEvent) => {
|
const handler = (event: KeyboardEvent) => {
|
||||||
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
||||||
@@ -123,7 +123,7 @@ export function Shell({
|
|||||||
<span className="crumb-sep">/</span>
|
<span className="crumb-sep">/</span>
|
||||||
<span className="crumb">{activeLabel}</span>
|
<span className="crumb">{activeLabel}</span>
|
||||||
<div className="topbar-actions">
|
<div className="topbar-actions">
|
||||||
{actions}
|
<span className="topbar-actions-slot" ref={setActionsSlot} />
|
||||||
{window.agentCompany.platform !== "darwin" && (
|
{window.agentCompany.platform !== "darwin" && (
|
||||||
<>
|
<>
|
||||||
<IconButton icon="minus" label="Minimize" onClick={() => void window.agentCompany.windowMinimize()} />
|
<IconButton icon="minus" label="Minimize" onClick={() => void window.agentCompany.windowMinimize()} />
|
||||||
@@ -132,7 +132,9 @@ export function Shell({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="content">{children}</div>
|
<div className="content">
|
||||||
|
<TopbarSlotContext.Provider value={actionsSlot}>{children}</TopbarSlotContext.Provider>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<SearchDialog
|
<SearchDialog
|
||||||
snapshot={snapshot}
|
snapshot={snapshot}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { useContext, type ReactNode } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import { TopbarSlotContext } from "./topbar-context";
|
||||||
|
|
||||||
|
export function TopbarActions({ children }: { children: ReactNode }) {
|
||||||
|
const slot = useContext(TopbarSlotContext);
|
||||||
|
if (!slot) return null;
|
||||||
|
return createPortal(children, slot);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { createContext } from "react";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Shell owns the fixed topbar and publishes its action area as a DOM node
|
||||||
|
* through this context. Pages portal their primary actions into that node via
|
||||||
|
* {@link TopbarActions} so the controls stay pinned to the topbar (matching the
|
||||||
|
* design) instead of scrolling away inside the page body.
|
||||||
|
*/
|
||||||
|
export const TopbarSlotContext = createContext<HTMLElement | null>(null);
|
||||||
@@ -291,6 +291,7 @@ a { color: inherit; }
|
|||||||
.crumb-sub { font-size: 13px; color: var(--text-3); }
|
.crumb-sub { font-size: 13px; color: var(--text-3); }
|
||||||
.crumb-sep { color: var(--text-4); }
|
.crumb-sep { color: var(--text-4); }
|
||||||
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
|
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
|
||||||
|
.topbar-actions-slot { display: flex; align-items: center; gap: 6px; }
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
Reference in new issue
Block a user