mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
8dbf2b64f8
* Notify about unsaved changes * Move system message components and types to shared folder * Add system messages component GitOrigin-RevId: ab81a24888847bd9a8a390fd1af6b58f471f7a4b
27 lines
548 B
TypeScript
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
|