Skip to content

Commit 6307e8e

Browse files
committed
Make jump links actually hideable
Connect UI to toggle jump links to store and save information in local storage.
1 parent 7b6c17d commit 6307e8e

25 files changed

+102
-57
lines changed

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default tseslint.config(
1010
{ ignores: ['dist/**/*'] },
1111
js.configs.recommended,
1212
{
13-
files: ['ui/**/*.{js,jsx,ts,tsx}'],
13+
files: ['src/**/*.{js,jsx,ts,tsx}'],
1414
languageOptions: {
1515
globals: { ...globals.browser },
1616
},
@@ -30,7 +30,7 @@ export default tseslint.config(
3030
},
3131
reactPlugin.configs.flat['jsx-runtime'],
3232
{
33-
files: ['ui/**/*.tsx'],
33+
files: ['src/**/*.{ts,tsx}'],
3434
plugins: {
3535
'react-hooks': reactHooksPlugin,
3636
},

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"format": "prettier . --write"
1111
},
1212
"dependencies": {
13-
"@headlessui/react": "^2.1.2",
13+
"@headlessui/react": "^2.1.10",
1414
"@mdi/js": "^7.4.47",
1515
"@mdi/react": "^1.4.0",
1616
"classnames": "^2.3.1",
@@ -28,7 +28,7 @@
2828
"autoprefixer": "^10.4.2",
2929
"eslint": "^9.12.0",
3030
"eslint-plugin-react": "^7.37.1",
31-
"eslint-plugin-react-hooks": "^5.1.0-rc-d5bba18b-20241009",
31+
"eslint-plugin-react-hooks": "^5.1.0-rc-70fb1363-20241010",
3232
"fuzzysort": "^3.0.2",
3333
"globals": "^15.11.0",
3434
"postcss": "^8.4.31",

src/components/App/App.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ import { useCustomizeMode } from './useCustomizeMode'
2626
import { useSearchMode } from './useSearchMode'
2727
import { useTheme } from './useTheme'
2828
import { useToggleDescriptions } from './useToggleDescriptions'
29+
import { useToggleJumpLinks } from './useToggleJumpLinks'
2930

3031
export const WebdevHome: FC = () => {
3132
const customizeMode = useCustomizeMode()
3233
const searchMode = useSearchMode()
3334
const toggleDescriptions = useToggleDescriptions()
35+
const toggleJumpLinks = useToggleJumpLinks()
3436
const isCurrentAppMode = useIsCurrentAppMode()
3537

3638
useTheme()
@@ -45,7 +47,7 @@ export const WebdevHome: FC = () => {
4547
return (
4648
<AppLayout
4749
sidebar={
48-
isCurrentAppMode(AppMode.default, AppMode.customize) ? (
50+
isCurrentAppMode(AppMode.default, AppMode.customize) && toggleJumpLinks.showJumpLinks ? (
4951
<JumpLinks />
5052
) : null
5153
}
@@ -80,8 +82,8 @@ export const WebdevHome: FC = () => {
8082
<AppMenuItem
8183
label="Show group list"
8284
icon={<MdiIcon path={mdiDockLeft} />}
83-
selected={true}
84-
action={() => {}}
85+
selected={toggleJumpLinks.showJumpLinks}
86+
action={toggleJumpLinks.toggle}
8587
/>
8688

8789
<AppThemeSwitcher />

src/components/App/useCustomizeMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { setAppMode, toggleAppMode } from '../../stores/appMode/appModeActions'
44
import { useIsCurrentAppMode } from '../../stores/appMode/appModeHooks'
55
import { AppMode } from '../../stores/appMode/appModeReducer'
66

7-
export interface UseCustomizeModeResult {
7+
export type UseCustomizeModeResult = {
88
handleCustomizeAction: () => void
99
}
1010

src/components/App/useSearchMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useIsCurrentAppMode } from '../../stores/appMode/appModeHooks'
55
import { AppMode } from '../../stores/appMode/appModeReducer'
66
import { setSearchTerm } from '../../stores/search/searchActions'
77

8-
export interface UseSearchModeResult {
8+
export type UseSearchModeResult = {
99
handleSearchAction: () => void
1010
}
1111

src/components/App/useThemeSwitcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useAppDispatch, useAppSelector } from '../../stores'
33
import { setTheme } from '../../stores/appSettings/appSettingsActions'
44
import { AppTheme } from '../../stores/appSettings/appSettingsReducer'
55

6-
export interface UseThemeSwitcherResult {
6+
export type UseThemeSwitcherResult = {
77
currentTheme: AppTheme
88
setLightTheme: () => void
99
setDarkTheme: () => void

src/components/App/useToggleDescriptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback } from 'react'
22
import { useAppDispatch, useAppSelector } from '../../stores'
33
import { setDisplayDescription } from '../../stores/appSettings/appSettingsActions'
44

5-
interface UseToggleDescriptionsResult {
5+
type UseToggleDescriptionsResult = {
66
showDescriptions: boolean
77
toggle: () => void
88
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useCallback } from 'react'
2+
import { useAppDispatch, useAppSelector } from '../../stores'
3+
import { setDisplayJumpLinks } from '../../stores/appSettings/appSettingsActions'
4+
5+
type UseToggleJumpLinksResult = {
6+
showJumpLinks: boolean
7+
toggle: () => void
8+
}
9+
10+
export function useToggleJumpLinks(): UseToggleJumpLinksResult {
11+
const dispatch = useAppDispatch()
12+
13+
const showJumpLinks = useAppSelector(
14+
(state) => state.appSettings.showJumpLinks,
15+
)
16+
17+
const toggle = useCallback(() => {
18+
dispatch(setDisplayJumpLinks(!showJumpLinks))
19+
}, [dispatch, showJumpLinks])
20+
21+
return { showJumpLinks, toggle }
22+
}

src/components/Links/Links.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import classNames from 'classnames'
2-
import { FC, PropsWithChildren } from 'react'
2+
import { FC } from 'react'
33
import { links } from '../../links'
44
import { LinkGroup } from './LinkGroup'
55

6-
export const Links: FC<PropsWithChildren> = ({ children }) => {
6+
export const Links: FC = () => {
77
return (
88
<div
99
className={classNames(
@@ -12,7 +12,7 @@ export const Links: FC<PropsWithChildren> = ({ children }) => {
1212
'px-page py-4',
1313
)}
1414
>
15-
{links.items.map((group, index) => (
15+
{links.items.map((group) => (
1616
<LinkGroup group={group} key={group.name} />
1717
))}
1818
</div>

0 commit comments

Comments
 (0)