Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit dd3708c

Browse files
Merge pull request #241 from TylerAPfledderer/feat/add-base-theme-and-update-extend-theme
feat(core): update extendTheme imports and options
2 parents 3504bad + cbd0225 commit dd3708c

File tree

7 files changed

+91
-64
lines changed

7 files changed

+91
-64
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"@babel/preset-typescript": "^7.12.7",
8787
"@chakra-ui/anatomy": "^2.0.1",
8888
"@chakra-ui/styled-system": "^2.2.2",
89+
"@chakra-ui/theme-utils": "^2.0.6",
8990
"@chakra-ui/utils": "2.0.12",
9091
"@changesets/changelog-github": "^0.3.0",
9192
"@changesets/cli": "^2.14.1",

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@chakra-ui/c-theme-provider": "2.0.0-beta.0",
5050
"@chakra-ui/c-visually-hidden": "2.0.0-beta.0",
5151
"@chakra-ui/styled-system": "^2.2.2",
52+
"@chakra-ui/theme-utils": "^2.0.6",
5253
"@chakra-ui/utils": "2.0.12",
5354
"@chakra-ui/vue-a11y": "2.0.0-beta.0",
5455
"@chakra-ui/vue-composables": "2.0.0-beta.0",

packages/core/src/extend-theme.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

packages/core/src/helpers/plugin.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ColorModeRef } from "@chakra-ui/c-color-mode"
22
import { UnwrapRef } from "vue"
3-
import { ThemeOverride } from "../extend-theme"
3+
import { ThemeOverride } from "@chakra-ui/theme-utils"
44
import { Options } from "@emotion/cache"
55

