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

Commit 282b1d2

Browse files
committed
fix: use merged theme in memory
1 parent 7b23cab commit 282b1d2

File tree

16 files changed

+1166
-1920
lines changed

16 files changed

+1166
-1920
lines changed

package.json

Lines changed: 65 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -46,84 +46,48 @@
4646
"docs-serve": "yarn workspace chakra-ui-docs nuxt start",
4747
"evalbundle": "bundlesize",
4848
"contributors:add": "all-contributors add",
49-
"contributors:generate": "all-contributors generate"
49+
"contributors:generate": "all-contributors generate",
50+
"pkg": "manypkg run",
51+
"pkgs:check": "manypkg check",
52+
"pkgs:fix": "manypkg fix"
5053
},
5154
"dependencies": {
52-
"@chakra-ui/styled-system": "^1.12.1",
53-
"@emotion/css": "^11.0.0",
54-
"@mdx-js/vue-loader": "^1.6.1",
55-
"@nuxtjs/dotenv": "^1.4.0",
56-
"@nuxtjs/emotion": "^0.1.0",
57-
"@nuxtjs/now-builder": "^0.17.1",
58-
"@nuxtjs/router": "^1.5.0",
59-
"@popperjs/core": "^2.4.0",
60-
"@storybook/addon-actions": "^5.2.1",
61-
"@storybook/addon-centered": "^5.2.1",
62-
"@storybook/addon-links": "^5.2.1",
63-
"@storybook/addons": "^5.2.1",
64-
"@storybook/storybook-deployer": "^2.8.1",
65-
"@storybook/theming": "^5.2.8",
66-
"@storybook/vue": "^5.3.3",
67-
"aria-hidden": "^1.1.1",
68-
"breadstick": "^0.2.14",
69-
"can-use-dom": "^0.1.0",
70-
"chakra-loader": "latest",
71-
"color": "^3.1.2",
72-
"copy-to-clipboard": "^3.3.1",
73-
"core-js": "^3.6.4",
74-
"defu": "^2.0.4",
75-
"dotenv-defaults": "^1.1.1",
76-
"eslint": "^5.16.0",
77-
"eslint-plugin-vue": "^5.0.0",
78-
"eslint-plugin-vue-a11y": "^0.0.31",
79-
"feather-icons-paths": "^1.0.8",
80-
"file-contributors": "^1.0.2",
81-
"focus-trap": "^5.1.0",
82-
"focus-trap-vue": "^0.0.4",
83-
"husky": "^3.0.8",
84-
"install": "^0.13.0",
85-
"lerna": "^3.20.2",
86-
"lint-staged": "^9.4.2",
87-
"mdx-vue": "^1.0.2",
88-
"mdx-vue-loader": "^1.0.2",
89-
"node-fetch": "^2.6.0",
90-
"nuxt": "2.14.6",
91-
"portal-vue": "^2.1.6",
92-
"prismjs": "^1.19.0",
93-
"register-service-worker": "^1.6.2",
94-
"sass-loader": "^8.0.2",
95-
"v-scroll-lock": "^1.1.0",
96-
"vue": "^2.6.11",
97-
"vue-error-boundary": "^1.0.3",
98-
"vue-live": "1.5.1",
99-
"vue-loader": "^15.7.1",
100-
"vue-lorem-ipsum": "^0.0.1",
101-
"vue-meta": "^2.3.3",
102-
"vue-prism-editor": "^0.5.1",
103-
"vue-router": "^3.1.6",
104-
"vue-template-compiler": "^2.6.11"
105-
},
106-
"devDependencies": {
10755
"@babel/cli": "^7.8.4",
108-
"@babel/core": "^7.9.0",
56+
"@babel/core": "^7.9.6",
10957
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
11058
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
11159
"@babel/plugin-transform-modules-commonjs": "^7.7.4",
11260
"@babel/plugin-transform-parameters": "^7.7.4",
11361
"@babel/preset-env": "^7.15.0",
11462
"@babel/runtime-corejs2": "^7.8.7",
63+
"@chakra-ui/styled-system": "^1.12.2",
11564
"@changesets/changelog-github": "^0.2.7",
11665
"@changesets/cli": "^2.7.1",
11766
"@changesets/get-github-info": "^0.4.4",
118-
"@commitlint/cli": "^8.2.0",
119-
"@commitlint/config-conventional": "^8.2.0",
67+
"@commitlint/cli": "^8.3.5",
68+
"@commitlint/config-conventional": "^8.3.4",
12069
"@emotion/babel-plugin": "^11.1.2",
70+
"@emotion/css": "^11.0.0",
12171
"@emotion/eslint-plugin": "^11.0.0",
12272
"@emotion/jest": "^11.3.0",
73+
"@manypkg/cli": "^0.18.0",
74+
"@mdx-js/vue-loader": "^1.6.1",
75+
"@nuxtjs/dotenv": "^1.4.0",
76+
"@nuxtjs/emotion": "^0.1.0",
12377
"@nuxtjs/eslint-config": "^3.0.0",
12478
"@nuxtjs/eslint-module": "^1.0.0",
12579
"@nuxtjs/google-analytics": "^2.4.0",
12680
"@nuxtjs/module-test-utils": "^1.6.1",
81+
"@nuxtjs/now-builder": "^0.17.1",
82+
"@nuxtjs/router": "^1.5.0",
83+
"@popperjs/core": "^2.4.0",
84+
"@storybook/addon-actions": "^5.2.1",
85+
"@storybook/addon-centered": "^5.2.1",
86+
"@storybook/addon-links": "^5.2.1",
87+
"@storybook/addons": "^5.2.1",
88+
"@storybook/storybook-deployer": "^2.8.1",
89+
"@storybook/theming": "^5.2.8",
90+
"@storybook/vue": "^5.3.3",
12791
"@testing-library/jest-dom": "^5.1.1",
12892
"@testing-library/user-event": "^10.0.0",
12993
"@testing-library/vue": "^4.1.0",
@@ -140,10 +104,11 @@
140104
"@vue/test-utils": "1.0.0-beta.29",
141105
"add": "^2.0.6",
142106
"all-contributors-cli": "^6.20.0",
107+
"aria-hidden": "^1.1.1",
143108
"babel-core": "7.0.0-bridge.0",
144109
"babel-eslint": "^10.1.0",
145110
"babel-helper-vue-jsx-merge-props": "^2.0.3",
146-
"babel-jest": "^23.6.0",
111+
"babel-jest": "^25.5.1",
147112
"babel-loader": "^8.0.6",
148113
"babel-plugin-syntax-jsx": "^6.18.0",
149114
"babel-plugin-transform-es2015-for-of": "^6.23.0",
@@ -152,15 +117,45 @@
152117
"babel-preset-es2015": "^6.24.1",
153118
"babel-preset-vue": "^2.0.2",
154119
"babelrc-rollup": "^3.0.0",
120+
"breadstick": "^0.2.14",
155121
"bundlesize": "^0.18.0",
122+
"can-use-dom": "^0.1.0",
123+
"chakra-loader": "latest",
124+
"color": "^3.1.2",
125+
"copy-to-clipboard": "^3.3.1",
126+
"core-js": "^3.6.4",
156127
"cross-env": "^7.0.2",
128+
"defu": "^2.0.4",
129+
"dotenv-defaults": "^1.1.1",
130+
"eslint": "^7.12.1",
157131
"eslint-config-prettier": "^6.10.0",
132+
"eslint-config-standard": "^16.0.3",
158133
"eslint-loader": "^3.0.3",
134+
"eslint-plugin-import": "^2.22.1",
135+
"eslint-plugin-node": "^11.1.0",
159136
"eslint-plugin-nuxt": ">=0.4.2",
160137
"eslint-plugin-prettier": "^3.1.2",
138+
"eslint-plugin-promise": "^4.2.1",
161139
"eslint-plugin-testing-library": "^3.3.1",
162-
"jest": "^25.1.0",
140+
"eslint-plugin-vue": "^5.0.0",
141+
"eslint-plugin-vue-a11y": "^0.0.31",
142+
"feather-icons-paths": "^1.0.8",
143+
"file-contributors": "^1.0.2",
144+
"focus-trap": "^5.1.0",
145+
"focus-trap-vue": "^0.0.4",
146+
"husky": "^4.2.5",
147+
"install": "^0.13.0",
148+
"jest": "^25.5.2",
149+
"lerna": "^3.20.2",
150+
"lint-staged": "^10.0.0",
151+
"mdx-vue": "^1.0.2",
152+
"mdx-vue-loader": "^1.0.2",
153+
"node-fetch": "^2.6.0",
154+
"nuxt": "2.14.6",
155+
"portal-vue": "^2.1.6",
163156
"prettier": "^1.19.1",
157+
"prismjs": "^1.19.0",
158+
"register-service-worker": "^1.6.2",
164159
"rimraf": "^3.0.2",
165160
"rollup": "^1.31.1",
166161
"rollup-plugin-babel": "^4.3.3",
@@ -172,9 +167,18 @@
172167
"rollup-plugin-scss": "^2.1.0",
173168
"rollup-plugin-terser": "^5.1.2",
174169
"rollup-plugin-vue": "^5.1.4",
170+
"sass-loader": "^8.0.2",
175171
"v-scroll-lock": "^1.1.0",
172+
"vue": "^2.6.12",
173+
"vue-error-boundary": "^1.0.3",
174+
"vue-live": "1.5.1",
176175
"vue-loader": "^15.7.1",
177176
"vue-lorem-ipsum": "^0.0.1",
177+
"vue-meta": "^2.3.3",
178+
"vue-prism-editor": "^0.5.1",
179+
"vue-router": "^3.1.6",
180+
"vue-server-renderer": "2.6.12",
181+
"vue-template-compiler": "2.6.12",
178182
"watch": "^1.0.2",
179183
"yarn": "^1.22.10"
180184
},

