Files
liqa/client/src/ui/SidePanel/SidePanel.tsx
T
agent 92141a25fb feat(client): add cookie-backed authentication UI
- Add session-aware login, logout and protected navigation.
- Send cookie credentials for API and run-event requests with localized UI stories.
2026-11-05 04:18:11 -05:00

71 lines
1.9 KiB
TypeScript

import React, { useState } from 'react';
import styles from './SidePanel.module.css';
export interface SidePanelProps {
children: React.ReactNode;
header?: React.ReactNode;
width?: number;
defaultCollapsed?: boolean;
collapsed?: boolean;
onCollapsedChange?: (collapsed: boolean) => void;
className?: string;
}
export function SidePanel({
children,
header,
width = 240,
defaultCollapsed = false,
collapsed: controlledCollapsed,
onCollapsedChange,
className,
}: SidePanelProps) {
const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed);
const isControlled = controlledCollapsed !== undefined;
const collapsed = isControlled ? controlledCollapsed : internalCollapsed;
function toggle() {
const next = !collapsed;
if (!isControlled) setInternalCollapsed(next);
onCollapsedChange?.(next);
}
return (
<aside
className={[styles.panel, collapsed ? styles.collapsed : '', className]
.filter(Boolean)
.join(' ')}
style={{ '--side-panel-width': `${width}px` } as React.CSSProperties}
aria-expanded={!collapsed}
>
<div className={styles.inner} aria-hidden={collapsed} inert={collapsed}>
{header && <div className={styles.header}>{header}</div>}
<div className={styles.content}>{children}</div>
</div>
<button
className={styles.toggle}
onClick={toggle}
aria-label={collapsed ? 'Expand panel' : 'Collapse panel'}
title={collapsed ? 'Expand' : 'Collapse'}
>
<svg
className={styles.chevron}
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<path
d="M6 3L11 8L6 13"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</button>
</aside>
);
}