Skip to content

Commit 7e95d7c

Browse files
committed
Update useEffects, swap preact signals for a useState hook, update invokers polyfill and reduce navigation-container complexity
1 parent cde89e3 commit 7e95d7c

File tree

10 files changed

+146
-460
lines changed

10 files changed

+146
-460
lines changed

site/.astro/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"_variables": {
3-
"lastUpdateCheck": 1738930819805
3+
"lastUpdateCheck": 1740585432909
44
}
55
}

site/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"devDependencies": {
3535
"@astrojs/mdx": "^4.0.8",
3636
"@astrojs/sitemap": "3.2.1",
37-
"astro": "5.2.5",
37+
"astro": "5.3.1",
3838
"astro-compress": "^2.3.6",
3939
"eslint": "^8.18.0",
4040
"hast-util-to-string": "^2.0.0",
@@ -47,8 +47,7 @@
4747
},
4848
"dependencies": {
4949
"@astrojs/preact": "^4.0.4",
50-
"@preact/signals": "^2.0.1",
51-
"invokers-polyfill": "^0.4.7",
52-
"preact": "^10.25.4"
50+
"invokers-polyfill": "^0.5.2",
51+
"preact": "^10.26.2"
5352
}
5453
}

site/src/components/navigation/navigation-container.jsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
1-
import { useSignal } from '@preact/signals'
2-
import { useEffect, useRef } from 'preact/hooks'
1+
import { useState } from 'preact/hooks'
2+
import 'invokers-polyfill'
33

44
function NavigationContainer(props) {
5-
const isMenuOpen = useSignal(false)
6-
const navRef = useRef(null)
5+
const [isMenuOpen, setIsMenuOpen] = useState(false)
76

8-
useEffect(() => {
9-
function handleCommand(e) {
10-
if (e.command === '--toggle-menu') {
11-
isMenuOpen.value = !isMenuOpen.value
12-
e.source.setAttribute('aria-expanded', isMenuOpen.value)
13-
}
7+
function handleCommand(e) {
8+
if (e.command === '--toggle-menu') {
9+
setIsMenuOpen(!isMenuOpen)
10+
e.source.setAttribute('aria-expanded', isMenuOpen)
1411
}
15-
16-
if (navRef.current) {
17-
navRef.current.addEventListener('command', handleCommand)
18-
}
19-
20-
return () => {
21-
if (navRef.current) {
22-
navRef.current.removeEventListener('command', handleCommand)
23-
}
24-
}
25-
})
12+
}
2613

2714
return (
28-
<nav ref={navRef} id="site-nav" className={isMenuOpen.value ? 'opened' : ''}>
15+
<nav onCommand={handleCommand} id="site-nav" className={isMenuOpen ? 'opened' : ''}>
2916
{props.children}
3017
</nav>
3118
)

site/src/components/navigation/navigation.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const routesToNotPrefetch = ['/research/component-matrix']
5858
}
5959
</style>
6060

61-
<NavigationContainer client:load>
61+
<NavigationContainer client:only>
6262
<CommunityLinks className="mobile" />
6363

6464
<div class="wrapper">

site/src/components/toggle-menu-button.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import './toggle-menu-button.css'
2-
import 'invokers-polyfill'
32

43
function ToggleMenuButton() {
54
return (

site/src/pages/components/popup.research.explainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useEffect } from 'preact/hooks'
1010
function Page() {
1111
useEffect(() => {
1212
return history.replace('/get-involved')
13-
})
13+
}, [])
1414

1515
return null
1616
}

site/src/pages/components/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect } from 'preact/hooks'
33
function Page() {
44
useEffect(() => {
55
return history.replace('/get-involved')
6-
})
6+
}, [])
77

88
return null
99
}

site/src/pages/components/selectlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect } from 'preact/hooks'
33
function Page() {
44
useEffect(() => {
55
return history.replace('/get-involved')
6-
})
6+
}, [])
77

88
return null
99
}

site/src/pages/components/selectmenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect } from 'preact/hooks'
33
function Page() {
44
useEffect(() => {
55
return history.replace('/get-involved')
6-
})
6+
}, [])
77

88
return null
99
}

0 commit comments

Comments
 (0)