Skip to content

Commit

Permalink
fix: header poppver
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Sep 13, 2023
1 parent 25d32ca commit 6baeb47
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 46 deletions.
5 changes: 3 additions & 2 deletions src/components/layout/header/internal/HeaderContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { memo } from 'react'
import clsx from 'clsx'
import {
AnimatePresence,
LayoutGroup,
m,
useMotionTemplate,
useMotionValue,
Expand All @@ -23,12 +24,12 @@ import { MenuPopover } from './MenuPopover'

export const HeaderContent = () => {
return (
<>
<LayoutGroup>
<AnimatedMenu>
<ForDesktop />
</AnimatedMenu>
<AccessibleMenu />
</>
</LayoutGroup>
)
}

Expand Down
26 changes: 11 additions & 15 deletions src/components/layout/header/internal/MenuPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@ export const MenuPopover: Component<{
offset={10}
headless
popoverWrapperClassNames="z-[19] relative"
popoverClassNames="rounded-xl !p-0 focus-visible:!shadow-none focus-visible:!ring-0"
popoverClassNames={clsxm([
'select-none rounded-xl bg-white/60 outline-none dark:bg-neutral-900/60',
'shadow-lg shadow-zinc-800/5 border border-zinc-900/5 backdrop-blur-md',
'dark:from-zinc-900/70 dark:to-zinc-800/90 dark:border-zinc-100/10',
'relative flex w-[130px] flex-col py-1',
'focus-visible:!ring-0',
])}
TriggerComponent={TriggerComponent}
>
{!!subMenu.length && (
<div
className={clsxm(
'select-none rounded-xl bg-white/60 outline-none dark:bg-neutral-900/60',
'shadow-lg shadow-zinc-800/5 ring-1 ring-zinc-900/5 backdrop-blur-md',
'dark:from-zinc-900/70 dark:to-zinc-800/90 dark:ring-zinc-100/10',
'relative flex w-[130px] flex-col py-1',
)}
>
{subMenu.map((m) => {
return <Item key={m.title} currentId={currentId} {...m} />
})}
</div>
)}
{!!subMenu.length &&
subMenu.map((m) => {
return <Item key={m.title} currentId={currentId} {...m} />
})}
</FloatPopover>
)
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/float-popover/FloatPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ export const FloatPopover = function FloatPopover<T extends {}>(
return
}
setOpen(false)
}, [debug, animate])
}, [debug])

const doPopoverShow = useEventCallback(() => {
setOpen(true)
})

const handleMouseOut = useCallback(() => {
doPopoverDisappear()
}, [])
}, [doPopoverDisappear])

const listener = useMemo(() => {
const baseListener = {
Expand Down
52 changes: 25 additions & 27 deletions src/components/ui/form/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useMemo, useRef } from 'react'
import { useCallback, useMemo } from 'react'
import { produce } from 'immer'
import { atom } from 'jotai'
import type {
Expand All @@ -24,33 +24,31 @@ export const Form = (
const fieldsAtom = useRefValue(() => atom({}))
return (
<FormContext.Provider
value={
useRef({
showErrorMessage,
fields: fieldsAtom,
getField: (name: string) => {
// @ts-expect-error
return jotaiStore.get(fieldsAtom)[name]
},
addField: (name: string, field: Field) => {
jotaiStore.set(fieldsAtom, (p) => {
return {
...p,
[name]: field,
}
})
},
value={useRefValue(() => ({
showErrorMessage,
fields: fieldsAtom,
getField: (name: string) => {
// @ts-expect-error
return jotaiStore.get(fieldsAtom)[name]
},
addField: (name: string, field: Field) => {
jotaiStore.set(fieldsAtom, (p) => {
return {
...p,
[name]: field,
}
})
},

removeField: (name: string) => {
jotaiStore.set(fieldsAtom, (p) => {
const pp = { ...p }
// @ts-expect-error
delete pp[name]
return pp
})
},
}).current
}
removeField: (name: string) => {
jotaiStore.set(fieldsAtom, (p) => {
const pp = { ...p }
// @ts-expect-error
delete pp[name]
return pp
})
},
}))}
>
<FormConfigContext.Provider
value={useMemo(() => ({ showErrorMessage }), [showErrorMessage])}
Expand Down

1 comment on commit 6baeb47

@vercel
Copy link

@vercel vercel bot commented on 6baeb47 Sep 13, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

shiro – ./

shiro-git-main-innei.vercel.app
springtide.vercel.app
shiro-innei.vercel.app
innei.in

Please sign in to comment.