Skeleton loaders for text components #3236
-
Hi Paste team 👋 We've got a few skeleton loaders in our components that represent loading text, and I was wondering what the recommend approach is for matching the For example, if we have this line of text: <Text as="span" lineHeight="lineHeight100" fontSize="fontSize40">
A line of text
</Text> And we wanted to have a skeleton loader for it, we have used the approach of simulating the {/* Have to manually map lineHeight100 to 3.25rem and fontSize40 to 1rem */}
<Flex height="3.25rem" vertical vAlignContent="center">
<SkeletonLoader height="1rem" width="160px" />
</Flex> Which has the downside of us needing to map the For now we've use the actual paste token values to prevent doing this manually, but is the a better approach we could take? <Theme.Consumer>
{({ theme }) => (
<Flex
height={theme.lineHeights.lineHeight100}
vertical
vAlignContent="center"
>
<SkeletonLoader
height={theme.fontSizes.fontSize40}
width="160px"
/>
</Flex>
)}
</Theme.Consumer> https://codesandbox.io/s/nifty-mendeleev-vse7z1?file=/src/index.tsx:588-801 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hello @james2hey!! So I just spoke to our engineers and here's a couple of things they noted that may help you!
Then lastly, there are two distinct problems that may help to solve:
Here's an updated code sandbox https://codesandbox.io/s/serene-cloud-l51kfw?file=/src/index.tsx |
Beta Was this translation helpful? Give feedback.
-
Thanks for the speedy response Liberty! Thats makes sense for point 1 thank you. For the part about sizing them up using a The only way to prevent that I can think of is using |
Beta Was this translation helpful? Give feedback.
-
@james2hey Sure thing! You can try: height={theme.lineHeights.lineHeight40} |
Beta Was this translation helpful? Give feedback.
@james2hey Sure thing!
You can try:
const theme = useTheme();
height={theme.lineHeights.lineHeight40}