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
[base-ui][Button] Make demos more readable, modern, and robust #40742
base: master
Are you sure you want to change the base?
Conversation
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.
Looking good — first PR! 🎉
Left just a couple of small comments. I think it'd be great to consider documenting/discussing the alphabetical CSS sorting — I don't have any preference from the get-go, but whatever path we take, we should probably try to standardize as much as we can throughout the docs!
docs/data/base/components/button/UnstyledButtonIntroduction/css/index.js
Show resolved
Hide resolved
docs/data/base/components/button/UnstyledButtonIntroduction/css/index.js
Show resolved
Hide resolved
transition-property: background-color, box-shadow; | ||
transition-timing-function: ease; | ||
} | ||
@media (any-hover: hover) { |
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.
Im curious what's the point of @media (any-hover: hover)
? If no input device supports hover, these styles won't be applied anyway, right?
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.
There are lots of problems on mobile devices and other devices that support touch but not hover. The effect can often "stick" to a component when you touch a UI control, or touch close to a control, then slide over it.
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.
box-shadow: 0 2px 1px ${ | ||
isDarkMode ? 'rgba(0, 0, 0, 0.5)' : 'rgba(45, 45, 60, 0.2)' | ||
.Button { | ||
all: unset; |
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.
I am curious what's the motivation for adding this to the demos. It would break the default presets people may have in their projects.
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.
This is just a quick way to reset the UA styles, rather than going through and declaring each reset style one-by-one.
It would break the default presets people may have in their projects.
Any styles they need would be declared below this all: unset
style. imo, in a component-based architecture, people shouldn't rely on leaky/global CSS to style elements. All styles they need should be self-contained and encapsulated in the component, so you can drop it into any screen/environment and it just works.
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.
Makes sense to me. I mentioned this because it conflicts with other parts of the docs where we promote using the CssBaseline component, for e.g. in Material UI. We should be consistent with this across the products in my opinion.
border-radius: 8px; | ||
color: white; | ||
transition: all 150ms ease; | ||
cursor: pointer; |
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.
Should we start the cursor: pointer
discussion? 😄 I am just joking, I would love to follow the default browser behavior, however just noting that this is opposite to what we use in Material UI, which kind of feels better 😄
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.
Should we start the cursor: pointer discussion?
I think we just did lol
however just noting that this is opposite to what we use in Material UI
imo buttons should not have cursor: pointer, but it's not a hill I want to die on haha. So you choose, just say the word and I will add it?
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.
This and the not-allowed cursor have been discussed several times in the past (I could find #17871, #27719 (comment), #32371), so there's no way we could make everyone happy :)
Having our solution use the patterns found in the native browser or OS controls feels the safest, though.
user-select: none; | ||
vertical-align: middle; | ||
} | ||
@media (prefers-reduced-motion: no-preference) { |
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.
💯 I remember a time when I needed to create an animation context with a switch on/off that would remove all transitions automatically. Life's much easier now 😄
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.
Btw, we would add the @media
on the other demos (tailwind and system) - this is the pain point that would be solved if we have an automatic translation to System & Tailwind based on the plain CSS demo.
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.
Looks great! Great improvements all around!
Not sure if you were meaning to use this PR just for the introduction demos, but we should make sure every other demo on the page is using the same adjusted styles (tedious, I know 😕 but the docs-infra will tackle this soon).
Additionally, lots of CSS-specific quirks/strategies were discussed in here, pointing to potential "universal" guidelines for styling the Base UI demos. I think we should document them somewhere with explanations so we can reference them later on — I'm particularly thinking of a page in the Base UI Notion space to start (edit: started to do this here). Not sure whether it'd be valuable to expose this as a new page in the docs.
[WIP]
Will fix mui/base-ui#78
cursor: not-allowed
to disabled controls.cursor: pointer
(that value is intended to indicate a link)px
values torem
.0
from decimal values.transform: scale
effect (browsers rasterise text before scaling it, so it looks weird/blurry).transition-property: all
with explicit declarations for improved performance and manipulation.<React.Fragment />
.background-clip: padding-box
, so shadows can bleed through borders.Currently looking for feedback on these changes before I copy the changes to all button demos.
https://deploy-preview-40742--material-ui.netlify.app/base-ui/react-button/#introduction