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

[Skeleton] Use span element for text variant #19241

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/Skeleton/Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Skeleton = React.forwardRef(function Skeleton(props, ref) {
animation = 'pulse',
classes,
className,
component: Component = ['rect', 'circle'].includes(props.variant) ? 'div' : 'span',
component: Component = ['rect', 'circle'].indexOf(props.variant) > -1 ? 'div' : 'span',
height,
variant = 'text',
width,
Expand Down
21 changes: 21 additions & 0 deletions packages/material-ui-lab/src/Skeleton/Skeleton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ describe('<Skeleton />', () => {
});

describeConformance(<Skeleton />, () => ({
classes,
inheritComponent: 'span',
mount,
refInstanceof: window.HTMLSpanElement,
}));

describeConformance(<Skeleton variant="text" />, () => ({
Copy link
Member

@oliviertassinari oliviertassinari Jan 15, 2020

Choose a reason for hiding this comment

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

Let's use a single describeConformance. They would be too much duplication otherwise.

Copy link
Author

Choose a reason for hiding this comment

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

so only the first one without a variant?
what is the error of the broken check? i don't get it

Copy link
Member

Choose a reason for hiding this comment

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

One with the default props should great.

Copy link
Member

Choose a reason for hiding this comment

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

We can have a small dedicated test instead.

Copy link
Author

Choose a reason for hiding this comment

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

ok if i run yarn docs:api the docs will get updated. but than the default value is messed up

Copy link
Member

@oliviertassinari oliviertassinari Jan 16, 2020

Choose a reason for hiding this comment

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

What do you mean by "messed up", like more accurate?

In this case, always using span sounds better, which means giving less weight to the div vs span semantic in the tradeoff, considering the dimension negligible: https://stackoverflow.com/questions/2961889/is-there-a-semantic-difference-spans-and-divs/2961920.

classes,
inheritComponent: 'span',
mount,
refInstanceof: window.HTMLSpanElement,
}));

describeConformance(<Skeleton variant="rect" />, () => ({
classes,
inheritComponent: 'div',
mount,
refInstanceof: window.HTMLDivElement,
}));

describeConformance(<Skeleton variant="circle" />, () => ({
classes,
inheritComponent: 'div',
mount,
Expand Down