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

Improve skeleton for A and ListItem components #653

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions packages/app-elements/src/ui/atoms/SkeletonTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const SkeletonTemplate: SkeletonTemplateComponent<
/^AvatarLetter$/,
/^Badge$/,
/^Button$/,
/^A$/,
/^Icon$/,
/^StatusIcon$/,
/^RadialProgress$/,
Expand All @@ -187,6 +188,13 @@ const SkeletonTemplate: SkeletonTemplateComponent<
})
}

if (isSpecificReactComponent(child, [/^ListItem$/, /^Hr$/])) {
return cloneElement(child, {
...props,
className: cn(props.className as string, '!border-gray-50')
})
}

return cloneElement(child, props)
}
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exports[`PageSkeleton > Should be rendered 1`] = `
class=""
>
<div
class="flex gap-4 w-full text-gray-800 hover:text-gray-800 py-4 px-4 border-b border-gray-100"
class="flex gap-4 w-full text-gray-800 hover:text-gray-800 py-4 px-4 border-b border-gray-100 !border-gray-50"
>
<div
class="flex gap-4 flex-1 items-center"
Expand Down Expand Up @@ -207,7 +207,7 @@ exports[`PageSkeleton > Should be rendered 1`] = `
</div>
</div>
<div
class="flex gap-4 w-full text-gray-800 hover:text-gray-800 py-4 px-4 border-b border-gray-100"
class="flex gap-4 w-full text-gray-800 hover:text-gray-800 py-4 px-4 border-b border-gray-100 !border-gray-50"
>
<div
class="flex gap-4 flex-1 items-center"
Expand Down
40 changes: 26 additions & 14 deletions packages/docs/src/stories/atoms/SkeletonTemplate.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { A } from '#ui/atoms/A'
import { Avatar } from '#ui/atoms/Avatar'
import { Badge } from '#ui/atoms/Badge'
import { Button } from '#ui/atoms/Button'
import { CopyToClipboard } from '#ui/atoms/CopyToClipboard'
import { Hr } from '#ui/atoms/Hr'
import { RadialProgress } from '#ui/atoms/RadialProgress'
import {
SkeletonTemplate,
Expand Down Expand Up @@ -54,6 +56,9 @@ const children = (
<ForwardRefComponent>
<a>Simil Wouter</a>
</ForwardRefComponent>
<Spacer top='4' bottom='4'>
<Hr />
</Spacer>
<WithSkeletonComponentB>C</WithSkeletonComponentB>
<ListItem
onClick={() => {
Expand All @@ -71,22 +76,29 @@ const children = (
<StatusIcon name='check' background='green' gap='large' />
<RadialProgress percentage={42} />
</ListItem>
<ListItem>
<div>
<Text tag='div'>Ehi there!</Text>
<Badge variant='primary'>APPROVED</Badge>
</div>
<Button
onClick={() => {
alert('Hello world!')
}}
>
OK
</Button>
</ListItem>
<Spacer top='8'>
<ListItem variant='boxed'>
<div>
<Text tag='div'>Ehi there!</Text>
<Badge variant='primary'>APPROVED</Badge>
</div>
<Button
onClick={() => {
alert('Hello world!')
}}
>
OK
</Button>
<A variant='secondary' href='https://commercelayer.io'>
OK
</A>
</ListItem>
</Spacer>
<Spacer top='8'>
<a href='https://example.com'>It's a link</a>
<br />
<A href='https://example.com'>It's an A component</A>
<br />
<div
onClick={() => {
alert('Hello world!')
Expand Down Expand Up @@ -126,7 +138,7 @@ const Template: StoryFn<typeof SkeletonTemplate> = ({ children, ...args }) => (
</SkeletonTemplate>
</div>
<Spacer bottom='8'>
<hr />
<Hr />
</Spacer>
<div className='flex gap-2'>
<div>{children}</div>
Expand Down