mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
fix(sidebar): centre Playlists icon and unify hover hitbox in collapsed mode (#481)
* fix(sidebar): centre Playlists icon and unify hover hitbox in collapsed mode The Playlists nav entry had its own special render path with a wrapper div, header-row and `flex: 1` main link to fit the expand-toggle button. Those elements remained active in collapsed mode too, where `padding-right` on the header-row and `flex: 1` on the link made the icon sit off-centre and gave the row a wider hover hitbox than every other collapsed sidebar item. Hoist the `isCollapsed` check above the playlists special-case so that in collapsed mode Playlists renders through the same plain `<NavLink>` branch as Artists / Albums / Favorites / etc. The expanded-mode treatment (wrapper, header-row, expand-toggle, nested playlist list) is unchanged. * docs: changelog entry for PR #481 Logs the collapsed-sidebar Playlists icon centring fix in v1.46.0 "## Fixed".
This commit is contained in:
committed by
GitHub
parent
b084e96c1f
commit
ebce53f8a7
+13
-19
@@ -861,7 +861,7 @@ export default function Sidebar({
|
||||
}
|
||||
: {};
|
||||
|
||||
return item.to === '/playlists' ? (
|
||||
return item.to === '/playlists' && !isCollapsed ? (
|
||||
<div
|
||||
key={item.to}
|
||||
className={`sidebar-playlists-wrapper${rowClass ? ` ${rowClass}` : ''}`}
|
||||
@@ -872,25 +872,21 @@ export default function Sidebar({
|
||||
<NavLink
|
||||
to={item.to}
|
||||
className={({ isActive }) => `nav-link sidebar-playlists-main-link ${isActive ? 'active' : ''}`}
|
||||
data-tooltip={isCollapsed ? t(item.labelKey) : undefined}
|
||||
data-tooltip-pos="bottom"
|
||||
>
|
||||
<item.icon size={isCollapsed ? 22 : 18} />
|
||||
{!isCollapsed && <span>{t(item.labelKey)}</span>}
|
||||
<item.icon size={18} />
|
||||
<span>{t(item.labelKey)}</span>
|
||||
</NavLink>
|
||||
{!isCollapsed && (
|
||||
<button
|
||||
className={`sidebar-playlists-toggle ${playlistsExpanded ? 'expanded' : ''}`}
|
||||
onClick={() => setPlaylistsExpanded(!playlistsExpanded)}
|
||||
aria-expanded={playlistsExpanded}
|
||||
aria-label={playlistsExpanded ? t('sidebar.collapsePlaylists') : t('sidebar.expandPlaylists')}
|
||||
data-tooltip={playlistsExpanded ? t('sidebar.collapsePlaylists') : t('sidebar.expandPlaylists')}
|
||||
>
|
||||
<ChevronRight size={14} />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className={`sidebar-playlists-toggle ${playlistsExpanded ? 'expanded' : ''}`}
|
||||
onClick={() => setPlaylistsExpanded(!playlistsExpanded)}
|
||||
aria-expanded={playlistsExpanded}
|
||||
aria-label={playlistsExpanded ? t('sidebar.collapsePlaylists') : t('sidebar.expandPlaylists')}
|
||||
data-tooltip={playlistsExpanded ? t('sidebar.collapsePlaylists') : t('sidebar.expandPlaylists')}
|
||||
>
|
||||
<ChevronRight size={14} />
|
||||
</button>
|
||||
</div>
|
||||
{!isCollapsed && playlistsExpanded && (
|
||||
{playlistsExpanded && (
|
||||
<div className="sidebar-playlists-list">
|
||||
{playlistsLoading ? (
|
||||
<div className="sidebar-playlists-loading">
|
||||
@@ -904,8 +900,6 @@ export default function Sidebar({
|
||||
key={pl.id}
|
||||
to={`/playlists/${pl.id}`}
|
||||
className={({ isActive }) => `nav-link sidebar-playlist-item ${isActive ? 'active' : ''}`}
|
||||
data-tooltip={isCollapsed ? displayPlaylistName(pl.name) : undefined}
|
||||
data-tooltip-pos="bottom"
|
||||
>
|
||||
{isSmartPlaylistName(pl.name) ? <Sparkles size={12} /> : <PlayCircle size={12} />}
|
||||
<span>{displayPlaylistName(pl.name)}</span>
|
||||
|
||||
Reference in New Issue
Block a user