import { computed, CSSProperties, defineComponent, PropType } from 'vue'; import { createNamespace } from '../utils'; const [name, bem] = createNamespace('config-provider'); export function kebabCase(word: string) { return word .replace(/([A-Z])/g, '-$1') .toLowerCase() .replace(/^-/, ''); } function mapThemeVarsToCSSVars(themeVars: Record) { const cssVars: Record = {}; Object.keys(themeVars).forEach((key) => { cssVars[`--van-${kebabCase(key)}`] = themeVars[key]; }); return cssVars; } export default defineComponent({ name, props: { themeVars: Object as PropType>, }, setup(props, { slots }) { const style = computed(() => { if (props.themeVars) { return mapThemeVarsToCSSVars(props.themeVars); } }); return () => (
{slots.default?.()}
); }, });