feat: shell wordmark, accent nav item and styled company picker
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
37cb996bc0
commit
0710571894
11 files changed
+101
-57
No files matched your search
@@ -12,7 +12,7 @@ Serial. One implementer at a time, Opus review gate per task.
|
||||
|
||||
## 2. Shell
|
||||
|
||||
- [ ] 2.1 Sidebar wordmark (mark plus solid "Co-Lite"; remove `brand-gradient-text` from `globals.css`), cards use the shadow token, active item in the accent, header and page header spacing to the reference sketch; company picker becomes the styled select.
|
||||
- [x] 2.1 Sidebar wordmark (mark plus solid "Co-Lite"; remove `brand-gradient-text` from `globals.css`), cards use the shadow token, active item in the accent, header and page header spacing to the reference sketch; company picker becomes the styled select.
|
||||
- Depends on: 1.1
|
||||
- Tests first: sidebar shows "Co-Lite" with no gradient class; only the current nav item is marked active; the company picker opens a menu with "All companies" and each code, and choosing one sets the scope.
|
||||
- Scope: `solvway-admin-portal/app/components/app/**`, `solvway-admin-portal/app/components/ui/**`, `solvway-admin-portal/app/lib/CompanyScope*.tsx`, `solvway-admin-portal/app/globals.css`
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
import { useAdminAuth } from "@/app/lib/AdminAuthContext";
|
||||
import { useCompanyScope } from "@/app/lib/CompanyScope";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
|
||||
|
||||
// Radix Select rejects "" as an item value, so "All companies" is this sentinel, mapped to undefined.
|
||||
const ALL = "all";
|
||||
|
||||
// Header company filter; super admins only (staff are always scoped by the server).
|
||||
export default function CompanyPicker() {
|
||||
@@ -11,16 +15,16 @@ export default function CompanyPicker() {
|
||||
const t = useT();
|
||||
if (!isSuper) return null;
|
||||
return (
|
||||
<select
|
||||
aria-label={t("Company")}
|
||||
value={companyId ?? ""}
|
||||
onChange={(e) => setCompanyId(e.target.value ? Number(e.target.value) : undefined)}
|
||||
className="h-9 rounded-md border bg-background px-2 text-sm"
|
||||
>
|
||||
<option value="">{t("AllCompanies")}</option>
|
||||
{companies.map((c) => (
|
||||
<option key={c.id} value={c.id}>{c.code}</option>
|
||||
))}
|
||||
</select>
|
||||
<Select value={companyId === undefined ? ALL : String(companyId)} onValueChange={(v) => setCompanyId(v === ALL ? undefined : Number(v))}>
|
||||
<SelectTrigger aria-label={t("Company")} className="min-w-36">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value={ALL}>{t("AllCompanies")}</SelectItem>
|
||||
{companies.map((c) => (
|
||||
<SelectItem key={c.id} value={String(c.id)}>{c.code}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export default function Header() {
|
||||
const initial = (name ?? "?").slice(0, 1).toUpperCase();
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-30 flex h-16 shrink-0 items-center gap-2 border-b bg-card px-4">
|
||||
<header className="sticky top-0 z-30 flex h-14 shrink-0 items-center gap-2 border-b bg-card px-4">
|
||||
<Sheet open={menuOpen} onOpenChange={setMenuOpen}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -68,7 +68,7 @@ export default function Header() {
|
||||
</Button>
|
||||
<SheetContent side="left" className="w-[var(--sidebar-width)] max-w-[85vw] bg-sidebar p-0">
|
||||
<SheetTitle className="sr-only">{t("HeaderMenu")}</SheetTitle>
|
||||
<div className="flex h-16 shrink-0 items-center border-b px-4">
|
||||
<div className="flex h-14 shrink-0 items-center border-b px-4">
|
||||
<BrandLink onClick={() => setMenuOpen(false)} />
|
||||
</div>
|
||||
<SidebarNav onNavigate={() => setMenuOpen(false)} />
|
||||
|
||||
@@ -392,9 +392,9 @@ describe("Sidebar icon rail", () => {
|
||||
const sales = screen.getByRole("button", { name: "Sales & orders" });
|
||||
const stock = screen.getByRole("button", { name: "Stock" });
|
||||
expect(sales).toHaveAttribute("data-current", "true");
|
||||
expect(sales.className).toContain("bg-sidebar-primary");
|
||||
expect(sales).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
|
||||
expect(stock).not.toHaveAttribute("data-current");
|
||||
expect(stock.className).not.toContain("bg-sidebar-primary");
|
||||
expect(stock).not.toHaveClass("bg-sidebar-accent");
|
||||
});
|
||||
|
||||
it("keeps a current top-level leaf filled in the rail", async () => {
|
||||
@@ -405,7 +405,7 @@ describe("Sidebar icon rail", () => {
|
||||
|
||||
const link = screen.getByRole("link", { name: "Dashboard" });
|
||||
expect(link).toHaveAttribute("aria-current", "page");
|
||||
expect(link.className).toContain("bg-sidebar-primary");
|
||||
expect(link).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
|
||||
});
|
||||
|
||||
it("keeps the footer credit visible in a compact form", async () => {
|
||||
@@ -430,7 +430,7 @@ describe("Sidebar icon rail", () => {
|
||||
|
||||
expect(within(brandRow()).queryByRole("link")).toBeNull();
|
||||
expect(within(brandRow()).getByRole("button", { name: "Expand sidebar" })).toBeInTheDocument();
|
||||
expect(brandRow()).toHaveClass("h-16", "justify-center");
|
||||
expect(brandRow()).toHaveClass("h-14", "justify-center");
|
||||
|
||||
await user.click(screen.getByRole("button", { name: "Expand sidebar" }));
|
||||
expect(within(brandRow()).getByRole("link", { name: /Co-Lite/ })).toBeInTheDocument();
|
||||
@@ -488,3 +488,35 @@ describe("Sidebar icon rail", () => {
|
||||
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
|
||||
});
|
||||
});
|
||||
|
||||
// add-visual-foundation: Product Wordmark / One Accent Colour.
|
||||
describe("Sidebar visual identity", () => {
|
||||
afterEach(() => {
|
||||
state.pathname = "/";
|
||||
});
|
||||
|
||||
it("shows the Co-Lite mark and a solid wordmark, not gradient-filled text", () => {
|
||||
state.links = [];
|
||||
const { container } = render(<Sidebar />);
|
||||
const word = screen.getByText("Co-Lite");
|
||||
expect(word).not.toHaveClass("brand-wordmark");
|
||||
expect(word.className).not.toMatch(/gradient|text-transparent/);
|
||||
expect(container.querySelector("[data-slot='brand-mark']")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("marks only the current top-level item in the accent, not a solid primary fill", () => {
|
||||
state.links = [
|
||||
{ name: "Events", url: "/events", iconName: "Users", children: [] },
|
||||
{ name: "Leads", url: "/leads", iconName: "Users", children: [] },
|
||||
];
|
||||
state.pathname = "/events";
|
||||
render(<Sidebar />);
|
||||
const events = screen.getByRole("link", { name: "Events" });
|
||||
const leads = screen.getByRole("link", { name: "Leads" });
|
||||
expect(events).toHaveAttribute("aria-current", "page");
|
||||
expect(events).toHaveClass("bg-sidebar-accent", "text-sidebar-accent-foreground");
|
||||
expect(events).not.toHaveClass("bg-sidebar-primary");
|
||||
expect(leads).not.toHaveClass("bg-sidebar-accent");
|
||||
expect(leads).not.toHaveClass("bg-sidebar-primary");
|
||||
});
|
||||
});
|
||||
@@ -44,10 +44,8 @@ function NavNode({ link, depth, trail, onNavigate }: { link: SidebarLink; depth:
|
||||
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
|
||||
depth === 0 ? "min-h-11 text-sm font-medium" : "min-h-9 text-sm",
|
||||
active
|
||||
? depth === 0
|
||||
? "bg-sidebar-primary text-sidebar-primary-foreground"
|
||||
: "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
|
||||
: "text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
? "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
|
||||
: "text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{/* eslint-disable-next-line react-hooks/static-components -- Icon comes from
|
||||
@@ -98,7 +96,7 @@ function NavGroup({
|
||||
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
|
||||
depth === 0 ? "min-h-11 text-sm font-medium" : "min-h-9 text-sm",
|
||||
active ? "text-sidebar-accent-foreground" : "text-muted-foreground",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
"hover:bg-muted hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{Icon && <Icon aria-hidden="true" className="size-5 shrink-0" />}
|
||||
@@ -124,8 +122,8 @@ const railItemClass = cn(
|
||||
"flex size-11 items-center justify-center rounded-lg transition-colors",
|
||||
"focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none",
|
||||
);
|
||||
const railIdleClass = "text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground";
|
||||
const railActiveClass = "bg-sidebar-primary text-sidebar-primary-foreground";
|
||||
const railIdleClass = "text-muted-foreground hover:bg-muted hover:text-foreground";
|
||||
const railActiveClass = "bg-sidebar-accent text-sidebar-accent-foreground";
|
||||
|
||||
function RailNode({ link, trail }: { link: SidebarLink; trail: SidebarLink[] }) {
|
||||
const t = useT();
|
||||
@@ -241,7 +239,8 @@ export function BrandLink({ onClick }: { onClick?: () => void }) {
|
||||
onClick={onClick}
|
||||
className="flex items-center gap-2.5 rounded-md focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none"
|
||||
>
|
||||
<span className="brand-wordmark text-lg">{BRAND}</span>
|
||||
<span data-slot="brand-mark" aria-hidden="true" className="size-6 shrink-0 rounded-md bg-primary" />
|
||||
<span className="text-lg font-semibold tracking-tight text-foreground">{BRAND}</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -270,7 +269,7 @@ export default function Sidebar() {
|
||||
// Expanded on the server and during hydration; the stored choice is applied after mount so both renders agree.
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
// The width animates only after a toggle: applying a stored collapse on load must not animate
|
||||
// 272 -> 76px (and reflow the page) on every navigation.
|
||||
// 240 -> 76px (and reflow the page) on every navigation.
|
||||
const [animate, setAnimate] = useState(false);
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- localStorage is only readable after mount; reading it during render would make the hydration render disagree with the server.
|
||||
@@ -297,7 +296,7 @@ export default function Sidebar() {
|
||||
{/* Header-high in both states so its border lines up with the header's; the rail shows only the toggle. */}
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-16 shrink-0 items-center border-b",
|
||||
"flex h-14 shrink-0 items-center border-b",
|
||||
collapsed ? "justify-center" : "justify-between gap-2 px-4",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -24,7 +24,7 @@ const badgeVariants = cva(
|
||||
// Category tones (feedback 2026-10-21: every type/fulfilment pill was the same beige). For
|
||||
// kinds, not states — status keeps positive/warning/negative. Each pill keeps its text label,
|
||||
// so colour is never the only signal.
|
||||
contrast: "border-contrast/30 bg-contrast-soft text-contrast-foreground",
|
||||
contrast: "bg-accent text-accent-foreground",
|
||||
teal: "border-chart-2/30 bg-chart-2/10 text-chart-2",
|
||||
violet: "border-chart-4/30 bg-chart-4/10 text-chart-4",
|
||||
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
||||
|
||||
@@ -7,7 +7,7 @@ function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||
<div
|
||||
data-slot="card"
|
||||
className={cn(
|
||||
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
||||
"flex flex-col gap-6 rounded-lg border bg-card py-6 text-card-foreground shadow-card",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -23,7 +23,7 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
||||
return (
|
||||
<thead
|
||||
data-slot="table-header"
|
||||
// A gold header row with dusty-blue text (--table-head; owner request 2026-10-23). Opaque, so
|
||||
// A slate header row (--table-head). Opaque, so
|
||||
// a sticky header still covers the rows scrolling under it.
|
||||
className={cn("bg-table-head [&_tr]:border-b [&_tr]:hover:bg-transparent", className)}
|
||||
{...props}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
/*
|
||||
* Design tokens, ported from src/styles/_variables.scss + tailwind.css
|
||||
* (Tailwind 4 @theme) into plain CSS custom properties for Tailwind 3's
|
||||
* postcss-based build (see tailwind.config.ts). The old stylesheet's two
|
||||
* Sass-only mixins in actual use (brand-gradient-text, custom-scrollbar) are
|
||||
* folded in below as .brand-wordmark/.scrollable. Inter, the one type family,
|
||||
* postcss-based build (see tailwind.config.ts). The old stylesheet's
|
||||
* Sass-only mixin in actual use (custom-scrollbar) is
|
||||
* folded in below as .scrollable. Inter, the one type family,
|
||||
* loads via next/font in app/layout.tsx, which sets --font-inter.
|
||||
*
|
||||
* CURRENT SKIN: Co-Lite. Slate neutrals with one blue accent (--primary/--ring #2563EB).
|
||||
@@ -25,9 +25,9 @@
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: 12px;
|
||||
|
||||
--sidebar-width: 272px;
|
||||
--sidebar-width: 240px;
|
||||
--sidebar-width-collapsed: 76px;
|
||||
--header-height: 64px;
|
||||
--header-height: 56px;
|
||||
--content-max-width: 1600px;
|
||||
|
||||
--background: #F8FAFC;
|
||||
@@ -212,19 +212,10 @@ h4 {
|
||||
}
|
||||
|
||||
/*
|
||||
* Ported from src/styles/_mixins.scss (brand-gradient-text, custom-scrollbar):
|
||||
* plain classes rather than Sass mixins, since Tailwind 3's postcss build has
|
||||
* no Sass step. Used by app/components/app/Sidebar.tsx (wordmark, scrollable nav).
|
||||
* Ported from src/styles/_mixins.scss (custom-scrollbar): a plain class rather than
|
||||
* a Sass mixin, since Tailwind 3's postcss build has no Sass step. Used by
|
||||
* app/components/app/Sidebar.tsx (scrollable nav).
|
||||
*/
|
||||
.brand-wordmark {
|
||||
background-image: linear-gradient(to right, var(--primary), var(--accent));
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
font-family: var(--font-heading);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scrollable {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
|
||||
@@ -32,13 +32,19 @@ beforeEach(() => {
|
||||
mocks.useAdminAuth.mockReset().mockReturnValue({ isSuper: true });
|
||||
});
|
||||
|
||||
const openPicker = async (user: ReturnType<typeof userEvent.setup>) => {
|
||||
const picker = await screen.findByRole("combobox", { name: "Company" });
|
||||
await user.click(picker);
|
||||
return picker;
|
||||
};
|
||||
|
||||
describe("CompanyPicker", () => {
|
||||
it("is shown to a super admin with All companies plus each company", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderScope();
|
||||
const picker = await screen.findByRole("combobox", { name: "Company" });
|
||||
await waitFor(() => expect(picker.querySelectorAll("option")).toHaveLength(3));
|
||||
expect([...picker.querySelectorAll("option")].map((o) => o.textContent)).toEqual(["All companies", "INS", "CV"]);
|
||||
expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV");
|
||||
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
|
||||
await openPicker(user);
|
||||
expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["All companies", "INS", "CV"]);
|
||||
});
|
||||
|
||||
it("is not shown to staff, who never load companies or get a companyId", async () => {
|
||||
@@ -53,16 +59,29 @@ describe("CompanyPicker", () => {
|
||||
it("feeds the chosen company into the scope and keeps it for the tab; All companies clears it", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderScope();
|
||||
const picker = await screen.findByRole("combobox", { name: "Company" });
|
||||
await waitFor(() => expect(picker.querySelectorAll("option")).toHaveLength(3));
|
||||
await user.selectOptions(picker, "2");
|
||||
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
|
||||
await openPicker(user);
|
||||
await user.click(await screen.findByRole("option", { name: "CV" }));
|
||||
expect(screen.getByTestId("probe")).toHaveTextContent("2|false|CV");
|
||||
expect(sessionStorage.getItem("company-scope")).toBe("2");
|
||||
await user.selectOptions(picker, "");
|
||||
await openPicker(user);
|
||||
await user.click(await screen.findByRole("option", { name: "All companies" }));
|
||||
expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV");
|
||||
expect(sessionStorage.getItem("company-scope")).toBeNull();
|
||||
});
|
||||
|
||||
it("opens with Enter, moves with the arrow keys and chooses with Enter", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderScope();
|
||||
await waitFor(() => expect(screen.getByTestId("probe")).toHaveTextContent("undefined|true|CV"));
|
||||
const picker = await screen.findByRole("combobox", { name: "Company" });
|
||||
picker.focus();
|
||||
await user.keyboard("{Enter}");
|
||||
await screen.findByRole("option", { name: "INS" });
|
||||
await user.keyboard("{ArrowDown}{Enter}");
|
||||
expect(screen.getByTestId("probe")).toHaveTextContent("1|false|CV");
|
||||
});
|
||||
|
||||
it("restores the choice from sessionStorage", async () => {
|
||||
sessionStorage.setItem("company-scope", "1");
|
||||
renderScope();
|
||||
|
||||
@@ -19,7 +19,6 @@ const FILES = globSync("app/**/*.tsx", { cwd: ROOT }).filter((f) => !/\.test\.ts
|
||||
// selectors/markers, not Tailwind utilities.
|
||||
const PROJECT_CLASSES = new Set([
|
||||
"tabular",
|
||||
"brand-wordmark",
|
||||
"scrollable",
|
||||
"giraffe-spots",
|
||||
"print-handover",
|
||||
|
||||
Reference in new issue
Block a user