mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 19:01:14 +01:00
33 lines
811 B
TypeScript
33 lines
811 B
TypeScript
import classNames from 'classnames';
|
|
import { useKeyValue } from '../../hooks/useKeyValue';
|
|
import type { BannerProps } from './Banner';
|
|
import { Banner } from './Banner';
|
|
import { IconButton } from './IconButton';
|
|
|
|
export function DismissibleBanner({
|
|
children,
|
|
className,
|
|
id,
|
|
...props
|
|
}: BannerProps & { id: string }) {
|
|
const { set: setDismissed, value: dismissed } = useKeyValue<boolean>({
|
|
namespace: 'global',
|
|
key: ['dismiss-banner', id],
|
|
fallback: false,
|
|
});
|
|
|
|
if (dismissed) return null;
|
|
|
|
return (
|
|
<Banner className={classNames(className, 'relative pr-8')} {...props}>
|
|
<IconButton
|
|
className="!absolute right-0 top-0"
|
|
icon="x"
|
|
onClick={() => setDismissed((d) => !d)}
|
|
title="Dismiss message"
|
|
/>
|
|
{children}
|
|
</Banner>
|
|
);
|
|
}
|