/** * Internal Sidebar — the module rail. * * Operate-mode navigation: the visitor is mid-task, so the rail stays quiet * until it is the thing being used. One item carries the accent, everything * else is a label. * * The rail collapses to icons only. The choice is per-browser and persists * across modules — someone who works in a narrow window should not have to * re-collapse on every page. Collapsed items keep their name reachable: the * label is exposed to assistive tech via aria-label and to sighted users via * a hover/focus tooltip, so nothing becomes a guessable glyph. */ import { useState, useCallback } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Icon } from '@aime/wp-components'; import { chevronLeft, chevronRight } from '@wordpress/icons'; const STORAGE_KEY = 'aime:sidebar-collapsed'; const readCollapsed = () => { try { return window.localStorage.getItem( STORAGE_KEY ) === '1'; } catch ( e ) { return false; } }; const InternalSidebar = ( { items, activeKey, onNavigate, footer, label } ) => { const [ collapsed, setCollapsed ] = useState( readCollapsed ); const toggle = useCallback( () => { setCollapsed( ( prev ) => { const next = ! prev; try { window.localStorage.setItem( STORAGE_KEY, next ? '1' : '0' ); } catch ( e ) { // A locked-down storage policy costs persistence, not the toggle. } return next; } ); }, [] ); const toggleLabel = collapsed ? __( 'Expand menu', 'ai-marketing-expert' ) : __( 'Collapse menu', 'ai-marketing-expert' ); return ( ); }; export default InternalSidebar;