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] variant=text wrong size #18170

Closed
2 tasks done
Mangatt opened this issue Nov 4, 2019 · 14 comments · Fixed by #18451
Closed
2 tasks done

[skeleton] variant=text wrong size #18170

Mangatt opened this issue Nov 4, 2019 · 14 comments · Fixed by #18451
Labels
component: skeleton This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@Mangatt
Copy link
Contributor

Mangatt commented Nov 4, 2019

I suppose that text skeleton should be 1:1 size to real text that he is replacing. Right now, size is way off.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Size of text skeleton is wrong.

Expected Behavior 🤔

Size of text skeleton should be equal to size of replaced text.

Steps to Reproduce 🕹

https://codesandbox.io/s/create-react-app-7y24f

To work as expected, there has to be 2 changes:

  1. Add   as skeleton children
  2. Change component CSS to:
height: 'auto',
marginTop: 0,
marginBottom: 0,
transformOrigin: '0 65%',
transform: 'translateZ(0) scale(1, 0.65)',
textIndent: -999,
borderRadius: theme.shape.borderRadius,
@Mangatt
Copy link
Contributor Author

Mangatt commented Nov 4, 2019

Alternatively,   could be added in pseudoelement:

text: {
	height: 'auto',
	marginTop: 0,
	marginBottom: 0,
	transformOrigin: '0 65%',
	transform: 'translateZ(0) scale(1, 0.65)',
	textIndent: -999,
	'&:empty:before': {
		content: '" "'
	}
}

@oliviertassinari
Copy link
Member

I suppose that text skeleton should be 1:1 size to real text that he is replacing.

@Mangatt Why should it follow this rule? The component was designed to be a rough approximation of the content.

@Mangatt
Copy link
Contributor Author

Mangatt commented Nov 4, 2019

@oliviertassinari You don't agree? Different size results in percieved jumps after content is loaded. What are benefits of different size really?

@oliviertassinari
Copy link
Member

@Mangatt I had a closer look, actually, it looks pretty slick. I would be curious to try it out with our implementation :).

@oliviertassinari oliviertassinari added component: skeleton This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. labels Nov 4, 2019
@Mangatt
Copy link
Contributor Author

Mangatt commented Nov 5, 2019

@oliviertassinari I'm glad that you like it. I think that as well :)

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 5, 2019

@Mangatt Alright, do you want to submit a pull request 💪?

@Mangatt
Copy link
Contributor Author

Mangatt commented Nov 9, 2019

@oliviertassinari I'll try to in next week 👍

@oliviertassinari
Copy link
Member

@Mangatt Did you had the chance to work on it? :)

@julie-volkova
Copy link

But what about other examples of usage? For example, if user provides disabledTypography prop. That way a rendered skeleton would shrink even harder compared to text content.
Demo here.

@Mangatt
Copy link
Contributor Author

Mangatt commented Nov 19, 2019

@oliviertassinari Sorry, I did not, but it is definitely on my schedule.
@macfire10 Yes, in your demo is size off, but right now size is always off, so there's no harm in adjusting styles. There is no sure-proof CSS solution of this problem, so everyone has to adjust CSS according to their needs if necessary.

@oliviertassinari
Copy link
Member

@macfire10 the <p> elements add its own margin. If you replace it with a <div>, we would still be good with disabledTypography set to true. @Mangatt's proposal seems to be solid. Given he has other priorities right now, would you be interested in contributing his idea? :)

@julie-volkova
Copy link

@oliviertassinari sure!

@josh-feldman
Copy link
Contributor

This appears to have created an odd issue:
image

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 25, 2019

@josh-feldman Thanks for the report. It was taken care of earlier today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: skeleton This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants