Skip to content

Commit 015185b

Browse files
author
刘欢
committed
feat(AutoCenter): unified provision of custom prefixCls
1 parent bfde19d commit 015185b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import React from 'react'
21
import type { FC, ReactNode } from 'react'
2+
import React from 'react'
33
import { NativeProps, withNativeProps } from '../../utils/native-props'
4+
import { useConfig } from '../config-provider'
45

5-
const classPrefix = 'adm-auto-center'
6-
7-
export type AutoCenterProps = { children?: ReactNode } & NativeProps
6+
export type AutoCenterProps = {
7+
children?: ReactNode
8+
prefixCls?: string
9+
} & NativeProps
810

9-
export const AutoCenter: FC<AutoCenterProps> = props =>
10-
withNativeProps(
11+
export const AutoCenter: FC<AutoCenterProps> = props => {
12+
const { getPrefixCls } = useConfig()
13+
const prefixCls = getPrefixCls('auto-center', props.prefixCls)
14+
return withNativeProps(
1115
props,
12-
<div className={classPrefix}>
13-
<div className={`${classPrefix}-content`}>{props.children}</div>
16+
<div className={prefixCls}>
17+
<div className={`${prefixCls}-content`}>{props.children}</div>
1418
</div>
1519
)
20+
}

0 commit comments

Comments
 (0)