Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(breadcrumb): 面包屑初始样式被覆盖 #618

Merged
merged 2 commits into from
Apr 14, 2022
Merged
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
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