Skip to content

Commit

Permalink
fixup! Refactor(web-react): Use class name prefix for utilities and h…
Browse files Browse the repository at this point in the history
…elpers
  • Loading branch information
literat committed Sep 13, 2023
1 parent 2c42cec commit 48307e6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/web-react/src/components/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { ElementType } from 'react';
import classNames from 'classnames';
import { useBreadcrumbsStyleProps } from './useBreadcrumbsStyleProps';
import { SpiritBreadcrumbsProps } from '../../types';
import React, { ElementType } from 'react';
import { useClassNamePrefix } from '../../hooks';
import { useStyleProps } from '../../hooks/styleProps';
import { SpiritBreadcrumbsProps } from '../../types';
import { Icon } from '../Icon';
import { Link } from '../Link';
import { useBreadcrumbsStyleProps } from './useBreadcrumbsStyleProps';

const defaultProps = {
items: [],
Expand All @@ -15,6 +16,10 @@ export const Breadcrumbs = <T extends ElementType = 'nav'>(props: SpiritBreadcru
const { classProps, props: modifiedProps } = useBreadcrumbsStyleProps({ ...restProps });
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);

const displayTabletNoneClassName = useClassNamePrefix('d-tablet-none');
const displayNoneClassName = useClassNamePrefix('d-none');
const displayTabletFlexClassName = useClassNamePrefix('d-tablet-flex');

const isLast = (index: number, itemsCount: number) => {
return index === itemsCount - 1;
};
Expand All @@ -31,14 +36,14 @@ export const Breadcrumbs = <T extends ElementType = 'nav'>(props: SpiritBreadcru
items?.map((item, index) => (
<React.Fragment key={`BreadcrumbsItem_${item.title}`}>
{index === items.length - 2 && goBackTitle && (
<li className="d-tablet-none">
<li className={displayTabletNoneClassName}>
<Icon name="chevron-left" />
<Link href={item.url} color="primary" isUnderlined>
{goBackTitle}
</Link>
</li>
)}
<li className="d-none d-tablet-flex">
<li className={classNames(displayNoneClassName, displayTabletFlexClassName)}>
{index !== 0 && <Icon name="chevron-right" />}
<Link
href={item.url}
Expand Down

0 comments on commit 48307e6

Please sign in to comment.