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

[docs][base] Add Tailwind CSS & plain CSS demo on the Slider page #37736

Merged

Conversation

mnajdova
Copy link
Member

Part of #37222

@mnajdova mnajdova added docs Improvements or additions to the documentation component: slider This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Jun 27, 2023
ref={ref}
className={clsx(
`absolute w-4 h-4 -ml-1.5 -mt-1.5 box-border rounded-full outline-0 border-3 border-solid border-current bg-white hover:shadow-outline-purple ${
focusVisible || active ? 'shadow-outline-purple' : ''
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 didn't want to use utils from our system, like the alpha, so I used the same shadow outline used in the other component. @danilo-leal @zanivan let me know if you think we should maybe add additional one, for distinguishing the styles between focus visible, active and hover.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's necessary to have more, as we don't have it, neither on plain CSS nor system.

Regarding the shadow-outline, on the switch, we're using rgba instead of hex value, so I converted the purple hex to rgb, and added the same 0.25 for the alpha. Would it be a problem? I thought it'd look more consistent with the other styles here.

@mui-bot
Copy link

mui-bot commented Jun 27, 2023

Netlify deploy preview

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 94107af

@@ -126,6 +126,7 @@ const Slider = React.forwardRef(function Slider<RootComponentType extends React.
marked: marks.length > 0 && marks.some((mark) => mark.label),
dragging,
focusedThumbIndex,
activeThumbIndex: active,
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 similarly to focusedThumbIndex, I added the activeThumbIndex to allow custom component utilizing this information. I know we discussed something similar in the past, but I really feel like this calculated feels should be accessible in the slotProps callback. Maybe we can extend it so that apart from the ownerState, we have two additional states in the callback - active and focused so that we don't need to create custom components just for this calculation. We decided in the past that we should not include them in the ownerState, as they are not really a state of the owner component, but still having access to them feels important.

Copy link
Member

Choose a reason for hiding this comment

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

From a developer's perspective, yeah, it is totally understandable that someone would expect to have an easy way of applying props based on the active state. Having them as additional parameters of the slotProps callback feels like the best way to achieve this. This way we won't pollute the ownerState with something that does not belong to the owner.
Additionally, for styling, we could make sure that the built-in CSS pseudoclasses (:active and :focus-visible) can be used. For now, I see that only :active works well.

Copy link
Member Author

Choose a reason for hiding this comment

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

From a developer's perspective, yeah, it is totally understandable that someone would expect to have an easy way of applying props based on the active state. Having them as additional parameters of the slotProps callback feels like the best way to achieve this. This way we won't pollute the ownerState with something that does not belong to the owner.

Perfect, I will create a pull request for this soon.

Additionally, for styling, we could make sure that the built-in CSS pseudoclasses (:active and :focus-visible) can be used. For now, I see that only :active works well.

Yep

Copy link
Member Author

Choose a reason for hiding this comment

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

Here it is #37749

@@ -102,7 +102,7 @@ async function transpileFile(tsxPath, program) {

const propTypesAST = typescriptToProptypes.parseFromProgram(tsxPath, program, {
shouldResolveObject: ({ name }) => {
if (name === 'classes') {
if (name === 'classes' || name === 'ownerState') {
Copy link
Member Author

@mnajdova mnajdova Jun 27, 2023

Choose a reason for hiding this comment

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

There were lint issues while generating the ownerState in the JavaScript files. Also, it cluttered a lot the demo, so I am skipping the ownerState here, so that it shows only as object in the propTypes. Check the failing build: https://app.circleci.com/pipelines/github/mui/material-ui/100746/workflows/17aaea13-a224-416a-9d33-c8634deba2d4/jobs/536745

@mnajdova mnajdova marked this pull request as ready for review June 27, 2023 12:36
@mnajdova mnajdova requested a review from zanivan July 3, 2023 09:59
@mnajdova mnajdova merged commit 2a0a0f7 into mui:master Jul 4, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants