Skip to content

Commit

Permalink
updates here and trhere
Browse files Browse the repository at this point in the history
  • Loading branch information
arzafran committed Sep 12, 2023
1 parent 053a9c8 commit 4e8eba7
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 157 deletions.
2 changes: 0 additions & 2 deletions components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import cn from 'clsx'
import { Navigation } from 'components/navigation'
import { useStore } from 'libs/store'
import { forwardRef } from 'react'
import { shallow } from 'zustand/shallow'
import s from './header.module.scss'

export const Header = forwardRef((_, ref) => {
const [navIsOpened, setNavIsOpened] = useStore(
({ navIsOpened, setNavIsOpened }) => [navIsOpened, setNavIsOpened],
shallow
)

return (
Expand Down
2 changes: 0 additions & 2 deletions components/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import cn from 'clsx'
import { useStore } from 'libs/store'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { shallow } from 'zustand/shallow'
import s from './navigation.module.scss'

export function Navigation() {
const [navIsOpened, setNavIsOpened] = useStore(
({ navIsOpened, setNavIsOpened }) => [navIsOpened, setNavIsOpened],
shallow
)

const router = useRouter()
Expand Down
26 changes: 15 additions & 11 deletions libs/orchestra/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { del, get, set } from 'idb-keyval'
import { broadcast } from 'libs/zustand-broadcast'
import dynamic from 'next/dynamic'
import { useEffect } from 'react'
import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
import { shallow } from 'zustand/shallow'
import { createWithEqualityFn } from 'zustand/traditional'
import s from './orchestra.module.scss'

const Studio = dynamic(
() => import('libs/theatre/studio').then(({ Studio }) => Studio),
{ ssr: false }
{ ssr: false },
)
const Stats = dynamic(() => import('./stats').then(({ Stats }) => Stats), {
ssr: false,
Expand All @@ -19,14 +19,17 @@ const GridDebugger = dynamic(
() => import('./grid').then(({ GridDebugger }) => GridDebugger),
{
ssr: false,
}
},
)

// avoid to display debug tools on orchestra page
const useInternalStore = create((set) => ({
isVisible: true,
setIsVisible: (isVisible) => set({ isVisible }),
}))
const useInternalStore = createWithEqualityFn(
(set) => ({
isVisible: true,
setIsVisible: (isVisible) => set({ isVisible }),
}),
shallow,
)

// https://github.com/pmndrs/zustand/blob/main/docs/integrations/persisting-store-data.md
const INDEXEDDB_STORAGE = {
Expand All @@ -44,7 +47,7 @@ const INDEXEDDB_STORAGE = {
},
}

export const useOrchestraStore = create(
export const useOrchestraStore = createWithEqualityFn(
persist(
() => ({
studio: false,
Expand All @@ -54,8 +57,9 @@ export const useOrchestraStore = create(
{
name: 'orchestra',
storage: createJSONStorage(() => INDEXEDDB_STORAGE),
}
)
},
),
shallow,
)

broadcast(useOrchestraStore, 'orchestra')
Expand All @@ -65,7 +69,7 @@ export function Orchestra() {

const { studio, stats, grid } = useOrchestraStore(
({ studio, stats, grid }) => ({ studio, stats, grid }),
shallow
shallow,
)

return (
Expand Down
26 changes: 15 additions & 11 deletions libs/store.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { create } from 'zustand'
import { shallow } from 'zustand/shallow'
import { createWithEqualityFn } from 'zustand/traditional'

export const useStore = create((set) => ({
headerData: undefined,
setHeaderData: (headerData) => set({ headerData }),
footerData: undefined,
setFooterData: (footerData) => set({ footerData }),
navIsOpened: false,
setNavIsOpened: (value) => set({ navIsOpened: value }),
triggerTransition: false,
setTriggerTransition: (triggerTransition) => set({ triggerTransition }),
}))
export const useStore = createWithEqualityFn(
(set) => ({
headerData: undefined,
setHeaderData: (headerData) => set({ headerData }),
footerData: undefined,
setFooterData: (footerData) => set({ footerData }),
navIsOpened: false,
setNavIsOpened: (value) => set({ navIsOpened: value }),
triggerTransition: false,
setTriggerTransition: (triggerTransition) => set({ triggerTransition }),
}),
shallow,
)
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "^9.5.0",
"@studio-freight/compono": "^0.0.37",
"@studio-freight/compono": "^0.0.40",
"@studio-freight/hamo": "^0.6.19",
"@studio-freight/react-lenis": "0.0.26",
"@studio-freight/react-lenis": "0.0.28",
"@studio-freight/tempus": "^0.0.38",
"@theatre/core": "^0.7.0",
"@theatre/studio": "^0.7.0",
Expand All @@ -25,26 +25,26 @@
"idb-keyval": "^6.2.1",
"jsonminify": "^0.4.2",
"next": "13.4.19",
"next-sitemap": "^4.2.2",
"next-sitemap": "^4.2.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"sass": "^1.66.1",
"stats.js": "^0.17.0",
"zustand": "4.4.1"
},
"devDependencies": {
"@builder.io/partytown": "^0.8.0",
"@cerner/duplicate-package-checker-webpack-plugin": "^2.3.0",
"@builder.io/partytown": "^0.8.1",
"@cerner/duplicate-package-checker-webpack-plugin": "^2.5.0",
"@next/bundle-analyzer": "^13.4.19",
"@size-limit/preset-app": "^8.2.6",
"@size-limit/preset-app": "^9.0.0",
"@svgr/webpack": "^8.1.0",
"critters": "^0.0.20",
"cross-env": "^7.0.3",
"eslint": "8.47.0",
"eslint": "8.49.0",
"eslint-config-next": "^13.4.19",
"eslint-config-prettier": "^9.0.0",
"husky": "^8.0.3",
"prettier": "^3.0.2",
"prettier": "^3.0.3",
"prettier-eslint": "^15.0.1"
},
"lint-staged": {
Expand Down
Loading

1 comment on commit 4e8eba7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"⚡️ Lighthouse report for the changes in this commit:

🟢 Performance: 100
🟢 Accessibility: 97
🟢 Best practices: 100
🟠 SEO: 83
🟢 PWA: 90

Lighthouse ran on https://satus-dyyn25eus-studio-freight.vercel.app/"

Please sign in to comment.