init
This commit is contained in:
29
uni_modules/nutui-uni/components/_hooks/useStyle.ts
Normal file
29
uni_modules/nutui-uni/components/_hooks/useStyle.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { computed, normalizeClass, normalizeStyle } from 'vue'
|
||||
import { stringifyStyle } from '../_utils'
|
||||
|
||||
export function useStyleContext(props: any, componentName: string) {
|
||||
const mainClass = computed(() => {
|
||||
const cls = normalizeClass([props.customClass, { [componentName]: true }])
|
||||
|
||||
return cls
|
||||
})
|
||||
|
||||
const mainStyle = computed(() => {
|
||||
return stringifyStyle(normalizeStyle(props.customStyle))
|
||||
})
|
||||
|
||||
const getMainClass = (cls: unknown) => {
|
||||
return normalizeClass([props.customClass, { [componentName]: true }, cls])
|
||||
}
|
||||
|
||||
const getMainStyle = (style: unknown) => {
|
||||
return stringifyStyle(normalizeStyle([props.customStyle, style]))
|
||||
}
|
||||
|
||||
return {
|
||||
mainClass,
|
||||
mainStyle,
|
||||
getMainClass,
|
||||
getMainStyle,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user