Skip to content

Commit

Permalink
fix turnstile display
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Dec 30, 2023
1 parent 2ad665f commit ddfe908
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions @web/providers/turnstile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,41 @@ export function TurnstileProvider(props: { children: React.ReactNode }) {
return (
<>
{props.children}
<Portal.Root>
<div
className={cn(
'fixed top-0 left-0 right-0 bottom-0 z-[99999] flex items-center justify-center bg-background/80',
{
'top-[100%] bottom-[-100%]': !turnstileStore.isShowChallenge,
},
)}
>
<Turnstile
ref={turnstileRef}
id={id}
siteKey={env.TURNSTILE_SITE_KEY}
options={{
theme: systemStore.theme === 'system' ? 'auto' : systemStore.theme,
}}
onSuccess={(token) => {
useTurnstileStore.setState(() => ({
token,
instance: turnstileRef.current,
}))
}}
onError={() => {
useTurnstileStore.setState(() => ({
token: null,
instance: turnstileRef.current,
}))
}}
onExpire={() => {
useTurnstileStore.setState(() => ({
token: null,
instance: turnstileRef.current,
}))
turnstileRef.current?.reset()
}}
/>
</div>
<Portal.Root
className={cn(
'pointer-events-auto fixed top-0 left-0 right-0 bottom-0 z-[99999] flex items-center justify-center bg-background/80',
{
'top-[100%] bottom-[-100%]': !turnstileStore.isShowChallenge,
},
)}
>
<Turnstile
ref={turnstileRef}
id={id}
siteKey={env.TURNSTILE_SITE_KEY}
options={{
theme: systemStore.theme === 'system' ? 'auto' : systemStore.theme,
}}
onSuccess={(token) => {
useTurnstileStore.setState(() => ({
token,
instance: turnstileRef.current,
}))
}}
onError={() => {
useTurnstileStore.setState(() => ({
token: null,
instance: turnstileRef.current,
}))
}}
onExpire={() => {
useTurnstileStore.setState(() => ({
token: null,
instance: turnstileRef.current,
}))
turnstileRef.current?.reset()
}}
/>
</Portal.Root>
</>
)
Expand Down

0 comments on commit ddfe908

Please sign in to comment.