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

[Progress] New Progress components #470

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Jun 28, 2024

@mj12albert mj12albert added new feature New feature or request component: progress This is the name of the generic UI component, not the React module! labels Jun 28, 2024
@mj12albert mj12albert force-pushed the feat/progress-component branch from 9a8691b to 8426306 Compare June 28, 2024 06:16
@mui-bot
Copy link

mui-bot commented Jun 28, 2024

Netlify deploy preview

https://deploy-preview-470--base-ui.netlify.app/

Generated by 🚫 dangerJS against 752a574

@mj12albert mj12albert force-pushed the feat/progress-component branch 2 times, most recently from 18f24f1 to 4a3e1a1 Compare July 1, 2024 09:21
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 2, 2024
@mj12albert mj12albert force-pushed the feat/progress-component branch from 4a3e1a1 to 695fad0 Compare July 4, 2024 05:23
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 4, 2024
@mj12albert mj12albert force-pushed the feat/progress-component branch 13 times, most recently from 9186d7e to 7fef12c Compare July 9, 2024 07:02
@mj12albert
Copy link
Member Author

@colmtuite The implementation is complete, what do you think about the demos?
I will add the Tailwind/css variants to the intro demo if you're OK with it like this, not sure if you want to animate it or something like that.

@mj12albert mj12albert marked this pull request as ready for review July 9, 2024 08:56
@mj12albert mj12albert force-pushed the feat/progress-component branch from 7fef12c to f07c004 Compare July 9, 2024 09:21
export function Styles() {
const isDarkMode = useIsDarkMode();
return (
<style suppressHydrationWarning>{`
Copy link
Member

Choose a reason for hiding this comment

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

What this suppression for? If there are differences due to encoding of some characters, try <style dangerouslySetInnerHTML={{ __html: '' }} />

Copy link
Member Author

Choose a reason for hiding this comment

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

It was for some encoding issue, but I've fixed the root cause now 😅

* The direction that progress bars fill in
* @default 'ltr'
*/
direction?: ProgressDirection;
Copy link
Member

Choose a reason for hiding this comment

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

We use dir elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

The prop is 'direction' ~ e.g. Tabs: https://master--base-ui.netlify.app/base-ui/react-tabs/components-api/#tabs-root-prop-direction

'dir' is the attribute set on the elements via 'direction' 😬

Copy link
Member

Choose a reason for hiding this comment

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

I must have been hallucinating, then, sorry! :)

/**
* @ignore - internal component.
*/
export const ProgressContext = React.createContext<ProgressContextValue | undefined>(undefined);
Copy link
Member

Choose a reason for hiding this comment

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

It's possible to use the same name for the const and its type:

Suggested change
export const ProgressContext = React.createContext<ProgressContextValue | undefined>(undefined);
export const ProgressContext = React.createContext<ProgressContext | undefined>(undefined);

Copy link
Member Author

Choose a reason for hiding this comment

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

@michaldudak How can this work? 🤔 I get an error...
All our other components have XXXContextValue as the type name, e.g. export const PopoverContext = React.createContext<PopoverRootContextValue | null>(null)

Copy link
Member

Choose a reason for hiding this comment

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

OK, let's leave it as it is. I'm trying out a different approach in #468. If we decide to adopt it, I'll change all the occurences.


let state: ProgressStatus = 'indeterminate';
if (Number.isFinite(value)) {
state = value === max ? 'complete' : 'loading';
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about "loading". The progress bar doesn't have to show the loading process. Perhaps 'in-progress' | 'complete'? (plus | 'not-started' for completeness)

Copy link
Member Author

@mj12albert mj12albert Jul 22, 2024

Choose a reason for hiding this comment

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

Good idea renaming 'loading' to 'in-progress', it's closer to the component's name and a bit more flexible (e.g. it could represent "uploading")
But for 'not-started', I think we can't really differentiate that with 'in-progress' - 0% could mean a process has started, but no progress has been made yet (or so little that it rounds down to 0%)

Copy link
Member

Choose a reason for hiding this comment

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

IMO you could make the same argument for complete - it could be 99.9% rounded up to 100%. But I don't insist. Probably best to see with @colmtuite if this third state could be useful for styling.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have decided on: 'indeterminate' | 'progressing' | 'complete'

@mj12albert mj12albert force-pushed the feat/progress-component branch from f07c004 to 6ef9e31 Compare July 22, 2024 06:47
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 23, 2024
@mj12albert mj12albert force-pushed the feat/progress-component branch from 6ef9e31 to fca034d Compare July 25, 2024 06:04
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 25, 2024
@mj12albert mj12albert force-pushed the feat/progress-component branch 2 times, most recently from 10021b0 to 60c14c1 Compare July 26, 2024 07:46
@mj12albert mj12albert force-pushed the feat/progress-component branch from 60c14c1 to bda349d Compare July 26, 2024 08:11
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

LGTM!

@colmtuite
Copy link
Contributor

@mj12albert What's the purpose of having 3 parts to this component, rather than just Root and Indicator?

@mj12albert
Copy link
Member Author

@mj12albert What's the purpose of having 3 parts to this component, rather than just Root and Indicator?

@colmtuite Though this isn't a form control, it's still label-able and I thought its more consistent to recommend placing the label inside the root like other components
With a structure like that, it's inconvenient to style the root to look like the track, so the Track subcomponent is really to avoid having to use a pseudoelement like for slider:

<Progress.Root>
  <Label>Label text</Label>
  <Progress.Indicator />
</Progress.Root>

What do you think?

@mj12albert mj12albert merged commit 0e60b91 into mui:master Jul 30, 2024
18 checks passed
@mj12albert mj12albert deleted the feat/progress-component branch July 30, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: progress This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Progress] Implement Progress
4 participants