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

Commit 7cbbf69

Browse files
committed
add: theme provider component
1 parent 327c72a commit 7cbbf69

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

kue.config.js renamed to kiwi.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
pallette: {
2+
palette: {
33
primary: 'hsl(209, 100%, 50%)',
44
secondary: 'hsl(278, 100%, 69%)',
55
success: 'hsl(160, 100%, 43%)',

src/App.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<div>
3+
{{ greeting }}
4+
<k-button>Simple text</k-button>
5+
</div>
6+
</template>
7+
8+
<script>
9+
import KButton from './components/Button/index'
10+
11+
export default {
12+
name: 'App',
13+
components: {
14+
KButton
15+
},
16+
data () {
17+
return {
18+
greeting: 'Hi!'
19+
}
20+
}
21+
}
22+
</script>
23+
24+
<style lang="scss" scoped>
25+
26+
</style>

src/components/Button/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<script>
2222
export default {
2323
name: 'Button',
24+
inject: ['KiwiTheme'],
2425
props: {
2526
as: {
2627
type: String,

src/components/ThemeContext/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Theme from '../../../kiwi.config'
2+
3+
/**
4+
* @type {Object}
5+
*/
6+
const ThemeProvider = {
7+
name: 'ThemeProvider',
8+
provide: {
9+
KiwiTheme: Theme
10+
},
11+
render (h) {
12+
return this.$slots.default[0]
13+
}
14+
}
15+
16+
export default ThemeProvider

src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33
import './registerServiceWorker'
4+
import ThemeProvider from './components/ThemeContext/index.js'
45

56
Vue.config.productionTip = false
67

78
new Vue({
8-
render: h => h(App)
9+
render: h => h(ThemeProvider, {}, [h(App)])
910
}).$mount('#app')

0 commit comments

Comments
 (0)