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

ProgressBar: Simplify default width implementation and make it more easily overridable #61976

Merged
merged 37 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 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
7a00da3
Allow `ProgressBar` to have unconstrained width, which is disabled by…
fullofcaffeine May 24, 2024
a9c174b
Revert "Allow `ProgressBar` to have unconstrained width, which is dis…
fullofcaffeine May 28, 2024
66e8223
Update docs and add story to illustrate a custom width
fullofcaffeine May 28, 2024
3a95761
Update CHANGELOG
fullofcaffeine May 28, 2024
a076910
Merge branch 'trunk' into improve/progress-bar-width-control
fullofcaffeine May 29, 2024
2454c7a
Simplify description in the story
fullofcaffeine May 29, 2024
981ce6f
Improve jsdoc in story, do not encourage more customization than needed
fullofcaffeine May 29, 2024
67d97df
Inherit the second story from the main template
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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)).
- `ProgressBar`: Simplify default width implementation and make it more easily overridable ([#61976](https://github.com/WordPress/gutenberg/pull/61976)).

### Bug Fixes

Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/progress-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ const MyLoadingComponent = ( { progress } ) => {
};
```

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

```css
.my-custom-progress-bar {
width: 100%;
}
```

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

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

Expand All @@ -52,7 +57,7 @@ If a `value` is not specified, the progress bar will be considered indeterminate

A CSS class to apply to the underlying `div` element, serving as a progress bar track.

- Required: No
- Required: No

#### Inherited props

Expand Down
35 changes: 35 additions & 0 deletions packages/components/src/progress-bar/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,38 @@ const Template: StoryFn< typeof ProgressBar > = ( { ...args } ) => {

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

const withCustomWidthCustomCSS = `
.custom-progress-bar {
width: 100%;
}
`;

/**
* A progress bar with a custom width.
*
* You can override the default `width` by passing a custom CSS class via the
* `className` prop.
*
* This example shows a progress bar with an overriden `width` of `100%` which
* makes it fit all available horizontal space of the parent element. The CSS
* class looks like this:
*
* ```css
* .custom-progress-bar {
* width: 100%;
* }
* ```
*/
export const WithCustomWidth = Template.bind( {} );
WithCustomWidth.args = {
className: 'custom-progress-bar',
};
WithCustomWidth.decorators = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing that's not specific to this PR, but I wonder why we're still using a legacy CSF version, even for new stuff. Haven't checked our current version, but CSF 3 has been supported for the last couple of versions and it makes Storybook much easier to work with. @WordPress/gutenberg-components

Copy link
Member

Choose a reason for hiding this comment

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

We probably should! Nobody hadn't really prioritized it enough.

( Story ) => (
<>
<style>{ withCustomWidthCustomCSS }</style>
<Story />
</>
),
];
6 changes: 4 additions & 2 deletions packages/components/src/progress-bar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const INDETERMINATE_TRACK_WIDTH = 50;
export const Track = styled.div`
position: relative;
overflow: hidden;
width: 100%;
max-width: 160px;
height: ${ CONFIG.borderWidthFocus };
/* Text color at 10% opacity */
background-color: color-mix(
Expand All @@ -38,6 +36,10 @@ export const Track = styled.div`
// Windows high contrast mode.
outline: 2px solid transparent;
outline-offset: 2px;

:where( & ) {
fullofcaffeine marked this conversation as resolved.
Show resolved Hide resolved
width: 160px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not specific to this PR, but is there any reason we're not using rem almost everywhere? It is good practice for proper zoom support, which is an important accessibility feature. @WordPress/gutenberg-components

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 assumed that this was a "that ship has sailed" situation, since WordPress/Gutenberg is already built entirely on a non-rem basis 😓

}
`;

export const Indicator = styled.div< {
Expand Down
Loading