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

Shortcut: Add Storybook stories #53627

Merged
merged 3 commits into from
Aug 24, 2023
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
7 changes: 3 additions & 4 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
### Enhancements

- Make the `Popover.Slot` optional and render popovers at the bottom of the document's body by default. ([#53889](https://github.com/WordPress/gutenberg/pull/53889)).
- `ProgressBar`: Add transition to determinate indicator ([#53877](https://github.com/WordPress/gutenberg/pull/53877)).

### Bug Fix

- `SandBox`: Fix the cleanup method in useEffect ([#53796](https://github.com/WordPress/gutenberg/pull/53796)).

### Internal
- `SlotFill`: Do not render children when using `<Slot bubblesVirtually />`. ([#53272](https://github.com/WordPress/gutenberg/pull/53272))

### Enhancements

- `ProgressBar`: Add transition to determinate indicator ([#53877](https://github.com/WordPress/gutenberg/pull/53877)).
- `Shortcut`: Add Storybook stories ([#53627](https://github.com/WordPress/gutenberg/pull/53627)).
- `SlotFill`: Do not render children when using `<Slot bubblesVirtually />`. ([#53272](https://github.com/WordPress/gutenberg/pull/53272))

## 25.6.0 (2023-08-16)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function UnconnectedItemGroup(
/**
* `ItemGroup` displays a list of `Item`s grouped and styled together.
*
* @example
* ```jsx
* import {
* __experimentalItemGroup as ItemGroup,
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/item-group/item/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function UnconnectedItem(
* `Item` is used in combination with `ItemGroup` to display a list of items
* grouped and styled together.
*
* @example
* ```jsx
* import {
* __experimentalItemGroup as ItemGroup,
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const noop = () => {};
/**
* Render a navigation list with optional groupings and hierarchy.
*
* @example
* ```jsx
* import {
* __experimentalNavigation as Navigation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ function UnconnectedNavigatorProvider(
* view (via the `NavigatorButton` and `NavigatorBackButton` components or the
* `useNavigator` hook).
*
* @example
* ```jsx
* import {
* __experimentalNavigatorProvider as NavigatorProvider,
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/shortcut/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
*/
import type { ShortcutProps } from './types';

/**
* Shortcut component is used to display keyboard shortcuts, and it can be customized with a custom display and aria label if needed.
*
* ```jsx
* import { Shortcut } from '@wordpress/components';
*
* const MyShortcut = () => {
* return (
* <Shortcut shortcut={{ display: 'Ctrl + S', ariaLabel: 'Save' }} />
* );
* };
* ```
*/
function Shortcut( props: ShortcutProps ) {
const { shortcut, className } = props;

Expand Down
33 changes: 33 additions & 0 deletions packages/components/src/shortcut/stories/index.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import type { Meta, StoryFn } from '@storybook/react';

/**
* Internal dependencies
*/
import Shortcut from '../';

const meta: Meta< typeof Shortcut > = {
component: Shortcut,
title: 'Components/Shortcut',
parameters: {
controls: {
expanded: true,
},
docs: { canvas: { sourceState: 'shown' } },
},
};
export default meta;

const Template: StoryFn< typeof Shortcut > = ( props ) => {
return <Shortcut shortcut="Ctrl + S" { ...props } />;
};

export const Default: StoryFn< typeof Shortcut > = Template.bind( {} );

export const WithAriaLabel = Template.bind( {} );
WithAriaLabel.args = {
...Default.args,
shortcut: { display: 'Ctrl + L', ariaLabel: 'Load' },
};
1 change: 0 additions & 1 deletion packages/components/src/spinner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function UnforwardedSpinner(
/**
* `Spinner` is a component used to notify users that their action is being processed.
*
* @example
* ```js
* import { Spinner } from '@wordpress/components';
*
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useCx } from '../utils';
* Multiple `Theme` components can be nested in order to override specific theme variables.
*
*
* @example
* ```jsx
* const Example = () => {
* return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const UnconnectedToolsPanel = (
* by a header. The header includes a dropdown menu which is automatically
* generated from the panel's inner `ToolsPanelItems`.
*
* @example
* ```jsx
* import { __ } from '@wordpress/i18n';
* import {
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function getSelectOptions(
/**
* TreeSelect component is used to generate select input fields.
*
* @example
* ```jsx
* import { TreeSelect } from '@wordpress/components';
* import { useState } from '@wordpress/element';
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/unit-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ function UnforwardedUnitControl(
* `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).
*
*
* @example
* ```jsx
* import { __experimentalUnitControl as UnitControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/utils/hooks/use-cx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const isSerializedStyles = ( o: any ): o is SerializedStyles =>
* `cx` normally knows how to handle. It also hooks into the Emotion
* Cache, allowing `css` calls to work inside iframes.
*
* @example
* ```jsx
* import { css } from '@emotion/react';
*
* const styles = css`
Expand All @@ -39,6 +39,7 @@ const isSerializedStyles = ( o: any ): o is SerializedStyles =>
*
* return <span className={classes} {...props} />;
* }
* ```
*/
export const useCx = () => {
const cache = useEmotionCache();
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/view/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { ViewProps } from './types';
* `View` is a core component that renders everything in the library.
* It is the principle component in the entire library.
*
* @example
* ```jsx
* import { View } from `@wordpress/components`;
*
Expand Down