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

Components: Make the ProgressBar public #61062

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
023e5c4
Remove "experimental" designation for `ProgressBar`
fullofcaffeine Apr 19, 2024
b1fe7cd
Add optional width prop to override/set the progress bar track container
fullofcaffeine Apr 25, 2024
fe9129d
Revert "Add optional width prop to override/set the progress bar trac…
fullofcaffeine May 22, 2024
64c72e2
Keep an unconstrained width by default, while allowing consumers to o…
fullofcaffeine May 22, 2024
c88ece0
Revert "Keep an unconstrained width by default, while allowing consum…
fullofcaffeine May 24, 2024
ad0fff9
Make the component public
fullofcaffeine May 24, 2024
dc299ed
Update consumers to import the public component
fullofcaffeine May 24, 2024
4c0b8fd
Expose docs for the now public ProgressBar component
fullofcaffeine May 24, 2024
0ff6637
Update CHANGELOG
fullofcaffeine May 24, 2024
ad2fd28
Merge branch 'trunk' into remove/wp-components-experimental-designati…
fullofcaffeine May 24, 2024
adf39a1
Run docs:build after docs/manifest.js change
fullofcaffeine May 24, 2024
ceb2840
Merge branch 'trunk' into remove/wp-components-experimental-designati…
fullofcaffeine May 24, 2024
9b3db94
Remove remaining private usage of ProgressBar
fullofcaffeine May 24, 2024
a219fa8
Small formatting fix in the changelog
fullofcaffeine May 24, 2024
1d22f24
Add basic docs to the README
fullofcaffeine May 24, 2024
b096ca4
Add jsdoc
fullofcaffeine May 24, 2024
3af0985
Formatting fix in README jsx block
fullofcaffeine May 27, 2024
846ccc0
Another formatting fix in README jsx block
fullofcaffeine May 27, 2024
39b92a5
YAFF (yet another formatting fix) in the README jsx
fullofcaffeine May 27, 2024
3241379
Improve wording in descripton of the `value` prop in the README
fullofcaffeine May 27, 2024
ff982fb
YAFF: Missing semicolon in README jsx
fullofcaffeine May 27, 2024
b0eca3f
YAFF: missing semicolon in jsx block in README
fullofcaffeine May 27, 2024
59d46cc
YAFF: missing semicolon in jsx block in README
fullofcaffeine May 27, 2024
0832e40
YAFF: use tab instead of spaces in jsx code block in README
fullofcaffeine May 27, 2024
5ca947a
Move export out of the HOC export section
fullofcaffeine May 27, 2024
47183b7
Fix CHANGELOG: Move entry to the existing enhacements section
fullofcaffeine May 27, 2024
eed1dba
Merge branch 'trunk' into remove/wp-components-experimental-designati…
fullofcaffeine May 27, 2024
d132170
Spacing fix
fullofcaffeine May 28, 2024
43e1a57
Sort import alphabetically
fullofcaffeine May 28, 2024
c0bd79d
Simplify CHANGELOG entry
fullofcaffeine May 29, 2024
2f978f4
Re-export as default for visual consistency
fullofcaffeine May 29, 2024
433d249
Merge branch 'trunk' into remove/wp-components-experimental-designati…
fullofcaffeine May 29, 2024
1b4dc84
Merge branch 'trunk' into remove/wp-components-experimental-designati…
fullofcaffeine May 29, 2024
17b0d30
Improve jsdoc comment: make it fit within ~80chars of char lenght and…
fullofcaffeine May 29, 2024
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
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,12 @@
"markdown_source": "../packages/components/src/popover/README.md",
"parent": "components"
},
{
"title": "ProgressBar",
"slug": "progress-bar",
"markdown_source": "../packages/components/src/progress-bar/README.md",
"parent": "components"
},
{
"title": "QueryControls",
"slug": "query-controls",
Expand Down
1 change: 0 additions & 1 deletion docs/tool/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const componentPaths = glob( 'packages/components/src/*/**/README.md', {
'packages/components/src/theme/README.md',
'packages/components/src/view/README.md',
'packages/components/src/dropdown-menu-v2/README.md',
'packages/components/src/progress-bar/README.md',
'packages/components/src/tabs/README.md',
'packages/components/src/custom-select-control-v2/README.md',
],
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- `Tabs`: Animate indicator ([#60560](https://github.com/WordPress/gutenberg/pull/60560)).
- `ComboboxControl`: Introduce Combobox expandOnFocus prop ([#61705](https://github.com/WordPress/gutenberg/pull/61705)).
- `ProgressBar`: Expose as public API ([#61062](https://github.com/WordPress/gutenberg/pull/61062)).

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export { default as PanelHeader } from './panel/header';
export { default as PanelRow } from './panel/row';
export { default as Placeholder } from './placeholder';
export { default as Popover } from './popover';
export { default as ProgressBar } from './progress-bar';
export { default as QueryControls } from './query-controls';
export { default as __experimentalRadio } from './radio-group/radio';
export { default as __experimentalRadioGroup } from './radio-group';
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/private-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from './composite/v2';
import { default as CustomSelectControl } from './custom-select-control';
import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
import { default as ProgressBar } from './progress-bar';
import { createPrivateSlotFill } from './slot-fill';
import {
DropdownMenu as DropdownMenuV2,
Expand Down Expand Up @@ -44,7 +43,6 @@ lock( privateApis, {
__experimentalPopoverLegacyPositionToPlacement,
createPrivateSlotFill,
ComponentsContext,
ProgressBar,
Tabs,
Theme,
DropdownMenuV2,
Expand Down
37 changes: 33 additions & 4 deletions packages/components/src/progress-bar/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
# ProgressBar

<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>
fullofcaffeine marked this conversation as resolved.
Show resolved Hide resolved

A simple horizontal progress bar component.

Supports two modes: determinate and indeterminate. A progress bar is determinate when a specific progress value has been specified (from 0 to 100), and indeterminate when a value hasn't been specified.

## Usage
fullofcaffeine marked this conversation as resolved.
Show resolved Hide resolved

Basic usage:

```jsx
import { ProgressBar } from '@wordpress/components';

const MyLoadingComponent = () => {
return <ProgressBar />;
};
```

You can also make it determinate by passing a `value` (from 0 to 100) representing the progress:

```jsx
import { ProgressBar } from '@wordpress/components';

const MyLoadingComponent = ( { progress } ) => {
return <ProgressBar value={ progress } />;
};
```

You can customize its appearance by passing a custom CSS class name to `className`:


```jsx
import { ProgressBar } from '@wordpress/components';

const MyLoadingComponent = () => {
return <ProgressBar className="my-custom-css-class" />;
};
```

### Props

The component accepts the following props:
Expand Down
15 changes: 15 additions & 0 deletions packages/components/src/progress-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ function UnforwardedProgressBar(
);
}

/**
* A simple horizontal progress bar component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always felt we duplicate so much README and add overhead for maintaining these docs in the future 😕 I wonder if we can improve/automate that somehow - perhaps a command to allow the README to inherit content from here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial plans were to abandon the manual readmes altogether once the Storybook was "complete" with all the type data and documentation. I do consider it pretty much complete now. But @DaniGuardiola mentioned some kind of TSDoc to markdown docgen he has up his sleeve, so that could be another option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It would be fun to try something like this out here @DaniGuardiola 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I share the non-DRY feelings here, too. A way to extract and keep everything from/in a central place would be nice 👍🏻

*
* Supports two modes: determinate and indeterminate. A progress bar is determinate
* when a specific progress value has been specified (from 0 to 100), and indeterminate
* when a value hasn't been specified.
*
* ```jsx
* import { ProgressBar } from '@wordpress/components';
*
* const MyLoadingComponent = () => {
* return <ProgressBar />;
* };
* ```
*/
export const ProgressBar = forwardRef( UnforwardedProgressBar );

export default ProgressBar;
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { ProgressBar } from '..';

const meta: Meta< typeof ProgressBar > = {
component: ProgressBar,
title: 'Components (Experimental)/ProgressBar',
title: 'Components/ProgressBar',
argTypes: {
value: { control: { type: 'number', min: 0, max: 100, step: 1 } },
},
tags: [ 'status-private' ],
parameters: {
controls: {
expanded: true,
Expand Down
7 changes: 5 additions & 2 deletions packages/edit-site/src/components/canvas-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { privateApis as componentsPrivateApis } from '@wordpress/components';
import {
privateApis as componentsPrivateApis,
ProgressBar,
} from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';

Expand All @@ -12,7 +15,7 @@ import { useSelect } from '@wordpress/data';
import { unlock } from '../../lock-unlock';
import { useStylesPreviewColors } from '../global-styles/hooks';

const { ProgressBar, Theme } = unlock( componentsPrivateApis );
const { Theme } = unlock( componentsPrivateApis );
const { useGlobalStyle } = unlock( blockEditorPrivateApis );

export default function CanvasLoader( { id } ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
Button,
DropdownMenu,
SearchControl,
privateApis as componentsPrivateApis,
ProgressBar,
} from '@wordpress/components';
import { debounce } from '@wordpress/compose';
import { sprintf, __, _x } from '@wordpress/i18n';
Expand All @@ -45,8 +45,6 @@ import GoogleFontsConfirmDialog from './google-fonts-confirm-dialog';
import { downloadFontFaceAssets } from './utils';
import { sortFontFaces } from './utils/sort-font-faces';
import CollectionFontVariant from './collection-font-variant';
import { unlock } from '../../../lock-unlock';
const { ProgressBar } = unlock( componentsPrivateApis );

const DEFAULT_CATEGORY = {
slug: 'all',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
__experimentalVStack as VStack,
Flex,
Notice,
privateApis as componentsPrivateApis,
ProgressBar,
} from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
Expand All @@ -26,12 +26,10 @@ import { chevronLeft } from '@wordpress/icons';
/**
* Internal dependencies
*/
import { unlock } from '../../../lock-unlock';
import { FontLibraryContext } from './context';
import FontCard from './font-card';
import LibraryFontVariant from './library-font-variant';
import { sortFontFaces } from './utils/sort-font-faces';
const { ProgressBar } = unlock( componentsPrivateApis );

function InstalledFonts() {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Notice,
FormFileUpload,
FlexItem,
privateApis as componentsPrivateApis,
ProgressBar,
} from '@wordpress/components';
import { useContext, useState } from '@wordpress/element';

Expand All @@ -23,9 +23,6 @@ import { FontLibraryContext } from './context';
import { Font } from '../../../../lib/lib-font.browser';
import makeFamiliesFromFaces from './utils/make-families-from-faces';
import { loadFontFaceInBrowser } from './utils';
import { unlock } from '../../../lock-unlock';

const { ProgressBar } = unlock( componentsPrivateApis );

function UploadFonts() {
const { installFonts, notice, setNotice } =
Expand Down
1 change: 1 addition & 0 deletions storybook/manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'navigation',
'customselectcontrol-v2',
'theme',
'progressbar',
];
const REDIRECTS = [
{
Expand Down
Loading