This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stories include: * Default generic error * API error * Unknown error * Error without possibility to retry * Base Error atom Where applicable, the **Retry** button will not only trigger the appropriate action, but also simulate the loading state of the error component.
- Loading branch information
1 parent
6490f99
commit dba384e
Showing
5 changed files
with
429 additions
and
28 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
assets/js/editor-components/error-placeholder/stories/error-message.tsx
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,27 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Story, Meta } from '@storybook/react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import ErrorMessage, { ErrorMessageProps } from '../error-message'; | ||
|
||
export default { | ||
title: 'WooCommerce Blocks/editor-components/Errors/Base Error Atom', | ||
component: ErrorMessage, | ||
} as Meta< ErrorMessageProps >; | ||
|
||
const Template: Story< ErrorMessageProps > = ( args ) => ( | ||
<ErrorMessage { ...args } /> | ||
); | ||
|
||
export const BaseErrorAtom = Template.bind( {} ); | ||
BaseErrorAtom.args = { | ||
error: { | ||
message: | ||
'A very generic and unhelpful error. Please try again later. Or contact support. Or not.', | ||
type: 'general', | ||
}, | ||
}; |
70 changes: 70 additions & 0 deletions
70
assets/js/editor-components/error-placeholder/stories/error-placeholder.tsx
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,70 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Story, Meta } from '@storybook/react'; | ||
import { useArgs } from '@storybook/client-api'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import ErrorPlaceholder, { ErrorPlaceholderProps } from '..'; | ||
|
||
export default { | ||
title: 'WooCommerce Blocks/editor-components/Errors', | ||
component: ErrorPlaceholder, | ||
} as Meta< ErrorPlaceholderProps >; | ||
|
||
const Template: Story< ErrorPlaceholderProps > = ( args ) => { | ||
const [ { isLoading }, setArgs ] = useArgs(); | ||
|
||
const onRetry = args.onRetry | ||
? () => { | ||
setArgs( { isLoading: true } ); | ||
|
||
setTimeout( () => setArgs( { isLoading: false } ), 3500 ); | ||
} | ||
: undefined; | ||
|
||
return ( | ||
<ErrorPlaceholder | ||
{ ...args } | ||
onRetry={ onRetry } | ||
isLoading={ isLoading } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind( {} ); | ||
Default.args = { | ||
error: { | ||
message: | ||
'A very generic and unhelpful error. Please try again later. Or contact support. Or not.', | ||
type: 'general', | ||
}, | ||
}; | ||
|
||
export const APIError = Template.bind( {} ); | ||
APIError.args = { | ||
error: { | ||
message: 'Server refuses to comply. It is a teapot.', | ||
type: 'api', | ||
}, | ||
}; | ||
|
||
export const UnknownError = Template.bind( {} ); | ||
UnknownError.args = { | ||
error: { | ||
message: '', | ||
type: 'general', | ||
}, | ||
}; | ||
|
||
export const NoRetry: Story< ErrorPlaceholderProps > = ( args ) => { | ||
return <ErrorPlaceholder { ...args } onRetry={ undefined } />; | ||
}; | ||
NoRetry.args = { | ||
error: { | ||
message: '', | ||
type: 'general', | ||
}, | ||
}; |
19 changes: 0 additions & 19 deletions
19
assets/js/editor-components/error-placeholder/stories/index.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.