File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
apps/builder/app/builder/features/blocking-alerts Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 1+ import { atom } from "nanostores" ;
2+ import { useStore } from "@nanostores/react" ;
13import type { ReactNode } from "react" ;
24import {
5+ Button ,
36 css ,
47 Flex ,
58 Popover ,
@@ -23,7 +26,19 @@ const contentStyle = css({
2326 color : theme . colors . foregroundDestructive ,
2427} ) ;
2528
26- export const Alert = ( { message } : { message : string | ReactNode } ) => {
29+ const $isAlertDismissed = atom ( false ) ;
30+
31+ export const Alert = ( {
32+ message,
33+ isDismissable,
34+ } : {
35+ message : string | ReactNode ;
36+ isDismissable ?: boolean ;
37+ } ) => {
38+ const isAlertDismissed = useStore ( $isAlertDismissed ) ;
39+ if ( isAlertDismissed ) {
40+ return ;
41+ }
2742 return (
2843 < Popover open >
2944 < PopoverContent css = { { zIndex : theme . zIndices . max } } >
@@ -38,6 +53,14 @@ export const Alert = ({ message }: { message: string | ReactNode }) => {
3853 < Text color = "contrast" align = "center" >
3954 { message }
4055 </ Text >
56+ { isDismissable && (
57+ < Button
58+ color = "destructive"
59+ onClick = { ( ) => $isAlertDismissed . set ( true ) }
60+ >
61+ Dismiss
62+ </ Button >
63+ ) }
4164 </ Flex >
4265 </ Flex >
4366 </ PopoverContent >
Original file line number Diff line number Diff line change @@ -93,8 +93,9 @@ export const BlockingAlerts = () => {
9393 const isPreviewMode = useStore ( $isPreviewMode ) ;
9494 const loadingState = useStore ( $loadingState ) ;
9595
96+ const unsupportedBrowsersMessage = useUnsupportedBrowser ( ) ;
9697 // Takes the latest message, order matters
97- const message = [ useTooSmallMessage ( ) , useUnsupportedBrowser ( ) ]
98+ const message = [ useTooSmallMessage ( ) , unsupportedBrowsersMessage ]
9899 . filter ( Boolean )
99100 . pop ( ) ;
100101
@@ -107,5 +108,10 @@ export const BlockingAlerts = () => {
107108 return ;
108109 }
109110
110- return < Alert message = { message } /> ;
111+ return (
112+ < Alert
113+ message = { message }
114+ isDismissable = { unsupportedBrowsersMessage !== undefined }
115+ />
116+ ) ;
111117} ;
You can’t perform that action at this time.
0 commit comments