diff --git a/src/components/flash.scss b/src/components/flash.scss index 035e8b44..6914f25c 100644 --- a/src/components/flash.scss +++ b/src/components/flash.scss @@ -1,21 +1,29 @@ .flash { + display: inline-grid; + grid-auto-flow: column; + justify-content: center; + align-items: center; + gap: var(--rm-space-small); + position: fixed; right: var(--rm-space-large); - display: flex; - align-items: center; top: var(--rm-space-large); - z-index: var(--rm-z-index-alert-group); + animation: rmSlideInOutFlash var(--rm-transition-flash) normal forwards; + width: auto; + + z-index: var(--rm-z-index-alert-group); padding: var(--rm-space-x-small) var(--rm-space-medium); font-size: var(--rm-font-small); - background: var(--rm-color-white); box-shadow: var(--rm-shadow-x-small); border-radius: var(--rm-radius-small); - animation: rmSlideInOutFlash var(--rm-transition-flash) normal forwards; + background: var(--rm-color-background); + color: var(--rm-color-on-background); border-left-width: var(--rm-border-width-x-large); border-left-style: solid; + border-color: var(--rm-color-on-background); } .flash--notice { @@ -40,12 +48,12 @@ .flash__message-type { font-weight: bold; - color: var(--rm-color-black); + color: var(--rm-color-on-background); } .flash__message { font-size: var(--rm-font-x-small); - color: var(--rm-color-black); + color: var(--rm-color-on-background); } .flash--demo { diff --git a/src/stories/Flash.stories.js b/src/stories/Flash.stories.js new file mode 100644 index 00000000..3f04f5da --- /dev/null +++ b/src/stories/Flash.stories.js @@ -0,0 +1,46 @@ +import { createFlash } from './Flash/Flash.js'; +import FlashDocs from './Flash/Flash.mdx'; + +export default { + title: 'Components/Flash', + argTypes: { + label: { control: 'text' }, + style: { + control: { type: 'select' }, + options: ['notice', 'info', 'alert', 'warning'], + }, + }, + parameters: { + docs: { + page: FlashDocs + }, + }, +}; + +const Template = ({ label, ...args }) => { + return createFlash({ label, ...args }); +}; + +export const Notice = Template.bind({}); +Notice.args = { + label: 'Success Message', + style: 'notice', +}; + +export const Info = Template.bind({}); +Info.args = { + label: 'Info Message', + style: 'info', +}; + +export const Alert = Template.bind({}); +Alert.args = { + label: 'Alert Message', + style: 'alert', +}; + +export const Warning = Template.bind({}); +Warning.args = { + label: 'Warning Message', + style: 'warning', +}; diff --git a/src/stories/Flash/Flash.js b/src/stories/Flash/Flash.js new file mode 100644 index 00000000..c19193f9 --- /dev/null +++ b/src/stories/Flash/Flash.js @@ -0,0 +1,36 @@ +import { createIcon } from '../Icon/Icon.js' + +const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1) + +export const createFlash = ({ + label, + style = 'notice', +}) => { + const flash = document.createElement('div'); + + flash.className = [ + 'flash', + 'flash--demo', + `flash--${style}`, + ].filter(Boolean).join(' ') + + const iconMapping = { + 'notice': 'check_circle', + 'info': 'info', + 'alert': 'cancel', + 'warning': 'warning', + } + + flash.innerHTML += "\n " + + flash.appendChild(createIcon({ name: iconMapping[style], size: 'large' })) + + flash.innerHTML += ` +