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

Fixes #692-Add_progress_bar_visual_element #1294

Conversation

yaten2302
Copy link
Contributor

Fixes #692

About

This PR creates a new visual element - Progress Bar (linear and circular). Currently this issue is being worked upon, this is only a draft for the review by the maintainers.

Copy link
Member

@FredLL-Avaiga FredLL-Avaiga left a comment

Choose a reason for hiding this comment

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

Good start 👍

frontend/taipy-gui/src/components/Taipy/ProgressBar.tsx Outdated Show resolved Hide resolved
}, [props.linear, linear]);

return (
<>
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you talking about the parenthesis <>?

Copy link
Member

Choose a reason for hiding this comment

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

Yes the react.fragment (<>)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But, without <>, I don't think that the element will be renderd? So, instead of <>, should I enclose it within the <Box>?

Copy link
Member

Choose a reason for hiding this comment

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

it will render

return (
<>
{value == true ? (
<Box sx={{ width: "100%" }}>
Copy link
Member

Choose a reason for hiding this comment

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

I suppose we want to be able to have 2 progress bars side by side without layout
Maybe use a span instead of a Box/div ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I'm not able to understand this completely. Like are you saying about that if the user wants to have 2 or more progress bars, for that I've to change, right?

Copy link
Member

Choose a reason for hiding this comment

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

yes if the declaration is <|progress|><|progress|>, the user wants to see 2 progress bars side by side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose we want to be able to have 2 progress bars side by side without layout Maybe use a span instead of a Box/div ?

But, in the official doc of MUi, it's given that we've to use <Box>. Will it render the same element if we use <Span> instead?

Copy link
Member

Choose a reason for hiding this comment

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

You don't need a <span> I would say.
Simply render the <Box> as is (without the useless fragment) and it should be ok.
You could easily test that in a React-supported Codepen, creating two of these next to each other...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ig my current PR is having a lot of bugs😢I'll create a new one instead and add the necessary changes👍🏼Apologies for inconvenience

Copy link
Member

Choose a reason for hiding this comment

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

Got it.

Copy link
Member

Choose a reason for hiding this comment

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

Please make sure you read and apply the comments we've added.
Thanks a lot!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please make sure you read and apply the comments we've added. Thanks a lot!

Sure, I'll definitely add the changes suggested here👍🏼

@yaten2302 yaten2302 closed this May 21, 2024
Copy link
Member

@FabienLelaquais FabienLelaquais left a comment

Choose a reason for hiding this comment

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

Neat!


for (let i = 0; i <= progressCount; i++) {
if (!progressVisible) {
if (linearProgress)
Copy link
Member

Choose a reason for hiding this comment

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

We typically force the block syntax ('{' and '}') for better readability.
This also avoids potential errors if, in the future, more directives are added to the 'true' or the 'else' part of the 'if'.
What I'm saying is:
I really prefer to see this written:

if (linearProgress) {
    return (
        <Box sx={{ width: "100%" }}>
            <LinearProgress />
        </Box>
        );
} else {
    return (
        <Box sx={{ display: "flex" }}>
            <CircularProgress />
        </Box>
        );
}


useEffect(() => {
setLinearProgress((progress) => {
if (props.linear !== undefined) return props.linear;
Copy link
Member

Choose a reason for hiding this comment

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

We really try to avoid this kind of shortcut:
More difficult to read, more difficult to maintain.
I would have written:
return (props.linear === undefined) ? progress : props.linear;

This applies for setProgressVisible() and setProgressCount() below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add progress bar/circle visual element
4 participants