Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type docs for Notices #17206

Merged
merged 3 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions docs/designers-developers/developers/data/data-core-notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _Related_
_Parameters_

- _content_ `string`: Notice message.
- _options_ `?Object`: Optional notice options.
- _options_ `[Object]`: Optional notice options.

_Returns_

Expand All @@ -57,7 +57,7 @@ _Related_
_Parameters_

- _content_ `string`: Notice message.
- _options_ `?Object`: Optional notice options.
- _options_ `[Object]`: Optional notice options.

_Returns_

Expand All @@ -69,14 +69,15 @@ Yields action objects used in signalling that a notice is to be created.

_Parameters_

- _status_ `?string`: Notice status. Defaults to `info`.
- _status_ `[string]`: Notice status.
- _content_ `string`: Notice message.
- _options_ `?Object`: Notice options.
- _options.context_ `?string`: Context under which to group notice.
- _options.id_ `?string`: Identifier for notice. Automatically assigned if not specified.
- _options.isDismissible_ `?boolean`: Whether the notice can be dismissed by user. Defaults to `true`.
- _options.speak_ `?boolean`: Whether the notice content should be announced to screen readers. Defaults to `true`.
- _options.actions_ `?Array<WPNoticeAction>`: User actions to be presented with notice.
- _options_ `[Object]`: Notice options.
- _options.context_ `[string]`: Context under which to group notice.
- _options.id_ `[string]`: Identifier for notice. Automatically assigned if not specified.
- _options.isDismissible_ `[boolean]`: Whether the notice can be dismissed by user.
- _options.type_ `[string]`: Type of notice, one of `default`, or `snackbar`.
- _options.speak_ `[boolean]`: Whether the notice content should be announced to screen readers.
- _options.actions_ `[Array<WPNoticeAction>]`: User actions to be presented with notice.

<a name="createSuccessNotice" href="#createSuccessNotice">#</a> **createSuccessNotice**

Expand All @@ -90,7 +91,7 @@ _Related_
_Parameters_

- _content_ `string`: Notice message.
- _options_ `?Object`: Optional notice options.
- _options_ `[Object]`: Optional notice options.

_Returns_

Expand All @@ -108,7 +109,7 @@ _Related_
_Parameters_

- _content_ `string`: Notice message.
- _options_ `?Object`: Optional notice options.
- _options_ `[Object]`: Optional notice options.

_Returns_

Expand All @@ -121,7 +122,7 @@ Returns an action object used in signalling that a notice is to be removed.
_Parameters_

- _id_ `string`: Notice unique identifier.
- _context_ `?string`: Optional context (grouping) in which the notice is intended to appear. Defaults to default context.
- _context_ `[string]`: Optional context (grouping) in which the notice is intended to appear. Defaults to default context.

_Returns_

Expand Down
59 changes: 29 additions & 30 deletions packages/notices/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';
/**
* Yields action objects used in signalling that a notice is to be created.
*
* @param {?string} status Notice status.
* Defaults to `info`.
* @param {string} content Notice message.
* @param {?Object} options Notice options.
* @param {?string} options.context Context under which to
* group notice.
* @param {?string} options.id Identifier for notice.
* Automatically assigned
* if not specified.
* @param {?boolean} options.isDismissible Whether the notice can
* be dismissed by user.
* Defaults to `true`.
* @param {?boolean} options.speak Whether the notice
* content should be
* announced to screen
* readers. Defaults to
* `true`.
* @param {?Array<WPNoticeAction>} options.actions User actions to be
* presented with notice.
* @param {string} [status='info'] Notice status.
* @param {string} content Notice message.
* @param {Object} [options] Notice options.
* @param {string} [options.context='global'] Context under which to
* group notice.
* @param {string} [options.id] Identifier for notice.
* Automatically assigned
* if not specified.
* @param {boolean} [options.isDismissible=true] Whether the notice can
* be dismissed by user.
* @param {string} [options.type='default'] Type of notice, one of
* `default`, or `snackbar`.
* @param {boolean} [options.speak=true] Whether the notice
* content should be
* announced to screen
* readers.
* @param {Array<WPNoticeAction>} [options.actions] User actions to be
* presented with notice.
*/
export function* createNotice( status = DEFAULT_STATUS, content, options = {} ) {
const {
Expand Down Expand Up @@ -76,8 +75,8 @@ export function* createNotice( status = DEFAULT_STATUS, content, options = {} )
*
* @see createNotice
*
* @param {string} content Notice message.
* @param {?Object} options Optional notice options.
* @param {string} content Notice message.
* @param {Object} [options] Optional notice options.
*
* @return {Object} Action object.
*/
Expand All @@ -91,8 +90,8 @@ export function createSuccessNotice( content, options ) {
*
* @see createNotice
*
* @param {string} content Notice message.
* @param {?Object} options Optional notice options.
* @param {string} content Notice message.
* @param {Object} [options] Optional notice options.
*
* @return {Object} Action object.
*/
Expand All @@ -106,8 +105,8 @@ export function createInfoNotice( content, options ) {
*
* @see createNotice
*
* @param {string} content Notice message.
* @param {?Object} options Optional notice options.
* @param {string} content Notice message.
* @param {Object} [options] Optional notice options.
*
* @return {Object} Action object.
*/
Expand All @@ -121,8 +120,8 @@ export function createErrorNotice( content, options ) {
*
* @see createNotice
*
* @param {string} content Notice message.
* @param {?Object} options Optional notice options.
* @param {string} content Notice message.
* @param {Object} [options] Optional notice options.
*
* @return {Object} Action object.
*/
Expand All @@ -133,9 +132,9 @@ export function createWarningNotice( content, options ) {
/**
* Returns an action object used in signalling that a notice is to be removed.
*
* @param {string} id Notice unique identifier.
* @param {?string} context Optional context (grouping) in which the notice is
* intended to appear. Defaults to default context.
* @param {string} id Notice unique identifier.
* @param {string} [context='global'] Optional context (grouping) in which the notice is
* intended to appear. Defaults to default context.
*
* @return {Object} Action object.
*/
Expand Down
7 changes: 6 additions & 1 deletion packages/notices/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const DEFAULT_NOTICES = [];
* removal without notice.
* @property {boolean} isDismissible Whether the notice can be dismissed by
* user. Defaults to `true`.
* @property {string} type Type of notice, one of `default`,
* or `snackbar`. Defaults to `default`.
* @property {boolean} speak Whether the notice content should be
* announced to screen readers. Defaults to
* `true`.
* @property {WPNoticeAction[]} actions User actions to present with notice.
simono marked this conversation as resolved.
Show resolved Hide resolved
*
*/
Expand All @@ -39,7 +44,7 @@ const DEFAULT_NOTICES = [];
* @property {string} label Message to use as action label.
* @property {?string} url Optional URL of resource if action incurs
* browser navigation.
* @property {?Function} callback Optional function to invoke when action is
* @property {?Function} onClick Optional function to invoke when action is
* triggered by user.
*
*/
Expand Down