-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Skeleton component and responsive typography (#1978)
* feat(ui): add Skeleton component * feat(ui): implement responsive typography * feat(ui): add `bodyTechnical` text style * chore: changeset
- Loading branch information
Showing
10 changed files
with
263 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@penumbra-zone/ui': minor | ||
--- | ||
|
||
- Make Typography font sizes responsive | ||
- Add `bodyTechnical` Text variant | ||
- Add Skeleton component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Skeleton } from '.'; | ||
import { Text } from '../Text'; | ||
|
||
const meta: Meta<typeof Skeleton> = { | ||
component: Skeleton, | ||
tags: ['autodocs', '!dev'], | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Skeleton>; | ||
|
||
export const Basic: Story = { | ||
args: {}, | ||
render: function Render(props) { | ||
return ( | ||
<> | ||
<Text color='text.primary'>Resize me</Text> | ||
<div className='h-20 w-60 resize overflow-auto'> | ||
<Skeleton {...props} /> | ||
</div> | ||
</> | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { ElementType } from 'react'; | ||
import cn from 'clsx'; | ||
|
||
export interface SkeletonProps { | ||
as?: ElementType; | ||
circular?: boolean; | ||
} | ||
|
||
/** | ||
* Shimmering skeleton loader. By default, takes the full space of its parent. | ||
*/ | ||
export const Skeleton = ({ as: Component = 'div', circular }: SkeletonProps) => { | ||
return ( | ||
<Component | ||
className={cn( | ||
'relative w-full h-full bg-other-tonalFill5 overflow-hidden', | ||
'before:content-[""] before:w-full before:h-full before:absolute before:top-1/2 before:left-1/2', | ||
'before:animate-shimmer before:-translate-x-1/2 before:-translate-y-1/2', | ||
'before:bg-gradient-to-r before:from-transparent before:via-other-tonalFill5 before:to-transparent', | ||
circular ? 'rounded-full' : 'rounded-xs', | ||
)} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/* | ||
In Penumbra UI, text styles are responsive. It is measured in `rem` and | ||
differ from screen to screen. For example, the base text size is 0.875rem for mobile, | ||
1rem for desktop, and 1.125rem for xl screens. | ||
This helps fit more data on respective screens while keeping the text readable. | ||
*/ | ||
|
||
/* MOBILE AND TABLET SCREENS*/ | ||
|
||
.text-textXs { | ||
font-size: 0.6875rem; | ||
line-height: 1rem; | ||
} | ||
|
||
.text-textSm { | ||
font-size: 0.75rem; | ||
line-height: 1.25rem; | ||
} | ||
|
||
.text-textBase { | ||
font-size: 0.875rem; | ||
line-height: 1.5rem; | ||
} | ||
|
||
.text-textLg { | ||
font-size: 1rem; | ||
line-height: 1.75rem; | ||
} | ||
|
||
.text-textXl { | ||
font-size: 1.125rem; | ||
line-height: 2rem; | ||
} | ||
|
||
.text-text2xl { | ||
font-size: 1.3125rem; | ||
line-height: 2.25rem; | ||
} | ||
|
||
.text-text3xl { | ||
font-size: 1.625rem; | ||
line-height: 2.5rem; | ||
} | ||
|
||
.text-text4xl { | ||
font-size: 2rem; | ||
line-height: 2.75rem; | ||
} | ||
|
||
.text-text5xl { | ||
font-size: 2.625rem; | ||
line-height: 3.5rem; | ||
} | ||
|
||
.text-text6xl { | ||
font-size: 3.25rem; | ||
line-height: 4.25rem; | ||
} | ||
|
||
.text-text7xl { | ||
font-size: 3.9375rem; | ||
line-height: 5rem; | ||
} | ||
|
||
.text-text8xl { | ||
font-size: 5.25rem; | ||
line-height: 6.25rem; | ||
} | ||
|
||
.text-text9xl { | ||
font-size: 7rem; | ||
line-height: 8.25rem; | ||
} | ||
|
||
/* DESKTOP AND LARGE SCREENS */ | ||
|
||
@screen desktop { | ||
.text-textXs { | ||
font-size: 0.75rem; | ||
} | ||
|
||
.text-textSm { | ||
font-size: 0.875rem; | ||
} | ||
|
||
.text-textBase { | ||
font-size: 1rem; | ||
} | ||
|
||
.text-textLg { | ||
font-size: 1.125rem; | ||
} | ||
|
||
.text-textXl { | ||
font-size: 1.25rem; | ||
} | ||
|
||
.text-text2xl { | ||
font-size: 1.5rem; | ||
} | ||
|
||
.text-text3xl { | ||
font-size: 1.875rem; | ||
} | ||
|
||
.text-text4xl { | ||
font-size: 2.25rem; | ||
} | ||
|
||
.text-text5xl { | ||
font-size: 3rem; | ||
} | ||
|
||
.text-text6xl { | ||
font-size: 3.75rem; | ||
} | ||
|
||
.text-text7xl { | ||
font-size: 4.5rem; | ||
} | ||
|
||
.text-text8xl { | ||
font-size: 6rem; | ||
} | ||
|
||
.text-text9xl { | ||
font-size: 8rem; | ||
} | ||
} | ||
|
||
/* EXTRA LARGE SCREENS */ | ||
|
||
@screen xl { | ||
.text-textXs { | ||
font-size: 0.875rem; | ||
} | ||
|
||
.text-textSm { | ||
font-size: 1rem; | ||
} | ||
|
||
.text-textBase { | ||
font-size: 1.125rem; | ||
} | ||
|
||
.text-textLg { | ||
font-size: 1.25rem; | ||
} | ||
|
||
.text-textXl { | ||
font-size: 1.375rem; | ||
} | ||
|
||
.text-text2xl { | ||
font-size: 1.6875rem; | ||
} | ||
|
||
.text-text3xl { | ||
font-size: 2.125rem; | ||
} | ||
|
||
.text-text4xl { | ||
font-size: 2.5rem; | ||
} | ||
|
||
.text-text5xl { | ||
font-size: 3.375rem; | ||
} | ||
|
||
.text-text6xl { | ||
font-size: 4.25rem; | ||
} | ||
|
||
.text-text7xl { | ||
font-size: 5.0625rem; | ||
} | ||
|
||
.text-text8xl { | ||
font-size: 6.75rem; | ||
} | ||
|
||
.text-text9xl { | ||
font-size: 9rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters