Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/layout-and-navigation/app-sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Inside a panel `AppLayout` (the default) the sidebar uses `surface="shell"`: Pro
- **`action`**: the main call to action under the header, as a full-width 44px button (Proton's "New message"). Collapsed to icons, only its icon shows; the label stays its accessible name.
- **Count pills**: numeric badges are brand-coloured pills for unread-like counts, read as "12 new" by screen readers. Set `badgeTone: "neutral"` on an item for a plain muted total, read as the number alone.
- **Folders and labels**: give an item a `color`. With a semantic icon (`icon: "folder"`) the icon is tinted; with no icon it shows a coloured dot. The colour is decorative; the label carries the meaning.
- **Header and footer**: put a `Logo` in `header`, with an [`ActionMenu`](../overlays/action-menu) of the suite's apps next to it if there is one, and a quota bar ([`ProgressBar`](../loading/progress-bar) with a link) or a `UserProfile` in `footer`.
- **Header and footer**: put a `Logo` in `header`, with an [`ActionMenu`](../overlays/action-menu) of the suite's apps next to it if there is one, and a quota bar ([`ProgressBar`](../loading/progress-bar) with a link) or a `UserProfile` in `footer`. Collapsed to icons, the header and footer are an icon wide: a `Logo` shows only its mark and a `UserProfile` only its avatar, and anything else that doesn't fit is clipped. Hide content that has no icon form, such as the quota bar or the app switcher, with `className="group-data-[collapsible=icon]:hidden"`.

```tsx
<AppSidebar
Expand Down
2 changes: 1 addition & 1 deletion figma/plugin/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(function() {

//#region ../packages/onu/package.json
var version = "0.3.0";
var version = "0.3.1";

//#endregion
//#region ../tokens.json
Expand Down
4 changes: 4 additions & 0 deletions packages/onu-mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @javaabu/onu-mcp

## 0.3.1

No changes in this release.

## 0.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/onu-mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@javaabu/onu-mcp",
"version": "0.3.0",
"version": "0.3.1",
"description": "MCP server for Onu (@javaabu/onu): gives AI assistants the component docs and the rules for writing Onu code.",
"license": "MIT",
"author": {
Expand Down
6 changes: 6 additions & 0 deletions packages/onu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @javaabu/onu

## 0.3.1

### Patch Changes

- 5a4d06b: `AppSidebar`: collapsed to icons, the header and footer no longer spill out of the sidebar. A `Logo` shows only its mark, a `UserProfile` only its avatar, and anything else is clipped to the sidebar's width.

## 0.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/onu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@javaabu/onu",
"version": "0.3.0",
"version": "0.3.1",
"description": "Javaabu's React UI component library: shadcn/ui based, RTL and Dhivehi first, Thaana keyboard input, one-variable theming.",
"license": "MIT",
"author": {
Expand Down
22 changes: 22 additions & 0 deletions packages/onu/src/components/layout/app-sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { directions, expectNoA11yViolations, renderWithOnu } from "../../../test
import { SidebarProvider, SidebarTrigger } from "../../ui/sidebar"
import { TooltipProvider } from "../../ui/tooltip"
import { AppSidebar } from "./app-sidebar"
import { Logo } from "./logo"
import { UserProfile } from "./user-profile"
import type { NavGroup } from "./_nav"

// Overlays and axe are slow under parallel coverage runs.
Expand Down Expand Up @@ -185,6 +187,26 @@ describe("AppSidebar", () => {
expect(within(menu).getByRole("menuitem", { name: "Locked" })).toHaveAttribute("aria-disabled", "true")
})

it("fits a Logo and a UserProfile into the header and footer when collapsed to icons", () => {
renderSidebar(
<AppSidebar
groups={groups}
header={<Logo alt="Onu" text="Onu Admin" href={null} />}
footer={<UserProfile name="Aishath Shifa" subtitle="Admin" />}
/>,
{},
false,
)
const header = document.querySelector("[data-slot=sidebar-header]")!
const footer = document.querySelector("[data-slot=sidebar-footer]")!
expect(header).toHaveClass("group-data-[collapsible=icon]:overflow-hidden")
expect(header).toHaveClass("group-data-[collapsible=icon]:[&_[data-slot=logo-text]]:sr-only")
expect(header.querySelector("[data-slot=logo-text]")).toHaveTextContent("Onu Admin")
expect(footer).toHaveClass("group-data-[collapsible=icon]:overflow-hidden")
expect(footer).toHaveClass("group-data-[collapsible=icon]:[&_[data-slot=user-profile-text]]:hidden")
expect(screen.getByRole("button", { name: /Aishath Shifa/ })).toHaveAttribute("data-part", "user-profile")
})

it("toggles with the sidebar trigger and Ctrl+B", async () => {
renderSidebar(<AppSidebar groups={groups} />)
const sidebar = document.querySelector("[data-slot=sidebar]")!
Expand Down
29 changes: 27 additions & 2 deletions packages/onu/src/components/layout/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ export interface AppSidebarProps extends Omit<React.ComponentProps<typeof Sideba
}
}

/**
* Collapsed to icons, the header and footer are only an icon wide: clip
* whatever doesn't fit, keep a `Logo`'s mark (its wordmark stays as the
* accessible name) and shrink a `UserProfile` to its avatar. Footer content
* with no icon form (a quota bar) should hide itself with
* `group-data-[collapsible=icon]:hidden`.
*/
const COLLAPSED_HEADER =
"group-data-[collapsible=icon]:overflow-hidden group-data-[collapsible=icon]:[&_[data-slot=logo-text]]:sr-only"
const COLLAPSED_FOOTER = cn(
"group-data-[collapsible=icon]:overflow-hidden",
"group-data-[collapsible=icon]:[&_[data-part=user-profile]]:size-8 group-data-[collapsible=icon]:[&_[data-part=user-profile]]:min-h-0 group-data-[collapsible=icon]:[&_[data-part=user-profile]]:p-0",
"group-data-[collapsible=icon]:[&_[data-slot=user-profile-chevron]]:hidden group-data-[collapsible=icon]:[&_[data-slot=user-profile-text]]:hidden",
)

function plainLabel(label: React.ReactNode) {
return typeof label === "string" || typeof label === "number" ? String(label) : undefined
}
Expand Down Expand Up @@ -445,7 +460,11 @@ export function AppSidebar({
<Sidebar collapsible={collapsible} side={side} surface={surface} className={className} {...props}>
{header || action ? (
<SidebarHeader
className={cn(shell && "gap-4 px-3 pt-4 pb-2 group-data-[collapsible=icon]:px-2", classNames?.header)}
className={cn(
COLLAPSED_HEADER,
shell && "gap-4 px-3 pt-4 pb-2 group-data-[collapsible=icon]:px-2",
classNames?.header,
)}
>
{header}
{action ? (
Expand Down Expand Up @@ -494,7 +513,13 @@ export function AppSidebar({
</nav>
{children}
</SidebarContent>
{footer ? <SidebarFooter className={cn(shell && "px-3 pb-3", classNames?.footer)}>{footer}</SidebarFooter> : null}
{footer ? (
<SidebarFooter
className={cn(COLLAPSED_FOOTER, shell && "px-3 pb-3 group-data-[collapsible=icon]:px-2", classNames?.footer)}
>
{footer}
</SidebarFooter>
) : null}
{rail ? <SidebarRail /> : null}
</Sidebar>
)
Expand Down
6 changes: 5 additions & 1 deletion packages/onu/src/components/layout/logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ export function Logo({
const content = (
<>
{mark}
{text ? <span className={cn("text-base font-semibold tracking-tight", classNames?.text)}>{text}</span> : null}
{text ? (
<span data-slot="logo-text" className={cn("text-base font-semibold tracking-tight", classNames?.text)}>
{text}
</span>
) : null}
</>
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/onu/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "onu",
"description": "Build UI with Onu (@javaabu/onu): the rules for writing Onu code, and the component docs through the Onu MCP server.",
"version": "0.3.0",
"version": "0.3.1",
"author": {
"name": "Javaabu Pvt. Ltd.",
"url": "https://javaabu.com"
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/_shared/shells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export function AdminShell({
</LinkButton>
}
footer={
<div className="gap-2 pt-3 grid border-t border-shell-border">
<div className="gap-2 pt-3 grid border-t border-shell-border group-data-[collapsible=icon]:hidden">
<ProgressBar
size="sm"
value={1284}
Expand Down
9 changes: 7 additions & 2 deletions web/src/showcase/layout-and-navigation/app-sidebar.demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ function ShellDemo() {
<ActionMenu
align="start"
trigger={
<Button variant="ghost" size="icon" aria-label={tr("Switch app", "އެޕް ބަދަލުކުރޭ")}>
<Button
variant="ghost"
size="icon"
className="group-data-[collapsible=icon]:hidden"
aria-label={tr("Switch app", "އެޕް ބަދަލުކުރޭ")}
>
<Icon name="grid" />
</Button>
}
Expand Down Expand Up @@ -136,7 +141,7 @@ function ShellDemo() {
},
]}
footer={
<div className="gap-2 pt-3 grid border-t border-shell-border">
<div className="gap-2 pt-3 grid border-t border-shell-border group-data-[collapsible=icon]:hidden">
<ProgressBar
size="sm"
value={1284}
Expand Down
Loading