-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pie-toast-provider): DSW-2222 add priorty order
feat(pie-toast-provider): DSW-2222 add tests feat(pie-toast-provider): DSW-2222 update yarn fix(pie-toast-provider): DSW-2222 update formating fix(pie-toast-provider): DSW-2222 ensure duration is parsed correctly fix(pie-toast-provider): DSW-2222 update markup fix(pie-toast-provider): DSW-2222 update yarn fix(pie-toast-provider): DSW-2222 add validation fix(pie-toast-provider): DSW-2222 update logs fix(pie-toast-provider): DSW-2222 refactor tests fix(pie-toast-provider): DSW-2222 refactor tests fix(pie-toast-provider): DSW-2222 refactor tests
- Loading branch information
Showing
18 changed files
with
606 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@justeattakeaway/pie-toast-provider": minor | ||
"@justeattakeaway/pie-toast": minor | ||
"@justeattakeaway/pie-webc": minor | ||
"pie-storybook": minor | ||
"pie-monorepo": minor | ||
--- | ||
|
||
[Added] - priority order for the toast provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/pie-storybook/stories/testing/pie-toast-provider.test.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { html } from 'lit'; | ||
import { type Meta } from '@storybook/web-components'; | ||
|
||
import '@justeattakeaway/pie-toast-provider'; | ||
import { type ToastProviderProps, defaultProps } from '@justeattakeaway/pie-toast-provider'; | ||
|
||
import { createStory } from '../../utilities'; | ||
|
||
type ToastProviderStoryMeta = Meta<ToastProviderProps>; | ||
|
||
const defaultArgs: ToastProviderProps = { | ||
...defaultProps, | ||
}; | ||
|
||
const toastProviderStoryMeta: ToastProviderStoryMeta = { | ||
title: 'Toast Provider', | ||
component: 'pie-toast-provider', | ||
argTypes: { | ||
options: { | ||
description: 'Default options for all toasts; accepts all toast props.', | ||
control: 'object', | ||
defaultValue: { | ||
summary: defaultProps.options, | ||
}, | ||
}, | ||
}, | ||
args: defaultArgs, | ||
}; | ||
|
||
export default toastProviderStoryMeta; | ||
|
||
const onQueueUpdate = (queue: CustomEvent) => { | ||
console.log('toast provider queue:', queue.detail); | ||
}; | ||
|
||
const Template = ({ options }: ToastProviderProps) => html` | ||
<pie-toast-provider | ||
.options="${options}" | ||
@pie-toast-provider-queue-update="${onQueueUpdate}"> | ||
</pie-toast-provider> | ||
`; | ||
|
||
export const Default = createStory<ToastProviderProps>(Template, defaultArgs)(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,54 @@ | ||
// TODO - please remove the eslint disable comment below when you add props to this interface | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ToastProviderProps {} | ||
import { type ToastProps } from '@justeattakeaway/pie-toast'; | ||
|
||
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core'; | ||
|
||
export const PRIORITY_ORDER: { [x: string]: number } = { | ||
'error-actionable': 1, | ||
error: 2, | ||
'warning-actionable': 3, | ||
'success-actionable': 4, | ||
'info-actionable': 5, | ||
'neutral-actionable': 6, | ||
warning: 7, | ||
success: 8, | ||
info: 9, | ||
neutral: 10, | ||
}; | ||
|
||
export interface ExtendedToastProps extends ToastProps { | ||
/** | ||
* Triggered when the user interacts with the close icon or when the toast auto dismiss. | ||
*/ | ||
onPieToastClose?: () => void; | ||
|
||
/** | ||
* Triggered when the toast is opened. | ||
*/ | ||
onPieToastOpen?: () => void; | ||
|
||
/** | ||
* Triggered when the user interacts with the leading action. | ||
*/ | ||
onPieToastLeadingActionClick?: (event: Event) => void; | ||
} | ||
|
||
export interface ToastProviderProps { | ||
/** | ||
* Default options for all toasts; accepts all toast props. | ||
*/ | ||
options?: Partial<ExtendedToastProps>; | ||
} | ||
|
||
export type DefaultProps = ComponentDefaultProps<ToastProviderProps>; | ||
|
||
export const defaultProps: DefaultProps = { | ||
options: {}, | ||
}; | ||
|
||
/** | ||
* Event name for when the toast provider queue is updated. | ||
* | ||
* @constant | ||
*/ | ||
|
||
export const ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT = 'pie-toast-provider-queue-update'; |
Oops, something went wrong.