diff --git a/src/elements/extensions/toast/index.ts b/src/elements/extensions/toast/index.ts new file mode 100644 index 00000000..8fde7bbc --- /dev/null +++ b/src/elements/extensions/toast/index.ts @@ -0,0 +1 @@ +export { default } from './toast'; diff --git a/src/elements/extensions/toast/toast.css b/src/elements/extensions/toast/toast.css new file mode 100644 index 00000000..db38a3a6 --- /dev/null +++ b/src/elements/extensions/toast/toast.css @@ -0,0 +1,4 @@ +@import '~/styles/build.css'; + +.pa-toast { +} diff --git a/src/elements/extensions/toast/toast.stories.mdx b/src/elements/extensions/toast/toast.stories.mdx new file mode 100644 index 00000000..84c27646 --- /dev/null +++ b/src/elements/extensions/toast/toast.stories.mdx @@ -0,0 +1,127 @@ +import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs'; +import { useTooltipExtension } from '../../../../packages/react/src'; +import { Customization, Codesandbox } from '../../../../.storybook/components'; + + + +export const Template = (args) => ( +
+ {(() => { + useToastExtension(document.body.querySelector('.toast-example')); + return ''; + })()} +
+ + Hover me + +
+
+); + +# Toast + +TODO + +## Showcase + + + + {Template.bind({})} + + + +### Customization + + + +### Properties + + + +## How to use this extension + +### Angular + +Hover me`} +/> + +### Preact + +Hover me`} +/> + +### Qwik + +Hover me`} +/> + +### React + +Hover me`} +/> + +### Solid + +Hover me`} +/> + +### Svelte + +Hover me`} +/> + +### Vue + +Hover me`} +/> + +### Web Components + +Hover me`} +/> diff --git a/src/elements/extensions/toast/toast.ts b/src/elements/extensions/toast/toast.ts new file mode 100644 index 00000000..6c681a08 --- /dev/null +++ b/src/elements/extensions/toast/toast.ts @@ -0,0 +1,32 @@ +import { getDocument } from 'ssr-window'; +import { debug } from '~/helpers'; +import './toast.css'; + +const themes = {}; +const methods = {}; + +function methodFactory(name) { + return () => console.log(1); +} + +function createTheme(name: string) { + const properties = ['background', 'foreground']; + const theme = {}; + + properties.forEach((property) => (theme[property] = `var(--pa-toast-${property}-${name})`)); + + debug(`ToastService createTheme: ${name}: ${JSON.stringify(theme)}`); + + themes[name] = theme; + methods[name] = methodFactory(name); +} + +export default function useTooltipExtension(rootElement?: HTMLElement) { + const document = getDocument(); + const element = rootElement || document.body; + + createTheme('success'); + createTheme('error'); + + return { ...methods }; +} diff --git a/src/index.ts b/src/index.ts index 8c1abade..0aeae2a0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ export { default as Pill } from './elements/components/pill'; export { default as Spinner } from './elements/components/spinner'; export { default as Itchio } from './elements/enterprise/itchio'; export { default as useTooltipExtension } from './elements/extensions/tooltip'; +export { default as useToastExtension } from './elements/extensions/toast'; export { default as Column } from './elements/layout/column'; export { default as Container } from './elements/layout/container'; export { default as Row } from './elements/layout/row';