mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2025-07-05 03:23:13 +08:00
feat: add theme
This commit is contained in:
30
components/theme/index.ts
Normal file
30
components/theme/index.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { createTheme, useCacheToken } from '@antd-tiny-vue/cssinjs'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export interface ThemeToken {
|
||||
primaryColor: string
|
||||
}
|
||||
|
||||
export const defaultTheme: ThemeToken = {
|
||||
primaryColor: '#1890ff'
|
||||
}
|
||||
|
||||
function derivative(theme: ThemeToken) {
|
||||
return {
|
||||
...theme
|
||||
}
|
||||
}
|
||||
|
||||
const theme = createTheme(derivative)
|
||||
|
||||
export const useToken = () => {
|
||||
const mergedTheme = computed(() => theme)
|
||||
const cacheToken = useCacheToken(
|
||||
mergedTheme,
|
||||
computed(() => [defaultTheme]),
|
||||
computed(() => ({
|
||||
salt: 'true'
|
||||
}))
|
||||
)
|
||||
return [mergedTheme, computed(() => cacheToken.value[0]), computed(() => cacheToken.value[1])]
|
||||
}
|
Reference in New Issue
Block a user