mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
make docs ipv4 banner non-dismissable (#20651)
This commit is contained in:
1 parent
740b06e650
commit
ef643f12dd
2 files changed
+1
-34
No files matched your search
@@ -1,30 +1,9 @@
|
||||
import Link from 'next/link'
|
||||
import { memo, useEffect, useReducer } from 'react'
|
||||
import { memo } from 'react'
|
||||
|
||||
import { Button, IconExternalLink, cn } from 'ui'
|
||||
|
||||
import { LOCAL_STORAGE_KEYS, retrieve, store } from '~/lib/storage'
|
||||
|
||||
const DISMISSAL_STORAGE_KEY = LOCAL_STORAGE_KEYS.IPV4_DEPRECATION_DISMISSAL
|
||||
|
||||
function changeBannerVsibility(_, isVisible: boolean) {
|
||||
if (isVisible) {
|
||||
return true
|
||||
}
|
||||
store('local', DISMISSAL_STORAGE_KEY, 'true')
|
||||
return false
|
||||
}
|
||||
|
||||
export const IPv4DeprecationBanner = memo(() => {
|
||||
const [isBannerVisible, setIsBannerVisible] = useReducer(changeBannerVsibility, false)
|
||||
|
||||
useEffect(() => {
|
||||
const acknowledged = retrieve('local', DISMISSAL_STORAGE_KEY) === 'true'
|
||||
if (!acknowledged) setIsBannerVisible(true)
|
||||
}, [])
|
||||
|
||||
if (!isBannerVisible) return null
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center gap-x-4 bg-surface-100 p-3 transition text-foreground box-border border-b border-default">
|
||||
<p className="text-sm">
|
||||
@@ -44,14 +23,6 @@ export const IPv4DeprecationBanner = memo(() => {
|
||||
>
|
||||
Learn more
|
||||
</Link>
|
||||
<Button
|
||||
type="text"
|
||||
className="sm:hidden opacity-75"
|
||||
aria-hidden="true"
|
||||
onClick={() => setIsBannerVisible(false)}
|
||||
>
|
||||
Dismiss
|
||||
</Button>
|
||||
</p>
|
||||
<div className="max-sm:sr-only sm:flex items-center gap-x-1">
|
||||
<Button asChild type="link" iconRight={<IconExternalLink />}>
|
||||
@@ -63,9 +34,6 @@ export const IPv4DeprecationBanner = memo(() => {
|
||||
Learn more
|
||||
</a>
|
||||
</Button>
|
||||
<Button type="text" className="opacity-75" onClick={() => setIsBannerVisible(false)}>
|
||||
Dismiss
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,7 +2,6 @@ export const LOCAL_STORAGE_KEYS = {
|
||||
SAVED_ORG: 'docs.ui.user.selected.org',
|
||||
SAVED_PROJECT: 'docs.ui.user.selected.project',
|
||||
SAVED_BRANCH: 'docs.ui.user.selected.branch',
|
||||
IPV4_DEPRECATION_DISMISSAL: 'pgbouncer-deprecation-warning-dismissed',
|
||||
} as const
|
||||
|
||||
type LocalStorageKey = (typeof LOCAL_STORAGE_KEYS)[keyof typeof LOCAL_STORAGE_KEYS]
|
||||
|
||||
Reference in new issue
Block a user