66
interface ExtendIconsPath {
@@ -19,4 +19,5 @@ export interface ChakraPluginOptions {
1919
icons?: IconsOptions
2020
defaultColorMode?: UnwrapRef<ColorModeRef>
2121
emotionCacheOptions?: Options
22+
isBaseTheme?: boolean
2223
}

packages/core/src/index.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { computed, Plugin, ref, UnwrapRef } from "vue"
2-
import defaultTheme from "@chakra-ui/vue-theme"
2+
import { theme as defaultTheme, baseTheme, Theme } from "@chakra-ui/vue-theme"
33
import type { ColorModeRef } from "@chakra-ui/c-color-mode"
44
import { toCSSVar, WithCSSVar } from "@chakra-ui/styled-system"
55
import { chakra, injectGlobal } from "@chakra-ui/vue-system"
@@ -9,35 +9,43 @@ import {
99
} from "@chakra-ui/vue-styled"
1010
import createCache, { EmotionCache } from "@emotion/cache"
1111
import internalIcons from "./icon.internals"
12-
import { extendTheme, ThemeOverride } from "./extend-theme"
12+
import {
13+
extendTheme,
14+
extendBaseTheme,
15+
ThemeOverride,
16+
} from "@chakra-ui/theme-utils"
1317
import { MergedIcons, parseIcons } from "./parse-icons"
1418
import { injectResetStyles, injectThemeGlobalStyles } from "./helpers/css-reset"
1519
import { mode } from "@chakra-ui/vue-theme-tools"
1620
import { ChakraPluginOptions } from "./helpers/plugin.types"
21+
import { Dict } from "@chakra-ui/utils"
1722

1823
/**
1924
* 1. Support passing cache options from plugin
2025
* 2. Provide emotion theme directly from plugin
2126
* 3.
2227
*/
2328

29+
const defaultPluginOptions: ChakraPluginOptions = {
30+
cssReset: true,
31+
isBaseTheme: false,
32+
}
33+
2434
/**
2535
* Helper function to extend Chakra plugin with options
2636
* It just returns its arguments with typescript types added
2737
*/
28-
29-
export function extendChakra(
30-
options: ChakraPluginOptions = { cssReset: true }
31-
) {
38+
export function extendChakra(options = defaultPluginOptions) {
3239
return options
3340
}
3441

3542
const ChakraUIVuePlugin: Plugin = {
36-
install(app, options: ChakraPluginOptions = { cssReset: true }) {
43+
install(app, options: ChakraPluginOptions = defaultPluginOptions) {
3744
// 1. Get theme value
3845
// 2. Parse theme tokens to CSS variables
3946
// 3. Inject all CSS variables as theme object
40-
const theme = options.extendTheme || defaultTheme
47+
const theme: Theme | (Omit<Theme, "components"> & { components: Dict }) =
48+
options.extendTheme || options.isBaseTheme ? baseTheme : defaultTheme
4149
const computedTheme = computed<WithCSSVar<ThemeOverride>>(() =>
4250
toCSSVar(theme)
4351
)
@@ -106,7 +114,7 @@ const ChakraUIVuePlugin: Plugin = {
106114
export type { ChakraPluginOptions }
107115
export interface ThemeProviderProps extends ThemeOverride {}
108116
export default ChakraUIVuePlugin
109-
export { extendTheme }
117+
export { extendTheme, extendBaseTheme }
110118

111119
// Export chakra factory function
112120
export { chakra }

packages/theme/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export const theme = {
2626
config,
2727
}
2828

29+
export const baseTheme = {
30+
...foundations,
31+
components: {},
32+
styles,
33+
config,
34+
}
35+
2936
export type Theme = typeof theme
3037
export type { ColorHues }
3138

yarn.lock

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,13 @@ __metadata:
14311431
languageName: node
14321432
linkType: hard
14331433

1434+
"@chakra-ui/anatomy@npm:2.1.0":
1435+
version: 2.1.0
1436+
resolution: "@chakra-ui/anatomy@npm:2.1.0"
1437+
checksum: 76197950a1f6e0ebaec7bba845ad3993e36677f349d75b0fa0fd62719ee9fefaacf97026cd0baaa61033f5b84b44b80c37ee80c36830754576d2ee0ddbd47932
1438+
languageName: node
1439+
linkType: hard
1440+
14341441
"@chakra-ui/anatomy@npm:^2.0.1":
14351442
version: 2.0.1
14361443
resolution: "@chakra-ui/anatomy@npm:2.0.1"
@@ -1848,6 +1855,16 @@ __metadata:
18481855
languageName: unknown
18491856
linkType: soft
18501857

1858+
"@chakra-ui/styled-system@npm:2.5.0":
1859+
version: 2.5.0
1860+
resolution: "@chakra-ui/styled-system@npm:2.5.0"
1861+
dependencies:
1862+
csstype: ^3.0.11
1863+
lodash.mergewith: 4.6.2
1864+
checksum: 805e36893c4eb00cfd18cb2242fc680edfca7d01202d6172708c4a4cf70309a8b3d988d12b30f766cc554117c1e2de53a01aef85e563057d91c4876efe4c345a
1865+
languageName: node
1866+
linkType: hard
1867+
18511868
"@chakra-ui/styled-system@npm:^2.2.2":
18521869
version: 2.3.3
18531870
resolution: "@chakra-ui/styled-system@npm:2.3.3"
@@ -1858,6 +1875,18 @@ __metadata:
18581875
languageName: node
18591876
linkType: hard
18601877

1878+
"@chakra-ui/theme-tools@npm:2.0.14":
1879+
version: 2.0.14
1880+
resolution: "@chakra-ui/theme-tools@npm:2.0.14"
1881+
dependencies:
1882+
"@chakra-ui/anatomy": 2.1.0
1883+
color2k: ^2.0.0
1884+
peerDependencies:
1885+
"@chakra-ui/styled-system": ">=2.0.0"
1886+
checksum: 51275895caf9da88b47c28d9a1e965190c5fd4bfb2036f7cda4acfd308e36d220c3d3eff0e8bb6005f1a1e565cfbe7bc72bf321d0c288cd10f93bb2d1d1c4e61
1887+
languageName: node
1888+
linkType: hard
1889+
18611890
"@chakra-ui/theme-tools@npm:^2.0.2":
18621891
version: 2.0.4
18631892
resolution: "@chakra-ui/theme-tools@npm:2.0.4"
@@ -1870,6 +1899,29 @@ __metadata:
18701899
languageName: node
18711900
linkType: hard
18721901

1902+
"@chakra-ui/theme-utils@npm:^2.0.6":
1903+
version: 2.0.6
1904+
resolution: "@chakra-ui/theme-utils@npm:2.0.6"
1905+
dependencies:
1906+
"@chakra-ui/styled-system": 2.5.0
1907+
"@chakra-ui/theme": 2.2.2
1908+
lodash.mergewith: 4.6.2
1909+
checksum: 85f5fc8515165f6167d4c990f81b0aafa26e2681421692c78eb8f56f85a396856a02e77eb4fc1ef7de170e9bce17193b6c2c6220058641b80277c31ee0cad60d
1910+
languageName: node
1911+
linkType: hard
1912+
1913+
"@chakra-ui/theme@npm:2.2.2":
1914+
version: 2.2.2
1915+
resolution: "@chakra-ui/theme@npm:2.2.2"
1916+
dependencies:
1917+
"@chakra-ui/anatomy": 2.1.0
1918+
"@chakra-ui/theme-tools": 2.0.14
1919+
peerDependencies:
1920+
"@chakra-ui/styled-system": ">=2.0.0"
1921+
checksum: 150facefb731f8f2eaa4afb14d2bdeff039521491fffa9c7858a2ca58ab103ba998ea3e7dcaf7bd6116dd40eed47541ada2d39b140b8571f2a4903c497dd1cbc
1922+
languageName: node
1923+
linkType: hard
1924+
18731925
"@chakra-ui/utils@npm:2.0.12":
18741926
version: 2.0.12
18751927
resolution: "@chakra-ui/utils@npm:2.0.12"
@@ -1996,6 +2048,7 @@ __metadata:
19962048
"@chakra-ui/c-theme-provider": 2.0.0-beta.0
19972049
"@chakra-ui/c-visually-hidden": 2.0.0-beta.0
19982050
"@chakra-ui/styled-system": ^2.2.2
2051+
"@chakra-ui/theme-utils": ^2.0.6
19992052
"@chakra-ui/utils": 2.0.12
20002053
"@chakra-ui/vue-a11y": 2.0.0-beta.0
20012054
"@chakra-ui/vue-composables": 2.0.0-beta.0
@@ -5327,8 +5380,8 @@ __metadata:
53275380

53285381
"@types/react@file:stub/types__react::locator=chakra-ui-vue-next%40workspace%3A.":
53295382
version: 0.0.0
5330-
resolution: "@types/react@file:stub/types__react#stub/types__react::hash=cdf41a&locator=chakra-ui-vue-next%40workspace%3A."
5331-
checksum: ee71a1d706c7da9972c78f6ad540606c06ca943eed58582d93deedfc5b63447029e63d3532d5b69d4ae837921e4c903c0c8461feccd0166df3367a4bfa0eb794
5383+
resolution: "@types/react@file:stub/types__react#stub/types__react::hash=9ec565&locator=chakra-ui-vue-next%40workspace%3A."
5384+
checksum: 1e54fb7b3d4073e87783b945cd1a231209784ed825bac308caadaac43dd0b0676f251280fc2228346d0fd434b564ff3e5a8f7d3337e79a3e9f61f39d91435af6
53325385
languageName: node
53335386
linkType: hard
53345387

@@ -7840,6 +7893,7 @@ __metadata:
78407893
"@babel/preset-typescript": ^7.12.7
78417894
"@chakra-ui/anatomy": ^2.0.1
78427895
"@chakra-ui/styled-system": ^2.2.2
7896+
"@chakra-ui/theme-utils": ^2.0.6
78437897
"@chakra-ui/utils": 2.0.12
78447898
"@changesets/changelog-github": ^0.3.0
78457899
"@changesets/cli": ^2.14.1
@@ -8486,6 +8540,13 @@ __metadata:
84868540
languageName: node
84878541
linkType: hard
84888542

8543+
"color2k@npm:^2.0.0":
8544+
version: 2.0.0
8545+
resolution: "color2k@npm:2.0.0"
8546+
checksum: 6a425d2c3680b5de35f81d372ee2f4ed45739b234a7adb76750ec6fb8fba6a8d43b89ff1d5f009e2a4965a5b3f2f9e0d636908d41a9a7644b6e8c0145cbb7203
8547+
languageName: node
8548+
linkType: hard
8549+
84898550
"color@npm:^3.0.0":
84908551
version: 3.2.1
84918552
resolution: "color@npm:3.2.1"

0 commit comments

Comments
 (0)