packages/chakra-ui-core/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"max-overall-size": "85KB"
3737
},
3838
"dependencies": {
39-
"@chakra-ui/styled-system": "^1.12.1",
39+
"@chakra-ui/styled-system": "^1.12.2",
4040
"@popperjs/core": "^2.4.0",
4141
"animejs": "^3.1.0",
4242
"aria-hidden": "^1.1.1",
@@ -50,11 +50,13 @@
5050
},
5151
"peerDependencies": {
5252
"@emotion/css": "^11.0.0",
53-
"vue": "^2.6.10"
53+
"vue": ">=2.6.10"
5454
},
5555
"devDependencies": {
56+
"@emotion/css": "^11.0.0",
5657
"@fortawesome/fontawesome-common-types": "^0.2.36",
57-
"rimraf": "^3.0.2"
58+
"rimraf": "^3.0.2",
59+
"vue": "^2.6.12"
5860
},
5961
"keywords": [
6062
"vue",

packages/chakra-ui-core/rollup.config.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ import path from 'path'
33
import babel from 'rollup-plugin-babel'
44
import resolve from 'rollup-plugin-node-resolve'
55
import cjs from 'rollup-plugin-commonjs'
6-
import { terser } from 'rollup-plugin-terser'
76
import buble from 'rollup-plugin-buble'
87
import scss from 'rollup-plugin-scss'
98
import vue from 'rollup-plugin-vue'
109
import pkg from './package.json'
1110

12-
const production = !process.env.ROLLUP_WATCH
13-
1411
// Plugins
1512
const bubelConfig = buble({
1613
objectAssign: 'Object.assign',
@@ -65,8 +62,8 @@ const commons = {
6562
'node_modules/object-assign/index.js': ['assign']
6663
},
6764
include: /node_modules/
68-
}),
69-
production && terser()
65+
})
66+
// production && terser()
7067
]
7168
}
7269

