-
Notifications
You must be signed in to change notification settings - Fork 47
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
🚀 feat(button): add prop loading #705
Conversation
Why not make the Example: <Button isLoading={loading} />
<Button.Outline isLoading={loading} />
<Button.Icon isLoading={loading} /> (On one of our projects has an abstraction that does what I am suggesting, you can check the code here and the documentation here - needs VPN) |
I agree with @frgiovanna , have loading as props of the current button would be better than a new component. |
As said by @frgiovanna and @joaopaulonsoares-gympass, I really think that we should change this, so the loading state can be a prop instead of a whole new component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job so far, please check my comments
@@ -14,6 +14,14 @@ You can use all differente compounds like `<Button.Outline />` and `<Button.Text | |||
</Box> | |||
``` | |||
|
|||
#### Inverted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏅
<Link {...props} disabled={disabled} aria-disabled={disabled} /> | ||
); | ||
// eslint-disable-next-line react/prop-types | ||
const ButtonLink = forwardRef(({ isLoading, ...rest }, ref) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are we using this destructured isLoading
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original idea was to use all the properties except 'isLoading' when dealing with 'Button.Link' and 'Button.Text.' However, I had to disable eslint since 'isLoading' was not being utilized; it was solely removed to prevent its use in 'Button.Link' and 'Button.Text.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think is scalable if you get all of the other props except the isLoading
? This means every time someone adds a new value for all buttons they will need to add it here too, otherwise it will be ignored. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 🤔
I'm just concerned that someone might misunderstand the 'button.text' and 'button.link' props and try to use them. By removing this approach, people will still be able to use isLoading, and it will work. However, it wouldn't be advisable to do so because, as far as I know, we don't have any plans for that.
But, yes I agree with you. This approach isn't scalable. It's more on the developer's side to use it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No no, I really got your point and I think you're right, I'm just wondering if we can handle it in another way instead of having this eslint comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you do something like this?
const ButtonLink = forwardRef(({ rest }, ref) => {
const props = Object.fromEntries(
Object.entries(rest).filter(([key]) => key !== 'isLoading')
);
return (
<Link {...props} disabled={props.disabled} aria-disabled={props.disabled} ref={ref} />
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion!! 🚀
f263612
to
599dea6
Compare
…l and role attributes
599dea6
to
a4f5cf6
Compare
Description 📄
This is a new prop of button, now we can use loading on buttons! ✨
We can use it when we are going to perform some type of loading or request, and it will take a while to finish. That's when the loading comes into action.
Exemple:
<Button isLoading>Find an activity</Button>
<Button isLoading={false}>Find an activity</Button>
Platforms 📲
Type of change 🔍
How Has This Been Tested? 🧪
[Enter the tips to test this PR]
Checklist: 🔍
Screenshots 📸
Default Button
Screen.Recording.2023-10-25.at.18.39.26.mov
Icon Button
Screen.Recording.2023-10-23.at.15.03.14.mov
Outline Button
Screen.Recording.2023-10-23.at.15.03.44.mov