Skip to content

Commit b272421

Browse files
committed
fix: resolve an issue that the font family was not corretly resolved
1 parent 0069646 commit b272421

File tree

2 files changed

+45
-32
lines changed

2 files changed

+45
-32
lines changed

.storybook/ThemeProvider.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { ChakraProvider, theme as baseTheme, extendTheme, useColorMode } from '@chakra-ui/react'
1+
import { ChakraProvider, extendTheme, useColorMode } from '@chakra-ui/react'
22
import '@fontsource-variable/open-sans'
33
import '@fontsource-variable/spline-sans'
44
import { Fragment, ReactNode, useEffect } from 'react'
5-
import { theme as proTheme } from '../src'
5+
import { theme } from '../src'
66

77
type Props = {
88
colorMode: 'dark' | 'light'
99
children?: ReactNode | undefined
1010
}
1111

1212
export const ThemeProvider = (props: Props) => {
13-
const theme = extendTheme(
14-
{
15-
colors: { ...baseTheme.colors, brand: baseTheme.colors.teal },
16-
},
17-
proTheme,
18-
)
13+
const proTheme = extendTheme(theme)
14+
const extenstion = {
15+
colors: { ...proTheme.colors, brand: proTheme.colors.teal },
16+
}
17+
const myTheme = extendTheme(extenstion, proTheme)
18+
1919
return (
20-
<ChakraProvider theme={theme}>
20+
<ChakraProvider theme={myTheme}>
2121
<Main {...props} />
2222
</ChakraProvider>
2323
)

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,40 @@ npm install @chakra-ui/pro-theme
2020

2121
## Setting up the Pro Theme
2222

23-
Setting up the Pro Theme is a straightforward process. The Pro Theme extends the base theme from Chakra UI and can be incorporated in a few simple steps.
24-
Import the Pro Theme and the base theme from Chakra UI:
23+
Setting up the Pro Theme is a straightforward process.
24+
25+
### 1. Import Required Themes
26+
27+
Firstly, you'll need to import the `theme` from the pro theme package nd the `extendTheme` function provided by Chakra UI. Use the following code snippet:
2528

2629
```typescript
27-
import { theme as proTheme } from '@chakra-ui/pro-theme'
28-
import { extendTheme, theme as baseTheme } from '@chakra-ui/react'
30+
import { theme } from '@chakra-ui/pro-theme'
31+
import { extendTheme, ChakraProvider } from '@chakra-ui/react'
2932
```
3033

31-
Next, extend the base theme with our Pro Theme:
34+
### 2. Create the Extended Theme
35+
36+
Next, create a new theme that combines the Pro Theme with your custom settings.
3237

3338
```javascript
34-
export const theme = extendTheme(
35-
{
36-
colors: { ...baseTheme.colors, brand: baseTheme.colors.blue },
37-
},
38-
proTheme,
39-
)
39+
const proTheme = extendTheme(theme)
40+
const extendedConfig = {
41+
colors: { ...proTheme.colors, brand: proTheme.colors.teal },
42+
}
43+
const myTheme = extendTheme(extendedConfig, proTheme)
4044
```
4145

42-
This code snippet imports the Pro Theme and the base theme from Chakra UI. It then uses the `extendTheme` function from Chakra UI to merge the Pro Theme with your custom configuration.
46+
### 3. Integrate your Theme in Your Application
47+
48+
Finally, wrap your application within the `ChakraProvider` and apply the custom theme.
49+
50+
```javascript
51+
return (
52+
<ChakraProvider theme={myTheme}>
53+
<App />
54+
</ChakraProvider>
55+
)
56+
```
4357

4458
## Font Configuration
4559

@@ -69,20 +83,19 @@ yarn add @fontsource-variable/inter
6983
Then, import the font and adjust the `fonts` key in your theme configuration:
7084

7185
```javascript
72-
import { theme as proTheme } from '@chakra-ui/pro-theme'
73-
import { extendTheme, theme as baseTheme } from '@chakra-ui/react'
86+
import { theme } from '@chakra-ui/pro-theme'
87+
import { extendTheme } from '@chakra-ui/react'
7488
import '@fontsource-variable/inter'
7589

76-
export const theme = extendTheme(
77-
{
78-
colors: { ...baseTheme.colors, brand: baseTheme.colors.blue },
79-
fonts: {
80-
heading: "'Inter Variable', -apple-system, system-ui, sans-serif",
81-
body: "'Inter Variable', -apple-system, system-ui, sans-serif",
82-
},
90+
const proTheme = extendTheme(theme)
91+
const extenstion = {
92+
colors: { ...proTheme.colors, brand: proTheme.colors.teal },
93+
fonts: {
94+
heading: "'Inter Variable', -apple-system, system-ui, sans-serif",
95+
body: "'Inter Variable', -apple-system, system-ui, sans-serif",
8396
},
84-
proTheme,
85-
)
97+
}
98+
const myTheme = extendTheme(extenstion, proTheme)
8699
```
87100

88101
## Generating Theme Typings

0 commit comments

Comments
 (0)