Skip to content

Commit 1d4ab53

Browse files
committed
refactor(plus): refactor content card and configuration vanilla for plus package (#5628)
1 parent 7300b63 commit 1d4ab53

File tree

31 files changed

+702
-1209
lines changed

31 files changed

+702
-1209
lines changed

.changeset/icy-jobs-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/ui": patch
3+
---
4+
5+
Add prop `style` on `<Skeleton />` component

.changeset/some-teams-worry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ultraviolet/plus": minor
3+
---
4+
5+
- Refactor `<ContentCard />` to use vanilla extract
6+
- Configure vanilla extract on build and export styles. Can be imported as follow: `import '@ultraviolet/plus/styles'`

.storybook/vite.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ export default defineConfig({
3333
},
3434
optimizeDeps: {
3535
exclude: ['@ultraviolet/*'],
36+
include: [
37+
'@vanilla-extract/css-utils',
38+
'@vanilla-extract/css',
39+
'@vanilla-extract/css/fileScope',
40+
'@vanilla-extract/dynamic',
41+
'@vanilla-extract/recipes',
42+
'@vanilla-extract/recipes/createRuntimeFn',
43+
'@vanilla-extract/sprinkles',
44+
'@vanilla-extract/sprinkles/createRuntimeSprinkles',
45+
]
3646
},
3747
plugins: [
3848
svgr({ memo: true, svgo: false }),

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ Welcome to the Ultraviolet Core repository! This is the main repository for the
2525
### Quick start
2626

2727
```sh
28-
pnpm add @ultraviolet/ui @ultraviolet/fonts @emotion/react @emotion/styled
28+
pnpm add @ultraviolet/ui @ultraviolet/fonts
2929
```
3030

3131
```tsx
32-
import { Global, ThemeProvider, css } from '@emotion/react'
32+
import { ThemeProvider } from '@ultraviolet/ui'
3333
import { Button, normalize, theme } from '@ultraviolet/ui'
34+
import '@ultraviolet/ui/styles'
3435
import '@ultraviolet/fonts/fonts.css'
3536

3637
const App = () => (
37-
<ThemeProvider theme={theme}>
38+
<ThemeProvider>
3839
<Global
3940
styles={css`
4041
${normalize()}

packages/form/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ It is using [React Hook Form](https://react-hook-form.com/) under the hood.
88
## Get Started
99

1010
```sh
11-
$ pnpm add @ultraviolet/ui @ultraviolet/form @emotion/react @emotion/styled
11+
$ pnpm add @ultraviolet/ui @ultraviolet/form
1212
```
1313

1414
### Usage
1515

1616
To use the library you need to put a `ThemeProvider` from `@emotion/react` with the theme that comes from `@ultraviolet/ui` then wrap all your fields inside a `Form`:
1717

1818
```tsx
19-
import { ThemeProvider } from '@emotion/react'
19+
import { ThemeProvider } from '@ultraviolet/ui'
2020
import { Form, TextInputField } from '@ultraviolet/form'
2121
import { theme } from '@ultraviolet/ui'
2222
import { useForm } from '@ultraviolet/form'
23+
import '@ultraviolet/ui/styles'
2324

2425
// Here are the input types of your form
2526
type FormValues = {

packages/plus/README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,37 @@
22

33
[![npm version](https://badge.fury.io/js/%40ultraviolet%2Fplus.svg)](https://badge.fury.io/js/%40ultraviolet%2Fplus)
44

5-
⚠️ THIS LIBRARY IS NOT STABLE ⚠️
6-
75
We are going to make breaking changes regularly until the first version is released.
86

97
Ultraviolet Plus is a set of complex components that are built on top of Ultraviolet UI.
108

119
## Get Started
1210

1311
```sh
14-
$ pnpm add @ultraviolet/ui @ultraviolet/plus @emotion/react @emotion/styled
12+
$ pnpm add @ultraviolet/ui @ultraviolet/plus
13+
```
14+
15+
### Usage
16+
17+
In order for the library to work you will need to import both Ultraviolet UI and Ultraviolet Plus styles in your project.
18+
19+
```tsx
20+
import { ThemeProvider } from '@ultraviolet/ui'
21+
import { normalize, theme } from '@ultraviolet/ui'
22+
import { ContentCard } from '@ultraviolet/plus'
23+
import '@ultraviolet/ui/styles'
24+
import '@ultraviolet/plus/styles'
25+
26+
const App = () => (
27+
<ThemeProvider theme={theme}>
28+
<Global
29+
styles={css`
30+
${normalize()}
31+
`}
32+
/>
33+
<ContentCard title="Welcome on Ultraviolet Plus" />
34+
</ThemeProvider>
35+
)
1536
```
1637

1738
## Documentation

packages/plus/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
1717
"typecheck": "tsc --noEmit",
1818
"size": "size-limit",
19-
"test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts",
19+
"test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vitest.config.ts",
2020
"test:unit:coverage": "pnpm test:unit --coverage",
2121
"lintpublish": "publint"
2222
},
@@ -47,7 +47,8 @@
4747
"types": "./dist/index.d.ts",
4848
"require": "./dist/index.cjs",
4949
"default": "./dist/index.js"
50-
}
50+
},
51+
"./styles": "./dist/plus.css"
5152
},
5253
"size-limit": [
5354
{
@@ -87,6 +88,8 @@
8788
"@uiw/react-codemirror": "4.25.2",
8889
"@ultraviolet/icons": "workspace:*",
8990
"@ultraviolet/themes": "workspace:*",
91+
"@vanilla-extract/css": "1.17.4",
92+
"@vanilla-extract/dynamic": "2.1.5",
9093
"csstype": "3.1.3",
9194
"react-intersection-observer": "9.16.0"
9295
}
Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
11
'use client'
22

3-
import styled from '@emotion/styled'
4-
import { Stack, Skeleton as UltravioletSkeleton } from '@ultraviolet/ui'
5-
6-
const SkeletonImage = styled(UltravioletSkeleton, {
7-
shouldForwardProp: prop => !['height', 'width', 'direction'].includes(prop),
8-
})<{
9-
width?: string
10-
height?: string
11-
direction: 'row' | 'column'
12-
}>`
13-
border-radius: ${({ theme, direction }) =>
14-
`${
15-
direction === 'column'
16-
? `${theme.radii.default} ${theme.radii.default} 0 0`
17-
: `${theme.radii.default} 0 0 ${theme.radii.default}`
18-
}`};
19-
width: ${({ width }) => width};
20-
height: ${({ height }) => height};
21-
`
22-
23-
const StyledStack = styled(Stack)`
24-
padding: ${({ theme }) => theme.space['3']};
25-
`
3+
import { Stack, Skeleton as UVSkeleton } from '@ultraviolet/ui'
4+
import { assignInlineVars } from '@vanilla-extract/dynamic'
5+
import {
6+
paddedStack,
7+
skeletonHeightVar,
8+
skeletonImage,
9+
skeletonWidthVar,
10+
} from './styles.css'
2611

2712
type SkeletonProps = {
2813
direction: 'row' | 'column'
2914
}
3015

3116
export const Skeleton = ({ direction }: SkeletonProps) => (
3217
<Stack direction={direction}>
33-
<SkeletonImage
34-
direction={direction}
35-
height={direction === 'column' ? '120px' : 'unset'}
18+
<UVSkeleton
19+
className={skeletonImage[direction]}
20+
style={assignInlineVars({
21+
[skeletonHeightVar]: direction === 'column' ? '120px' : 'unset',
22+
[skeletonWidthVar]: direction === 'row' ? '220px' : '100%',
23+
})}
3624
variant="square"
37-
width={direction === 'row' ? '220px' : undefined}
3825
/>
39-
<StyledStack gap={2}>
40-
<UltravioletSkeleton variant="line" />
41-
<UltravioletSkeleton variant="line" />
42-
<UltravioletSkeleton variant="line" />
43-
<UltravioletSkeleton variant="line" />
44-
<UltravioletSkeleton variant="line" />
45-
</StyledStack>
26+
<Stack className={paddedStack} gap={2}>
27+
<UVSkeleton variant="line" />
28+
<UVSkeleton variant="line" />
29+
<UVSkeleton variant="line" />
30+
<UVSkeleton variant="line" />
31+
<UVSkeleton variant="line" />
32+
</Stack>
4633
</Stack>
4734
)

0 commit comments

Comments
 (0)