@@ -53,7 +53,7 @@ import { HAElement, HAQuerySelector, HAQuerySelectorEvent, OnListenDetail } from
5353import { HomeAssistantStylesManager } from 'home-assistant-styles-manager' ;
5454
5555import { SoGroupDivider } from './components/so-group-divider' ;
56- import { DIVIDER_ADDED_STYLE , DRAWER_STYLE , HUI_ROOT_STYLE } from './sidebar-css' ;
56+ import { DIVIDER_ADDED_STYLE , DRAWER_STYLE , HA_MAIN_CUSTOM_WIDTH_STYLE , HUI_ROOT_STYLE } from './sidebar-css' ;
5757
5858export class SidebarOrganizer {
5959 constructor ( ) {
@@ -245,9 +245,8 @@ export class SidebarOrganizer {
245245 let ticking = false ;
246246 let lastScrollY = window . scrollY ;
247247 let currentOffset = 0 ;
248-
249- // NEW
250248 let accumulatedDelta = 0 ;
249+
251250 const threshold = maxHide ; // Minimum scroll delta before reacting, this helps to prevent jitter on small scrolls. Defaults to header height;
252251
253252 const updateHeaderVisibility = ( ) => {
@@ -543,6 +542,9 @@ export class SidebarOrganizer {
543542 this . _pinnedGroups = normalizePinnedGroups ( pinned_groups || { } ) ;
544543 // Initialize collapsed groups based on config, this will be used to set initial state of groups and manage collapse/expand functionality
545544 this . collapsedItems = getCollapsedItems ( custom_groups , default_collapsed ) ;
545+
546+ // Setup custom sidebar width
547+ this . _addCustomWidthStyle ( ) ;
546548 // Setup additional styles based on color config
547549 this . _addAdditionalStyles ( color_config ) ;
548550
@@ -574,14 +576,14 @@ export class SidebarOrganizer {
574576 beforeSpacerContainer . appendChild ( newItemEl ) ;
575577 }
576578 } ) ;
577- console . log ( 'New items added to sidebar:' , new_items ) ;
579+ console . debug ( 'New items added to sidebar:' , new_items ) ;
578580 }
579581
580582 if ( move_settings_from_fixed === true ) {
581583 const settingsItem = sidebarShadowRoot . querySelector ( SELECTOR . SETTINGS_ITEM ) as SidebarPanelItem ;
582584 if ( settingsItem ) {
583585 beforeSpacerContainer . appendChild ( settingsItem ) ;
584- console . log ( 'Settings item moved from fixed:' , move_settings_from_fixed ) ;
586+ console . debug ( 'Settings item moved from fixed:' , move_settings_from_fixed ) ;
585587 } else {
586588 console . log (
587589 '%cSIDEBAR-ORGANIZER:%c ❌ Settings item not found' ,
@@ -734,7 +736,11 @@ export class SidebarOrganizer {
734736 this . _panelsList . insertBefore ( haMdList , spacer . nextElementSibling ) ;
735737 }
736738 //success
737- console . log ( '%cSIDEBAR-ORGANIZER:%c ✅ Bottom items added to sidebar' , 'color: #bada55;' , 'color: #40c057;' ) ;
739+ console . debug (
740+ '%cSIDEBAR-ORGANIZER:%c ✅ Bottom items added to sidebar' ,
741+ 'color: #bada55;' ,
742+ 'color: #40c057;'
743+ ) ;
738744 }
739745 console . groupEnd ( ) ;
740746 } ) ;
@@ -1118,6 +1124,23 @@ export class SidebarOrganizer {
11181124 } ) ;
11191125 }
11201126
1127+ private _addCustomWidthStyle ( ) : void {
1128+ if ( ! this . _config . width ) return ;
1129+ Promise . all ( [ this . _haMain . element as Promise < HTMLElement > ] ) . then ( ( elements ) => {
1130+ const [ haMain ] = elements ;
1131+ const { width } = this . _config ! ;
1132+ const customWidth = this . _store . _utils . CONFIG . _computeWidth ( width ) ;
1133+ if ( ! customWidth ) {
1134+ console . debug ( '❌ Invalid custom width, skipping applying custom width style:' , width ) ;
1135+ return ;
1136+ }
1137+ haMain . style . setProperty ( '--custom-sidebar-width' , customWidth ) ;
1138+ console . debug ( 'Custom sidebar width applied:' , customWidth ) ;
1139+
1140+ this . _styleManager . addStyle ( [ HA_MAIN_CUSTOM_WIDTH_STYLE . toString ( ) ] , haMain . shadowRoot ! ) ;
1141+ } ) ;
1142+ }
1143+
11211144 private _addAdditionalStyles ( color_config : SidebarConfig [ 'color_config' ] , mode ?: string ) {
11221145 mode = mode ? mode : this . darkMode ? 'dark' : 'light' ;
11231146 const customTheme = color_config ?. custom_theme ?. theme || undefined ;
0 commit comments