Skip to content

Commit 0543605

Browse files
matthprostlisalupi
authored andcommitted
feat(Button): emotion removal vanilla extract (#5428)
* feat(Button): emotion removal vanilla extract * fix: unit tests and checks * fix: update prefix to add uv * fix: snapshot update
1 parent d436756 commit 0543605

File tree

61 files changed

+3785
-19544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3785
-19544
lines changed

.changeset/eight-glasses-warn.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"@ultraviolet/ui": major
3+
---
4+
5+
⚠️ BREAKING CHANGES ⚠️
6+
In order to start using the new style, you will need to import new `<ThemeProvider />` and import new CSS generated at build time:
7+
8+
```tsx
9+
import { ThemeProvider } from '@emotion/react'
10+
import { consoleLightTheme } from '@ultraviolet/themes'
11+
12+
import { ThemeProvider as ThemeProviderUV } from "@ultraviolet/ui" // ThemeProvider that generate the theme applied to components
13+
import "@ultraviolet/ui/styles" // Generated CSS used by components
14+
15+
export const App = (children) => {
16+
<ThemeProvider theme={consoleLightTheme}>
17+
<ThemeProviderUV>
18+
{children}
19+
</ThemeProviderUV>
20+
</ThemeProvider>
21+
}
22+
```

.oxlintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"import/no-named-as-default-member": "error",
8080
"import/no-named-as-default": "error",
8181
"import/no-self-import": "error",
82-
"import/no-unassigned-import": "error",
82+
"import/no-unassigned-import": "off",
8383
"import/no-unused-modules": "off",
8484
"import/prefer-default-export": "off",
8585
"import/no-namespace": "off",
@@ -241,7 +241,7 @@
241241
"react_perf/jsx-no-new-array-as-prop": "error",
242242
"react_perf/jsx-no-new-function-as-props": "error",
243243
"react_perf/jsx-no-new-object-as-prop": "error",
244-
"react/button-has-type": "error",
244+
"react/button-has-type": "off",
245245
"react/exhaustive-deps": "error",
246246
"react/jsx-filename-extension": [
247247
"error",

.storybook/components/DocsContainer.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { ReactNode } from 'react'
1010
import { cloneElement, isValidElement, useState } from 'react'
1111
import { globalStyles } from './globalStyle'
1212
import '@ultraviolet/fonts/fonts.css'
13-
import { GlobalAlert } from '@ultraviolet/ui'
13+
import { GlobalAlert, ThemeProvider as ThemeProviderUV } from '@ultraviolet/ui'
1414

1515
type ExtraProps = {
1616
/**
@@ -66,28 +66,30 @@ const DocsContainer = ({ children, context }: DocsContainerProps) => {
6666

6767
return (
6868
<Unstyled>
69-
<ThemeProvider theme={lightTheme}>
70-
{isBeta ?
71-
<GlobalAlert
72-
buttonText="Access to Beta"
73-
onClickButton={() => window.top?.location.assign('https://beta.storybook.ultraviolet.scaleway.com')}
74-
closable={false}
75-
>
76-
A Beta version is available. Please use this version if your dependencies include the Beta release.
77-
</GlobalAlert> : null}
78-
<Global styles={[globalStyles]} />
79-
<BaseContainer context={context}>
80-
{isValidElement<ExtraProps>(children)
81-
? cloneElement(children, {
82-
deprecated: parameters?.deprecated,
83-
deprecatedReason: parameters?.deprecatedReason,
84-
migrationLink: parameters?.migrationLink,
85-
hideArgsTable: parameters?.hideArgsTable,
86-
experimental: isPlusLibrary ? true : parameters?.experimental,
87-
})
88-
: children}
89-
</BaseContainer>
90-
</ThemeProvider>
69+
<ThemeProviderUV>
70+
<ThemeProvider theme={lightTheme}>
71+
{isBeta ?
72+
<GlobalAlert
73+
buttonText="Access to Beta"
74+
onClickButton={() => window.top?.location.assign('https://beta.storybook.ultraviolet.scaleway.com')}
75+
closable={false}
76+
>
77+
A Beta version is available. Please use this version if your dependencies include the Beta release.
78+
</GlobalAlert> : null}
79+
<Global styles={[globalStyles]} />
80+
<BaseContainer context={context}>
81+
{isValidElement<ExtraProps>(children)
82+
? cloneElement(children, {
83+
deprecated: parameters?.deprecated,
84+
deprecatedReason: parameters?.deprecatedReason,
85+
migrationLink: parameters?.migrationLink,
86+
hideArgsTable: parameters?.hideArgsTable,
87+
experimental: isPlusLibrary ? true : parameters?.experimental,
88+
})
89+
: children}
90+
</BaseContainer>
91+
</ThemeProvider>
92+
</ThemeProviderUV>
9193
</Unstyled>
9294
)
9395
}

.storybook/storybookThemes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const generateStorybookTheme = ({
4343

4444
// Toolbar default and active colors
4545
barTextColor: theme.colors.neutral.textWeak,
46-
barSelectedColor: theme.colors.primary.textWeak,
46+
barSelectedColor: theme.colors.primary.text,
4747
barBg: theme.colors.neutral.backgroundWeak,
4848

4949
buttonBg: theme.colors.neutral.background,

.storybook/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { resolve } from 'path'
22
import svgr from '@svgr/rollup'
33
import react from '@vitejs/plugin-react'
44
import { defineConfig } from 'vite'
5+
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
56

67
// https://vitejs.dev/config/
78
export default defineConfig({
@@ -42,5 +43,6 @@ export default defineConfig({
4243
plugins: ['@emotion/babel-plugin'],
4344
},
4445
}),
46+
vanillaExtractPlugin({})
4547
],
4648
})

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"!**/build/**",
1818
"!**/.turbo/**",
1919
"!**/prebuild.ts",
20-
"!**/index.stories.tsx"
20+
"!**/index.stories.tsx",
21+
"!**/*.css.ts"
2122
]
2223
},
2324
"css": {

eslint.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export default [
109109
'**/__stories__/**/*.{ts,tsx}',
110110
'**/__tests__/**/*.{ts,tsx}',
111111
'**/vite.config.*',
112+
'**/vitest.config.*',
112113
'utils/test/**/*.{ts,tsx}',
113114
'**/vitest.setup.ts',
114115
],
@@ -136,6 +137,7 @@ export default [
136137
'**/__stories__/**/*.{ts,tsx}',
137138
'**/__tests__/**/*.{ts,tsx}',
138139
'**/vite.config.*',
140+
'**/vitest.config.*',
139141
'utils/test/**/*.{ts,tsx}',
140142
'**/vitest.setup.ts',
141143
'.storybook/**',
@@ -160,7 +162,8 @@ export default [
160162
},
161163
})),
162164
{
163-
files: ['**/*.d.ts', '**/vite.config.ts'],
165+
files: ['**/*.d.ts', '**/vite.config.ts', '**/vitest.config.*',
166+
],
164167

165168
rules: {
166169
'import/no-extraneous-dependencies': 'off',

examples/vite/src/App.tsx

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
import { PlusIcon } from '@ultraviolet/icons'
2-
import { Alert, Button, Card, Row, Stack, Text } from '@ultraviolet/ui'
2+
import {
3+
Alert,
4+
Button,
5+
Card,
6+
Row,
7+
Stack,
8+
Text,
9+
ThemeProvider,
10+
} from '@ultraviolet/ui'
311
import { useState } from 'react'
12+
import '@ultraviolet/ui/styles' // Import styles for the UI components
13+
import { consoleDarkTheme, consoleLightTheme } from '@ultraviolet/themes'
414

515
export const App = () => {
616
const [count, setCount] = useState(0)
17+
const [darkMode, setDarkMode] = useState(false)
718

819
return (
9-
<Row gap="3" templateColumns="9fr 3fr">
10-
<Card>
11-
<Text as="h1" variant="headingSmall">
12-
Classic
13-
</Text>
14-
<Stack direction="row" gap="2">
15-
<Button onClick={() => setCount(prevCount => prevCount + 1)}>
16-
<PlusIcon />
17-
</Button>
18-
<Button onClick={() => setCount(0)}>Reset</Button>
19-
</Stack>
20-
<Text as="p" variant="body">
21-
Count:{count}
22-
</Text>
23-
</Card>
24-
<Alert sentiment="info">Alert</Alert>
25-
</Row>
20+
<ThemeProvider theme={darkMode ? consoleDarkTheme : consoleLightTheme}>
21+
<Row gap="3" templateColumns="9fr 3fr">
22+
<Card>
23+
<Text as="h1" variant="headingSmall">
24+
Classic
25+
</Text>
26+
<Stack direction="row" gap="2">
27+
<Button onClick={() => setCount(prevCount => prevCount + 1)}>
28+
<PlusIcon />
29+
</Button>
30+
<Button onClick={() => setCount(0)}>Reset</Button>
31+
<Button onClick={() => setDarkMode(!darkMode)} sentiment="danger">
32+
Switch Theme
33+
</Button>
34+
</Stack>
35+
<Text as="p" variant="body">
36+
Count:{count}
37+
</Text>
38+
</Card>
39+
<Alert sentiment="info">Alert</Alert>
40+
</Row>
41+
</ThemeProvider>
2642
)
2743
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"@ultraviolet/fonts": "workspace:*",
136136
"@ultraviolet/themes": "workspace:*",
137137
"@ultraviolet/ui": "workspace:*",
138+
"@vanilla-extract/vite-plugin": "5.1.1",
138139
"@vitejs/plugin-react": "4.7.0",
139140
"@vitest/coverage-istanbul": "3.2.4",
140141
"@vitest/ui": "3.2.4",

0 commit comments

Comments
 (0)