packages/chakra-ui-core/src/CButton/CButton.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { buttonProps } from './utils/button.props'
2828
* @see Docs https://vue.chakra-ui.com/button
2929
*/
3030
const CButtonIcon = {
31-
name: 'CBreadcrumb',
3231
mixins: [createStyledAttrsMixin('CButtonIcon', true)],
3332
props: {
3433
icon: {

packages/chakra-ui-core/src/CThemeProvider/CThemeProvider.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const CThemeProvider = {
1919
provide () {
2020
return {
2121
$chakraTheme: () => this.theme,
22+
$chakraRawTheme: () => this.theme,
2223
$chakraIcons: this.icons,
2324
/**
2425
* By default the ThemeProvider exposes a colorMode value of light

packages/chakra-ui-core/src/Chakra/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const Chakra = {
3636
// Recursively merge extended theme variables
3737
const mergedTheme = toCSSVar(merge(defaultTheme, options.extendTheme))
3838

39+
console.log('mergedTheme', mergedTheme)
40+
3941
Vue.directive('chakra', createClientDirective(mergedTheme))
4042

4143
// Bind theme and icons to prototype

packages/chakra-ui-core/src/utils/components.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { css } from '@emotion/css'
22
import { runIfFn } from '@chakra-ui/utils'
3-
import { composeSystem, __get } from './styled-system'
3+
import { css as _css } from '@chakra-ui/styled-system'
4+
import { __get } from './styled-system'
45
import { hasOwn, extractChakraAttrs } from './object'
56

67
export const isVueComponent = (value) => {
@@ -37,7 +38,7 @@ export function createWatcher (property) {
3738
export const createStyledAttrsMixin = name => ({
3839
name,
3940
inheritAttrs: false,
40-
inject: ['$chakraTheme', '$chakraColorMode'],
41+
inject: ['$chakraTheme', '$chakraRawTheme', '$chakraColorMode'],
4142
data () {
4243
return {
4344
attrs$: {},
@@ -58,6 +59,9 @@ export const createStyledAttrsMixin = name => ({
5859
theme () {
5960
return this.$chakraTheme()
6061
},
62+
rawTheme () {
63+
return this.$chakraRawTheme()
64+
},
6165
/** Split style attributes and native attributes */
6266
splitProps () {
6367
const $attrs = this.$data.attrs$
@@ -80,14 +84,23 @@ export const createStyledAttrsMixin = name => ({
8084
className () {
8185
const { styleAttrs } = this.splitProps
8286

83-
const boxStylesObject = composeSystem(
84-
{
85-
...this.componentStyles || {},
86-
...this.baseStyle,
87-
...styleAttrs
88-
},
89-
this.theme
90-
)
87+
// console.log(name, this.componentStyles)
88+
89+
// const boxStylesObject = composeSystem(
90+
// {
91+
// ...this.componentStyles || {},
92+
// ...this.baseStyle,
93+
// ...styleAttrs
94+
// },
95+
// this.theme
96+
// )
97+
const merged = {
98+
...this.componentStyles || {},
99+
...this.baseStyle,
100+
...styleAttrs
101+
}
102+
const boxStylesObject = _css(merged)(this.theme)
103+
91104
return css(boxStylesObject)
92105
},
93106
/** Computed attributes object */

packages/chakra-ui-nuxt/lib/module.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { resolve } = require('path')
22
const defu = require('defu')
3-
const { defaultTheme, parsePackIcons, internalIcons, createServerDirective } = require('@chakra-ui/vue')
3+
const { parsePackIcons, internalIcons, createServerDirective } = require('@chakra-ui/vue')
4+
const defaultTheme = require('@chakra-ui/theme-vue')
45
const { ChakraLoaderPlugin } = require('chakra-loader')
6+
const { toCSSVar } = require('@chakra-ui/styled-system')
57

68
module.exports = function (moduleOptions) {
79
const { nuxt } = this
@@ -15,7 +17,7 @@ module.exports = function (moduleOptions) {
1517
}
1618

1719
// Recursively merge extended theme variables
18-
const theme = defu(options.extendTheme, defaultTheme)
20+
const mergedTheme = toCSSVar(defu(options.extendTheme, defaultTheme.default))
1921

2022
// Resolve icons
2123
let packIcons = {}
@@ -30,10 +32,10 @@ module.exports = function (moduleOptions) {
3032
nuxt.options.build.transpile.push('@chakra-ui')
3133

3234
if (nuxt.options.render.bundleRenderer.directives) {
33-
nuxt.options.render.bundleRenderer.directives.chakra = createServerDirective(theme)
35+
nuxt.options.render.bundleRenderer.directives.chakra = createServerDirective(mergedTheme)
3436
} else {
3537
nuxt.options.render.bundleRenderer.directives = {
36-
chakra: createServerDirective(theme)
38+
chakra: createServerDirective(mergedTheme)
3739
}
3840
}
3941

@@ -52,14 +54,14 @@ module.exports = function (moduleOptions) {
5254
)
5355
})
5456
}
55-
5657
// Global bindings and plugins
5758
this.addPlugin({
5859
src: resolve(__dirname, 'plugin.js'),
5960
fileName: 'chakra.js',
6061
options: {
61-
theme,
62-
icons
62+
theme: mergedTheme,
63+
icons,
64+
extendTheme: options.extendTheme
6365
}
6466
})
6567
}

0 commit comments

Comments
 (0)