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
20 changes: 20 additions & 0 deletions playground/src/components/ProportionChartDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ export function ProportionChartDemo() {
height="h-3"
/>
</div>

<div>
<h3 className="text-sm font-medium text-navy-700 dark:text-navy-300 mb-2">
Fixed legend columns (no widow)
</h3>
<ProportionChart
data={statusData}
colors={statusColors}
formatValue={formatCount}
showLegend={true}
legendColumns={5}
height="h-3"
/>
<p className="text-sm text-navy-500 dark:text-navy-400 mt-2">
<code className="text-xs bg-gray-100 dark:bg-navy-800 px-1 py-0.5 rounded">legendColumns</code> pins
the legend to a single row of N columns so a trailing item never wraps to a lonely second row.
Defaults to the number of visible segments.
</p>
</div>
</div>
</section>

Expand Down Expand Up @@ -266,6 +285,7 @@ const colors: Record<string, ColorConfig> = {
formatValue={(n) => \`\${n} tasks\`}
height="h-4"
showLegend={true}
legendColumns={5} // pin to one row of 5 — no widow, never wraps
ariaLabel="Task distribution by status"
/>

Expand Down
1 change: 1 addition & 0 deletions playground/src/components/SidebarDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function SidebarDemo() {
<p className="text-sm text-navy-600 dark:text-navy-400 mb-4">
The Sidebar can be used outside of Layout by wrapping it in a SidebarProvider.
Use SidebarLink and SidebarSection as children for a composable API.
The sidebar is chrome, so it renders navy in both light and dark mode; the active row carries the orange brand accent.
</p>

<div className="border border-gray-200 dark:border-navy-700 rounded-lg overflow-hidden">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Content/ContentPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function ContentPane({
return (
<div
className={cn(
"flex-1 overflow-y-auto bg-gray-50 dark:bg-navy-950",
"flex-1 overflow-y-auto bg-cream dark:bg-navy-950",
padding && "p-4 lg:p-6",
className
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function LayoutContent({

if (hasSidebar) {
return (
<div className="min-h-screen bg-gray-50 dark:bg-navy-950 flex flex-col">
<div className="min-h-screen bg-cream dark:bg-navy-950 flex flex-col">
{/* Banner */}
{banner && (
<div className="bg-orange-500 text-white text-center py-1.5 text-xs font-medium flex items-center justify-center gap-2">
Expand Down Expand Up @@ -285,7 +285,7 @@ function LayoutContent({

// Original layout without sidebar
return (
<div className="min-h-screen bg-gray-50 dark:bg-navy-950">
<div className="min-h-screen bg-cream dark:bg-navy-950">
{/* Banner */}
{banner && (
<div className="bg-orange-500 text-white text-center py-1.5 text-xs font-medium flex items-center justify-center gap-2">
Expand Down
28 changes: 21 additions & 7 deletions src/components/ProportionChart/ProportionChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ export interface ProportionChartProps extends HTMLAttributes<HTMLDivElement> {
*/
showLegend?: boolean

/**
* Number of columns for the optional legend. Legend items lay out in a
* single row of this many columns and never wrap, so a trailing item can't
* become a lone "widow" on a second row. Set this to the maximum number of
* segments you expect for a stable layout across renders.
* @default the number of visible (non-zero) segments
*/
legendColumns?: number

/**
* Accessible label for screen readers
*/
Expand Down Expand Up @@ -114,6 +123,7 @@ export function ProportionChart({
formatValue,
height = 'h-2',
showLegend = false,
legendColumns,
ariaLabel,
className,
...props
Expand Down Expand Up @@ -221,19 +231,23 @@ export function ProportionChart({
</Tooltip>
</Tooltip.Provider>

{/* Legend (optional) */}
{/* Legend (optional) — single non-wrapping row so a trailing item never
becomes a lone "widow". Columns default to the visible segment count. */}
{showLegend && (
<div
className="mt-3 grid grid-cols-2 sm:grid-cols-5 gap-3"
className="mt-3 grid gap-3"
style={{
gridTemplateColumns: `repeat(${legendColumns ?? segments.length}, minmax(0, 1fr))`,
}}
role="list"
aria-label="Chart legend"
>
{segments.map((seg) => (
<div key={seg.key} className="flex items-center gap-2" role="listitem">
<span className={cn('w-3 h-3 rounded', seg.bg)} aria-hidden="true" />
<div>
<div className="text-xs text-gray-500 dark:text-gray-400">{seg.label}</div>
<div className="text-sm font-medium text-gray-900 dark:text-white">
<div key={seg.key} className="flex items-center gap-2 min-w-0" role="listitem">
<span className={cn('w-3 h-3 rounded flex-shrink-0', seg.bg)} aria-hidden="true" />
<div className="min-w-0">
<div className="text-xs text-gray-500 dark:text-gray-400 truncate">{seg.label}</div>
<div className="text-sm font-medium text-gray-900 dark:text-white truncate">
{formatValue(seg.value)}
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function Sidebar({ items, children, header, footer, variant = "responsive
{/* Sidebar panel */}
<aside
className={cn(
"flex flex-col bg-white dark:bg-navy-850 border-r border-gray-200 dark:border-navy-800 overflow-hidden",
"flex flex-col bg-navy-850 border-r border-navy-800 overflow-hidden",
// Inline variant - uses container height, always visible
variant === "inline" && "h-full",
// Responsive variant - desktop sticky with viewport height
Expand All @@ -73,7 +73,7 @@ export function Sidebar({ items, children, header, footer, variant = "responsive
{isMobile ? (
<button
onClick={closeSidebar}
className="absolute top-3 right-3 p-1 text-navy-400 dark:text-navy-400 hover:text-navy-600 dark:hover:text-navy-200 transition-colors"
className="absolute top-3 right-3 p-1 text-navy-400 hover:text-navy-200 transition-colors"
aria-label="Close navigation"
>
<X className="w-5 h-5" aria-hidden="true" />
Expand All @@ -82,7 +82,7 @@ export function Sidebar({ items, children, header, footer, variant = "responsive

{/* Header slot */}
{header && (
<div className="border-b border-gray-200 dark:border-navy-800">
<div className="border-b border-navy-800">
{header}
</div>
)}
Expand All @@ -107,7 +107,7 @@ export function Sidebar({ items, children, header, footer, variant = "responsive

{/* Footer slot */}
{footer && (
<div className="border-t border-gray-200 dark:border-navy-800">
<div className="border-t border-navy-800">
{footer}
</div>
)}
Expand All @@ -116,7 +116,7 @@ export function Sidebar({ items, children, header, footer, variant = "responsive
{!isMobile && (
<button
onClick={toggle}
className="flex items-center justify-center h-10 border-t border-gray-200 dark:border-navy-800 text-navy-400 dark:text-navy-400 hover:text-navy-600 dark:hover:text-navy-200 hover:bg-gray-50 dark:hover:bg-navy-800 transition-colors"
className="flex items-center justify-center h-10 border-t border-navy-800 text-navy-400 hover:text-navy-200 hover:bg-navy-800 transition-colors"
aria-label={isCollapsed ? "Expand sidebar" : "Collapse sidebar"}
>
{isCollapsed ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/SidebarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function SidebarGroupComponent({
{group.label && (
<div
className={cn(
"px-3 text-xs font-semibold text-navy-400 dark:text-navy-400 uppercase tracking-wider whitespace-nowrap transition-[opacity,margin]",
"px-3 text-xs font-semibold text-navy-400 uppercase tracking-wider whitespace-nowrap transition-[opacity,margin]",
COLLAPSE_DURATION,
collapsed ? "opacity-0 mb-0" : "opacity-100 mb-2"
)}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function SidebarItemComponent({

// Keep consistent padding so icon stays in same X position
const baseClasses = cn(
"flex items-center gap-3 px-2 py-2 rounded-md text-sm font-medium transition-colors w-full",
"text-navy-600 dark:text-navy-300 hover:text-navy-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-navy-700",
isActive && "bg-gray-100 dark:bg-navy-700 text-navy-900 dark:text-white"
"flex items-center gap-3 px-2 py-2 rounded-lg text-sm font-medium transition-colors w-full",
"text-navy-300 hover:text-white hover:bg-navy-700",
isActive && "bg-orange-500/[0.14] text-orange-300 hover:text-orange-300"
);

const content = (
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/SidebarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export function SidebarLink({
};

const baseClasses = cn(
"flex items-center gap-3 px-2 py-2 rounded-md text-sm font-medium transition-colors w-full",
"text-navy-600 dark:text-navy-300 hover:text-navy-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-navy-700",
"flex items-center gap-3 px-2 py-2 rounded-lg text-sm font-medium transition-colors w-full",
"text-navy-300 hover:text-white hover:bg-navy-700",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500",
isActive && "bg-gray-100 dark:bg-navy-700 text-navy-900 dark:text-white",
isActive && "bg-orange-500/[0.14] text-orange-300 hover:text-orange-300",
className
);

Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/SidebarSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function SidebarSearch({
<div className={cn("p-2", className)}>
<button
onClick={handleCollapsedClick}
className="w-full h-9 flex items-center justify-center rounded-md border border-gray-200 dark:border-navy-700 text-navy-400 dark:text-navy-400 hover:text-navy-600 dark:hover:text-navy-200 hover:border-gray-300 dark:hover:border-navy-600 hover:bg-gray-50 dark:hover:bg-navy-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500"
className="w-full h-9 flex items-center justify-center rounded-md border border-navy-700 text-navy-400 hover:text-navy-200 hover:border-navy-600 hover:bg-navy-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500"
title={placeholder}
aria-label={placeholder}
>
Expand All @@ -52,7 +52,7 @@ export function SidebarSearch({
return (
<div className={cn("p-3", className)} role="search">
<div className="relative">
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-navy-400 dark:text-navy-400 pointer-events-none" />
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-navy-400 pointer-events-none" />
<input
ref={inputRef}
type="text"
Expand All @@ -61,7 +61,7 @@ export function SidebarSearch({
onChange={(e) => setValue(e.target.value)}
onKeyDown={handleKeyDown}
aria-label={placeholder}
className="w-full pl-8 pr-3 py-1.5 text-sm border border-gray-200 dark:border-navy-700 rounded-md bg-white dark:bg-navy-800 placeholder:text-navy-400 dark:placeholder:text-navy-400 text-navy-900 dark:text-navy-100 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent"
className="w-full pl-8 pr-3 py-1.5 text-sm border border-navy-700 rounded-md bg-navy-800 placeholder:text-navy-400 text-navy-100 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/SidebarSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function SidebarSection({
{label && (
<div
className={cn(
"px-3 text-xs font-semibold text-navy-400 dark:text-navy-400 uppercase tracking-wider whitespace-nowrap transition-[opacity,margin]",
"px-3 text-xs font-semibold text-navy-400 uppercase tracking-wider whitespace-nowrap transition-[opacity,margin]",
COLLAPSE_DURATION,
isCollapsed ? "opacity-0 mb-0" : "opacity-100 mb-2"
)}
Expand Down
10 changes: 5 additions & 5 deletions src/components/Sidebar/SidebarUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export function SidebarUser({
className="w-full h-full rounded-full object-cover"
/>
) : (
<span className="text-navy-600 dark:text-navy-300 font-medium">{initials}</span>
<span className="text-navy-300 font-medium">{initials}</span>
);

// Same pattern as SidebarItemComponent - consistent padding, text fades out
const content = (
<div className="flex items-center gap-3 pl-2.5 pr-2 py-3">
<div className="w-8 h-8 rounded-full bg-navy-100 dark:bg-navy-700 flex items-center justify-center text-sm flex-shrink-0 overflow-hidden">
<div className="w-8 h-8 rounded-full bg-navy-700 flex items-center justify-center text-sm flex-shrink-0 overflow-hidden">
{avatar}
</div>
<div
Expand All @@ -54,11 +54,11 @@ export function SidebarUser({
isCollapsed ? "opacity-0" : "opacity-100"
)}
>
<div className="text-sm font-medium text-navy-900 dark:text-navy-100 truncate whitespace-nowrap">
<div className="text-sm font-medium text-navy-100 truncate whitespace-nowrap">
{name}
</div>
{email && (
<div className="text-xs text-navy-500 dark:text-navy-300 truncate whitespace-nowrap">
<div className="text-xs text-navy-300 truncate whitespace-nowrap">
{email}
</div>
)}
Expand All @@ -68,7 +68,7 @@ export function SidebarUser({

const wrapperClasses = cn(
"w-full transition-colors",
onClick && "cursor-pointer hover:bg-gray-100 dark:hover:bg-navy-800",
onClick && "cursor-pointer hover:bg-navy-800",
className
);

Expand Down
5 changes: 2 additions & 3 deletions src/components/TabBar/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function TabBar({ items, activeId, onChange, variant = 'underline', class
return (
<div
role="tablist"
className={cn('inline-flex items-center gap-1 p-1 rounded-full bg-navy-900/5 dark:bg-navy-800/60', className)}
className={cn('inline-flex items-center gap-1 p-1 rounded-full border border-gray-200 bg-navy-900/5 dark:border-navy-700 dark:bg-navy-800/60', className)}
>
{items.map((item) => {
const isActive = activeId === item.id
Expand All @@ -70,8 +70,7 @@ export function TabBar({ items, activeId, onChange, variant = 'underline', class
aria-selected={isActive}
onClick={() => onChange(item.id)}
className={cn(
'px-3 py-1 text-xs font-semibold uppercase whitespace-nowrap rounded-full transition-colors',
'tracking-wider',
'px-5 py-1.5 text-sm font-semibold whitespace-nowrap rounded-full transition-colors',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500',
isActive
? 'bg-orange-500 text-white shadow-sm'
Expand Down
2 changes: 1 addition & 1 deletion src/styles/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
/* Component classes */
@layer components {
.gp-card {
@apply bg-white rounded-card shadow-sm p-4;
@apply bg-white rounded-card border border-gray-200 shadow-sm p-4;
@apply dark:bg-navy-900 dark:border dark:border-navy-700 dark:shadow-none;
}

Expand Down
Loading