Skip to content

Commit

Permalink
Merge pull request #618 from yatessss/fix/breadcrumb-class
Browse files Browse the repository at this point in the history
fix(breadcrumb): 面包屑初始样式被覆盖
  • Loading branch information
honkinglin authored Apr 14, 2022
2 parents b278a54 + cab8450 commit 759ca48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import classNames from 'classnames';
import useConfig from '../_util/useConfig';
import forwardRefWithStatics from '../_util/forwardRefWithStatics';
import { BreadcrumbItem } from './BreadcrumbItem';
Expand All @@ -7,7 +8,7 @@ import { BreadcrumbContext } from './BreadcrumbContext';

const Breadcrumb = forwardRefWithStatics(
(props: BreadcrumbProps, ref) => {
const { children, options, separator, maxItemWidth, theme, ...restProps } = props;
const { children, options, separator, maxItemWidth, theme, className, ...restProps } = props;
const { classPrefix } = useConfig();

let content = children;
Expand Down Expand Up @@ -38,7 +39,7 @@ const Breadcrumb = forwardRefWithStatics(
separator,
}}
>
<div ref={ref} className={`${classPrefix}-breadcrumb`} {...restProps}>
<div ref={ref} className={classNames(`${classPrefix}-breadcrumb`, className)} {...restProps}>
{content}
</div>
</BreadcrumbContext.Provider>
Expand Down
18 changes: 15 additions & 3 deletions src/breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ import { BreadcrumbItemProps } from './BreadcrumbProps';
import { BreadcrumbContext } from './BreadcrumbContext';

export const BreadcrumbItem = forwardRef<HTMLDivElement, BreadcrumbItemProps>((props, ref) => {
const { children, separator, disabled, maxItemWidth, maxWidth, href, to, target, router, replace, ...restProps } =
props;
const {
children,
separator,
disabled,
maxItemWidth,
maxWidth,
href,
to,
target,
router,
replace,
className,
...restProps
} = props;

const { maxItemWidthInContext, theme, separator: separatorInContext } = useContext(BreadcrumbContext);

Expand Down Expand Up @@ -58,7 +70,7 @@ export const BreadcrumbItem = forwardRef<HTMLDivElement, BreadcrumbItemProps>((p
);

return (
<div className={classNames(breadcrumbItemClassNames, theme)} ref={ref} {...restProps}>
<div className={classNames(breadcrumbItemClassNames, theme, className)} ref={ref} {...restProps}>
{itemContent}
<span className={separatorClassName}>{separatorContent}</span>
</div>
Expand Down

0 comments on commit 759ca48

Please sign in to comment.