overleaf/services/web/frontend/js/shared/components/system-message.tsx
Alf Eaton 8dbf2b64f8 [ide-react] Notify about unsaved changes (#16163)
* Notify about unsaved changes
* Move system message components and types to shared folder
* Add system messages component

GitOrigin-RevId: ab81a24888847bd9a8a390fd1af6b58f471f7a4b
2023-12-15 09:03:27 +00:00

27 lines
548 B
TypeScript

import Close from './close'
import usePersistedState from '../hooks/use-persisted-state'
type SystemMessageProps = {
id: string
children: React.ReactNode
}
function SystemMessage({ id, children }: SystemMessageProps) {
const [hidden, setHidden] = usePersistedState(
`systemMessage.hide.${id}`,
false
)
if (hidden) {
return null
}
return (
<li className="system-message">
{id !== 'protected' ? <Close onDismiss={() => setHidden(true)} /> : null}
{children}
</li>
)
}
export default SystemMessage