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

[Material You] Add ripple on the button #35299

Merged
merged 42 commits into from Dec 8, 2022

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Nov 30, 2022

Preview: https://codesandbox.io/s/jovial-currying-g7u9m0?file=/demo.tsx
Docs: https://deploy-preview-35299--material-ui.netlify.app/material-ui/react-button/#material-you-version

The only change in the TouchRipple component is the value for the opacity, which now matches the one defined in the state's layer opacity for focused/pressed states.

In addition to this, I've also decided to apply the changes from #34258 regarding the focus ripple, as it is anyway a step in the right direction.

}
100% {
transform: scale(1);
opacity: 0.12;
Copy link
Member Author

Choose a reason for hiding this comment

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

I've adjusted the opacity to match the state layer focus/pressed value.

@mnajdova mnajdova added component: button This is the name of the generic UI component, not the React module! design: material you labels Nov 30, 2022
@mui-bot
Copy link

mui-bot commented Nov 30, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35299--material-ui.netlify.app/

@mui/material-next: parsed: +37.53% , gzip: +32.76%

Details of bundle changes

Generated by 🚫 dangerJS against 28eedfb

@mnajdova mnajdova marked this pull request as ready for review November 30, 2022 10:23
@mnajdova mnajdova requested a review from a team November 30, 2022 10:23
@mnajdova mnajdova requested review from michaldudak and siriwatknp and removed request for siriwatknp and danilo-leal December 6, 2022 11:51
docs/pages/experiments/md3/index.tsx Outdated Show resolved Hide resolved
docs/pages/experiments/md3/index.tsx Outdated Show resolved Hide resolved
packages/mui-material-next/src/Button/Button.tsx Outdated Show resolved Hide resolved
packages/mui-material-next/src/Button/Button.types.ts Outdated Show resolved Hide resolved
packages/mui-material-next/src/Button/TouchRipple.js Outdated Show resolved Hide resolved
packages/mui-material-next/src/Button/TouchRipple.js Outdated Show resolved Hide resolved
@michaldudak
Copy link
Member

michaldudak commented Dec 7, 2022

That's likely for another PR, but during testing, I found out that the focus state of a tonal button is almost indistinguishable from the normal state. The spec shows a darker color: https://m3.material.io/components/buttons/specs#cd245ab1-c10a-4a1c-bb13-d6a08b9abfc5

normal:
image

focused (ours):
image

focused (spec):
image

@mnajdova
Copy link
Member Author

mnajdova commented Dec 7, 2022

That's likely for another PR, but during testing, I found out that the focus state of a tonal button is almost indistinguishable from the normal state. The spec shows a darker color: https://m3.material.io/components/buttons/specs#cd245ab1-c10a-4a1c-bb13-d6a08b9abfc5

It's strange because the code followed what was in the spec. I've also checked the tokens and they are correct. I am not sure where's the difference. I've updated the value to a darker color, but we likely need to revisit this again.

I've added a comment for future reference.

@@ -232,12 +229,37 @@ export const ButtonRoot = styled('button', {
};

const containerElevation = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added the missing elevations to complete the button component.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 Overall LGTM. just have one question, I could not find the ripple on the official site. Is adding the ripple to ease the migration or do I missed the spec?

@mnajdova
Copy link
Member Author

mnajdova commented Dec 7, 2022

👍 Overall LGTM. just have one question, I could not find the ripple on the official site. Is adding the ripple to ease the migration or do I missed the spec?

Because of the reasons mentioned in #29345 (comment). I feel like it is missed in the spec.

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.

Haven't found anything else to pick on ;)

@@ -490,12 +538,16 @@ const Button = React.forwardRef(function Button<
as={ComponentProp}
className={clsx(classes.root, className)}
ownerState={ownerState}
{...getRootProps()}
{...getRootProps(getRippleHandlers(props) as unknown as EventHandlers)}
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 get*Props in Base hooks should be more permissive. Note taken.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally yes :)

@danilo-leal
Copy link
Contributor

I feel like it is missed in the spec.

It's great that someone from the community has let us know. Still, I wonder if it's worth the work of checking out how Material You is implemented in Flutter/Android and replicating it on the web before they themselves update the web documentation. That said, and if it's the case of not being worth it, it might be helpful to document that we'll be mostly following whatever is documented in the web docs (and the community should still feel free to point things out).

@mnajdova
Copy link
Member Author

mnajdova commented Dec 8, 2022

That said, and if it's the case of not being worth it, it might be helpful to document that we'll be mostly following whatever is documented in the web docs (and the community should still feel free to point things out).

This is more or less what will happen. I don't think we need some special announcement that we are going to work this way tough :)

@mnajdova mnajdova merged commit 9480a8b into mui:master Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! design: material you
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants