Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/components/divider/divider.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@class-prefix-divider: ~'adm-divider';

.@{class-prefix-divider} {
}

.adm-divider-horizontal {
.@{class-prefix-divider}-horizontal {
display: flex;
align-items: center;
margin: 16px 0;
Expand All @@ -12,10 +9,10 @@
border-style: solid;
color: var(--adm-color-weak);
font-size: 14px;
.adm-divider-left&::before {
.@{class-prefix-divider}-left&::before {
max-width: 10%;
}
.adm-divider-right&::after {
.@{class-prefix-divider}-right&::after {
max-width: 10%;
}
&::after,
Expand All @@ -27,13 +24,13 @@
border-color: inherit;
border-width: 1px 0 0;
}
.adm-divider-content {
.@{class-prefix-divider}-content {
flex: none;
padding: 0 16px;
}
}

.adm-divider-vertical {
.@{class-prefix-divider}-vertical {
position: relative;
top: -0.06em;
display: inline-block;
Expand Down
14 changes: 8 additions & 6 deletions src/components/divider/divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import type { FC, ReactNode } from 'react'
import classNames from 'classnames'
import { NativeProps, withNativeProps } from '../../utils/native-props'
import { mergeProps } from '../../utils/with-default-props'

const classPrefix = `adm-divider`
import { useConfig } from '../config-provider'

export type DividerProps = {
contentPosition?: 'left' | 'right' | 'center'
direction?: 'horizontal' | 'vertical'
children?: ReactNode
prefixCls?: string
} & NativeProps

const defaultProps = {
Expand All @@ -19,17 +19,19 @@ const defaultProps = {

export const Divider: FC<DividerProps> = p => {
const props = mergeProps(defaultProps, p)
const { getPrefixCls } = useConfig()
const prefixCls = getPrefixCls('divider', props.prefixCls)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

此更改引入了可自定义的 prefixCls,但 src/components/divider/divider.less 中的 CSS 样式仍然硬编码使用了 adm-divider 前缀(例如在第 6 行的 .adm-divider-horizontal 和第 36 行的 .adm-divider-vertical)。当使用自定义前缀时,这将导致组件样式失效。为了让此功能正常工作,需要更新 .less 文件以使用变量来构造所有相关的 CSS 选择器,例如使用 .@{class-prefix-divider}-horizontal 而不是 .adm-divider-horizontal

return withNativeProps(
props,
<div
className={classNames(
classPrefix,
`${classPrefix}-${props.direction}`,
`${classPrefix}-${props.contentPosition}`
prefixCls,
`${prefixCls}-${props.direction}`,
`${prefixCls}-${props.contentPosition}`
)}
>
{props.children && (
<div className={`${classPrefix}-content`}>{props.children}</div>
<div className={`${prefixCls}-content`}>{props.children}</div>
)}
</div>
)
Expand Down
12 changes: 7 additions & 5 deletions src/components/dot-loading/dot-loading.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import classNames from 'classnames'
import React, { memo } from 'react'
import { mergeProps } from '../../utils/with-default-props'
import { NativeProps, withNativeProps } from '../../utils/native-props'
import classNames from 'classnames'

const classPrefix = `adm-dot-loading`
import { mergeProps } from '../../utils/with-default-props'
import { useConfig } from '../config-provider'

const colorRecord: Record<string, string> = {
default: 'var(--adm-color-weak)',
Expand All @@ -13,6 +12,7 @@ const colorRecord: Record<string, string> = {

export type DotLoadingProps = {
color?: 'default' | 'primary' | 'white' | (string & {})
prefixCls?: string
} & NativeProps

const defaultProps = {
Expand All @@ -21,13 +21,15 @@ const defaultProps = {

export const DotLoading = memo<DotLoadingProps>(p => {
const props = mergeProps(defaultProps, p)
const { getPrefixCls } = useConfig()
const prefixCls = getPrefixCls('dot-loading', props.prefixCls)
return withNativeProps(
props,
<div
style={{
color: colorRecord[props.color] ?? props.color,
}}
className={classNames('adm-loading', classPrefix)}
className={classNames('adm-loading', prefixCls)}
>
<svg
height='1em'
Expand Down
Loading