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
57 changes: 57 additions & 0 deletions src/components/PageHeader/PageHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,68 @@
import type { Meta, StoryObj } from '@storybook/react';
import { PageHeader } from './PageHeader';
import { Button } from '../Button/Button';
import {
HomeIcon,
SettingsIcon,
UserIcon,
UsersIcon,
CalendarIcon,
FileTextIcon,
BuildingIcon,
BriefcaseIcon,
ChartIcon,
ShieldIcon,
BellIcon,
SearchIcon,
StethoscopeIcon,
HospitalIcon,
ClipboardListIcon,
} from '../Icons';
import type { LucideIcon } from 'lucide-react';

const iconMap: Record<string, LucideIcon> = {
Home: HomeIcon,
Settings: SettingsIcon,
User: UserIcon,
Users: UsersIcon,
Calendar: CalendarIcon,
FileText: FileTextIcon,
Building: BuildingIcon,
Briefcase: BriefcaseIcon,
Chart: ChartIcon,
Shield: ShieldIcon,
Bell: BellIcon,
Search: SearchIcon,
Stethoscope: StethoscopeIcon,
Hospital: HospitalIcon,
ClipboardList: ClipboardListIcon,
};

const meta: Meta<typeof PageHeader> = {
title: 'Components/PageHeader',
component: PageHeader,
tags: ['autodocs'],
argTypes: {
actions: { control: false },
icon: {
control: 'select',
options: ['None', ...Object.keys(iconMap)],
mapping: {
None: undefined,
...Object.fromEntries(
Object.entries(iconMap).map(([name, Icon]) => [
name,
<Icon key={name} className="h-6 w-6" />,
])
),
},
},
iconAlign: {
control: 'radio',
options: ['top', 'center'],
},
children: { control: false },
},
parameters: {
layout: 'padded',
},
Expand Down
15 changes: 12 additions & 3 deletions src/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface PageHeaderProps {
subtitle?: string;
/** Optional icon to display before the title */
icon?: React.ReactNode;
/** Vertical alignment of the icon */
iconAlign?: 'top' | 'center';
/** Action buttons or controls to display on the right */
actions?: React.ReactNode;
/** Additional content below the title (e.g., breadcrumbs, tabs) */
Expand All @@ -29,6 +31,7 @@ export function PageHeader({
title,
subtitle,
icon,
iconAlign = 'center',
actions,
children,
className = '',
Expand All @@ -51,10 +54,16 @@ export function PageHeader({
<div
className={` ${sizeClasses[size]} ${bordered ? 'border-b border-gray-200 dark:border-gray-700' : ''} ${className} `.trim()}
>
<div className="flex items-center justify-between gap-4">
<div className="flex min-w-0 items-center gap-3">
<div
className={`flex justify-between gap-4 ${iconAlign === 'top' ? 'items-start' : 'items-center'}`}
>
<div
className={`flex min-w-0 gap-3 ${iconAlign === 'top' ? 'items-start' : 'items-center'}`}
>
{icon && (
<div className="flex-shrink-0 text-gray-500 dark:text-gray-400">
<div
className={`flex-shrink-0 text-gray-500 dark:text-gray-400 ${iconAlign === 'top' ? 'mt-1' : ''}`}
>
{icon}
</div>
)}
Expand Down
Loading