mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
feat(skeleton): clsPrefix
This commit is contained in:
parent
c40e69e0fd
commit
7b1c93215f
@ -1 +1,2 @@
|
|||||||
export { default as NSkeleton } from './src/Skeleton'
|
export { default as NSkeleton } from './src/Skeleton'
|
||||||
|
export type { SkeletonProps } from './src/Skeleton'
|
||||||
|
@ -7,47 +7,55 @@ import {
|
|||||||
Fragment,
|
Fragment,
|
||||||
mergeProps
|
mergeProps
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import type { ThemeProps } from '../../_mixins'
|
import { ThemeProps, useConfig, useTheme } from '../../_mixins'
|
||||||
import { useTheme } from '../../_mixins'
|
|
||||||
import { createKey, useHoudini } from '../../_utils'
|
import { createKey, useHoudini } from '../../_utils'
|
||||||
|
import type { ExtractPublicPropTypes } from '../../_utils'
|
||||||
import type { SkeletonTheme } from '../styles'
|
import type { SkeletonTheme } from '../styles'
|
||||||
import { skeletonLight } from '../styles'
|
import { skeletonLight } from '../styles'
|
||||||
import style from './styles/index.cssr'
|
import style from './styles/index.cssr'
|
||||||
|
|
||||||
|
const skeletonProps = {
|
||||||
|
...(useTheme.props as ThemeProps<SkeletonTheme>),
|
||||||
|
text: Boolean,
|
||||||
|
round: Boolean,
|
||||||
|
circle: Boolean,
|
||||||
|
height: [String, Number] as PropType<string | number>,
|
||||||
|
width: [String, Number] as PropType<string | number>,
|
||||||
|
size: String as PropType<'small' | 'medium' | 'large'>,
|
||||||
|
repeat: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
animated: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
sharp: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type SkeletonProps = ExtractPublicPropTypes<typeof skeletonProps>
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Skeleton',
|
name: 'Skeleton',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: skeletonProps,
|
||||||
...(useTheme.props as ThemeProps<SkeletonTheme>),
|
|
||||||
text: Boolean,
|
|
||||||
round: Boolean,
|
|
||||||
circle: Boolean,
|
|
||||||
height: [String, Number],
|
|
||||||
width: [String, Number],
|
|
||||||
size: String as PropType<'small' | 'medium' | 'large'>,
|
|
||||||
repeat: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
animated: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
sharp: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setup (props) {
|
setup (props) {
|
||||||
useHoudini()
|
useHoudini()
|
||||||
|
const { mergedClsPrefix } = useConfig(props)
|
||||||
const themeRef = useTheme(
|
const themeRef = useTheme(
|
||||||
'Skeleton',
|
'Skeleton',
|
||||||
'Skeleton',
|
'Skeleton',
|
||||||
style,
|
style,
|
||||||
skeletonLight,
|
skeletonLight,
|
||||||
props
|
props,
|
||||||
|
mergedClsPrefix
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
|
cPrefix: mergedClsPrefix,
|
||||||
style: computed(() => {
|
style: computed(() => {
|
||||||
const theme = themeRef.value
|
const theme = themeRef.value
|
||||||
const {
|
const {
|
||||||
@ -96,7 +104,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render () {
|
render () {
|
||||||
const { repeat, style, $attrs } = this
|
const { repeat, style, cPrefix, $attrs } = this
|
||||||
// BUG:
|
// BUG:
|
||||||
// Chrome devtools can't read the element
|
// Chrome devtools can't read the element
|
||||||
// Maybe it's a bug of chrome
|
// Maybe it's a bug of chrome
|
||||||
@ -104,7 +112,7 @@ export default defineComponent({
|
|||||||
'div',
|
'div',
|
||||||
mergeProps(
|
mergeProps(
|
||||||
{
|
{
|
||||||
class: 'n-skeleton',
|
class: `${cPrefix}-skeleton`,
|
||||||
style: style
|
style: style
|
||||||
},
|
},
|
||||||
$attrs
|
$attrs
|
||||||
|
Loading…
Reference in New Issue
Block a user