0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-18 02:31:28 -05:00

feat(docs): highlight active version in version switcher (#16790)

* docs: highlight active version in version switcher

* Add comment explaining workaround
This commit is contained in:
Nicholas Flamy 2025-03-11 06:41:12 -04:00 committed by GitHub
parent 48dddb78d4
commit f0f0056fe3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
export default function VersionSwitcher(): JSX.Element {
const [versions, setVersions] = useState([]);
const [label, setLabel] = useState('Versions');
const [activeLabel, setLabel] = useState('Versions');
const windowSize = useWindowSize();
@ -48,12 +48,13 @@ export default function VersionSwitcher(): JSX.Element {
versions.length > 0 && (
<DropdownNavbarItem
className="version-switcher-34ab39"
label={label}
label={activeLabel}
mobile={windowSize === 'mobile'}
items={versions.map(({ label, url }) => ({
label,
to: new URL(location.pathname + location.search + location.hash, url).href,
target: '_self',
className: label === activeLabel ? 'dropdown__link--active menu__link--active' : '', // workaround because React Router `<NavLink>` only supports using URL path for checking if active: https://v5.reactrouter.com/web/api/NavLink/isactive-func
}))}
/>
)