feat(element): expose css variables

This commit is contained in:
07akioni 2020-11-13 18:58:58 +08:00
parent 8e395cfe8b
commit 7172519089
7 changed files with 61 additions and 2 deletions

View File

@ -1,16 +1,19 @@
import { h } from 'vue'
import {
configurable,
themeable
themeable,
withCssr
} from '../../_mixins'
import styleScheme from '../../_deprecated/style-scheme'
import style from './styles'
import { warn } from '../../_utils/naive/warn'
export default {
name: 'Element',
mixins: [
configurable,
themeable
themeable,
withCssr(style)
],
props: {
tag: {
@ -49,6 +52,7 @@ export default {
} = this
return h(as || tag, {
class: {
'n-element': true,
[`n-${mergedTheme}-theme`]: mergedTheme
}
}, ($slots.default && $slots.default({

View File

@ -0,0 +1,11 @@
import themedBaseStyle from './themed-base.cssr.js'
export default [
{
key: 'mergedTheme',
watch: [
'mergedTheme'
],
CNode: themedBaseStyle
}
]

View File

@ -0,0 +1,14 @@
import { kebabCase } from 'lodash-es'
import { c, cTB } from '../../../_utils/cssr'
export default c([
({ props }) => {
const { $local } = props
return cTB('element',
Object.keys($local).reduce((vars, key) => {
vars[`--${kebabCase(key)}`] = $local[key]
return vars
}, {})
)
}
])

View File

@ -0,0 +1,12 @@
import create from '../../_styles/utils/create-component-base'
export default create({
theme: 'dark',
name: 'Element',
getDerivedVariables ({ base, derived }) {
return {
...base,
...derived
}
}
})

View File

@ -0,0 +1,2 @@
export { default as elementDark } from './dark'
export { default as elementLight } from './light'

View File

@ -0,0 +1,12 @@
import create from '../../_styles/utils/create-component-base'
export default create({
theme: 'light',
name: 'Element',
getDerivedVariables ({ base, derived }) {
return {
...base,
...derived
}
}
})

View File

@ -52,6 +52,10 @@ export {
tabsDark,
tabsLight
} from './tabs/styles'
export {
elementDark,
elementLight
} from './element/styles'
export {
treeDark,
treeLight