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

Commit 4d2d0f7

Browse files
committed
feat(themeprovider): add theme provider components and provide theme from plugin)
1 parent 9244cf7 commit 4d2d0f7

File tree

14 files changed

+103
-19
lines changed

14 files changed

+103
-19
lines changed

_templates/generator/component/package.json.ejs.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ to: packages/<%=h.changeCase.paramCase(name)%>/package.json
2020
"build": "concurrently yarn:build:*",
2121
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
2222
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
23-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types"
23+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
24+
"watch": "concurrently yarn:watch:*",
25+
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps --watch",
26+
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps --watch",
27+
"watch:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
2428
}
2529
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"playground:routes": "ts-node ./scripts/parse-routes.ts",
1717
"dev": "yarn playground:routes && NODE_ENV=development vite serve playground --config ./vite.config.ts",
1818
"playground:build": "yarn install && yarn build && yarn playground:routes && NODE_ENV=production vite build playground",
19+
"core": "yarn workspace @chakra-ui/vue-next",
1920
"c-alert": "yarn workspace @chakra-ui/c-alert",
21+
"c-theme-provider": "yarn workspace @chakra-ui/c-theme-provider",
2022
"c-box": "yarn workspace @chakra-ui/c-box",
2123
"c-button": "yarn workspace @chakra-ui/c-button",
2224
"system": "yarn workspace @chakra-ui/system-vue",

packages/c-alert/examples/base-alert.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
font-weight="bold"
44
px="4"
55
py="3"
6-
bg="yellow.300"
6+
:bg="['yellow.300', 'blue.200']"
77
aria-role="alert"
88
rounded="md"
99
>

packages/c-alert/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ const CAlert = defineComponent({
1313
setup(props, { slots, attrs }) {
1414
return () =>
1515
h(
16-
chakra[props.as],
16+
chakra(props.as, 'alert'),
1717
{
1818
...attrs,
19-
class: 'chakra-alert',
2019
role: 'alert',
2120
},
2221
slots

packages/c-box/examples/base-box.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default defineComponent({
1313
components: { CBox },
1414
setup() {
1515
const val = ref('Hello box')
16-
console.log('Base box setup ')
1716
1817
return { val }
1918
},
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@chakra-ui/c-theme-provider",
3+
"version": "1.0.0",
4+
"main": "dist/cjs/index.js",
5+
"module": "dist/esm/index.js",
6+
"types": "dist/types/index.d.ts",
7+
"typings": "dist/types/index.d.ts",
8+
"files": [
9+
"dist"
10+
],
11+
"description": "Chakra UI Vue | CThemeProvider component",
12+
"repository": "https://github.com/chakra-ui/chakra-ui-vue-next.git",
13+
"author": "Jonathan Bakebwa [email protected]",
14+
"license": "MIT",
15+
"scripts": {
16+
"build": "concurrently yarn:build:*",
17+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
18+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
19+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
20+
"watch": "concurrently yarn:watch:*",
21+
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps --watch",
22+
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps --watch",
23+
"watch:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {
2+
h,
3+
defineComponent,
4+
Fragment,
5+
PropType,
6+
provide,
7+
inject,
8+
computed,
9+
} from 'vue'
10+
import { ThemeProviderProps } from '@chakra-ui/vue-next'
11+
12+
const CThemeProvider = defineComponent({
13+
name: 'CAlert',
14+
props: {
15+
value: {
16+
type: [Object] as PropType<ThemeProviderProps>,
17+
default: () => undefined,
18+
},
19+
},
20+
setup(props, { slots }) {
21+
const pluginTheme = inject('$chakraTheme')
22+
const applicationTheme = computed(() => props.value || pluginTheme)
23+
provide('$chakraTheme', applicationTheme.value)
24+
return () => h(Fragment, slots.default?.({ $chakraTheme: props.value }))
25+
},
26+
})
27+
28+
export default CThemeProvider
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { render } from '@chakra-ui/vue-test-utils'
2+
import CThemeProvider from '../'
3+
4+
it('should render properly', () => {
5+
const { html } = render(CThemeProvider)
6+
expect(html()).toMatchSnapshot()
7+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src"]
4+
}

packages/core/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"build": "concurrently yarn:build:*",
1717
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
1818
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
19-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types"
19+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
20+
"watch": "concurrently yarn:watch:*",
21+
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps --watch",
22+
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps --watch",
23+
"watch:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
2024
}
2125
}

0 commit comments

Comments
 (0)