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

feat(bidi): add Text to BreadcrumbItem, DataTable, Dropdown, FormLabel, Link, and MultiSelect #10062

Merged
merged 9 commits into from
Dec 3, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const skeleton = () => <BreadcrumbSkeleton />;
const props = () => ({
className: 'some-class',
noTrailingSlash: boolean('No trailing slash (noTrailingSlash)', false),
isCurrentPage: boolean('Is current page (isCurrentPage)', false),
onClick: action('onClick'),
});

Expand All @@ -73,7 +72,10 @@ export const playground = () => (
<a href="/#">Breadcrumb 1</a>
</BreadcrumbItem>
<BreadcrumbItem href="#">Breadcrumb 2</BreadcrumbItem>
<BreadcrumbItem href="#" {...props()}>
<BreadcrumbItem
href="#"
{...props()}
isCurrentPage={boolean('Is current page (isCurrentPage)', false)}>
Breadcrumb 3
</BreadcrumbItem>
<BreadcrumbItem>Breadcrumb 4</BreadcrumbItem>
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/Breadcrumb/BreadcrumbItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import cx from 'classnames';
import { settings } from 'carbon-components';
import Link from '../Link';
import { OverflowMenuHorizontal16 } from '@carbon/icons-react';
import { Text } from '../Text';

const { prefix } = settings;

Expand Down Expand Up @@ -61,7 +62,7 @@ const BreadcrumbItem = React.forwardRef(function BreadcrumbItem(
{children}
</Link>
) : (
<span className={`${prefix}--link`}>{children}</span>
<Text className={`${prefix}--link`}>{children}</Text>
)}
</li>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ exports[`Breadcrumb should render 1`] = `
<Link
href="www.carbondesignsystem.com"
>
<a
<Text
as="a"
className="bx--link"
href="www.carbondesignsystem.com"
rel={null}
>
Breadcrumb 1
</a>
<a
className="bx--link"
dir="auto"
href="www.carbondesignsystem.com"
rel={null}
>
Breadcrumb 1
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -53,13 +61,21 @@ exports[`Breadcrumb should support rendering the current page 1`] = `
<Link
href="#a"
>
<a
<Text
as="a"
className="bx--link"
href="#a"
rel={null}
>
A
</a>
<a
className="bx--link"
dir="auto"
href="#a"
rel={null}
>
A
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -72,13 +88,21 @@ exports[`Breadcrumb should support rendering the current page 1`] = `
<Link
href="#b"
>
<a
<Text
as="a"
className="bx--link"
href="#b"
rel={null}
>
B
</a>
<a
className="bx--link"
dir="auto"
href="#b"
rel={null}
>
B
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -92,13 +116,21 @@ exports[`Breadcrumb should support rendering the current page 1`] = `
<Link
href="#c"
>
<a
<Text
as="a"
className="bx--link"
href="#c"
rel={null}
>
C
</a>
<a
className="bx--link"
dir="auto"
href="#c"
rel={null}
>
C
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -124,13 +156,21 @@ exports[`Breadcrumb should support rendering the current page 2`] = `
<Link
href="#a"
>
<a
<Text
as="a"
className="bx--link"
href="#a"
rel={null}
>
A
</a>
<a
className="bx--link"
dir="auto"
href="#a"
rel={null}
>
A
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -143,13 +183,21 @@ exports[`Breadcrumb should support rendering the current page 2`] = `
<Link
href="#b"
>
<a
<Text
as="a"
className="bx--link"
href="#b"
rel={null}
>
B
</a>
<a
className="bx--link"
dir="auto"
href="#b"
rel={null}
>
B
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand All @@ -164,14 +212,23 @@ exports[`Breadcrumb should support rendering the current page 2`] = `
aria-current="page"
href="#c"
>
<a
<Text
aria-current="page"
as="a"
className="bx--link"
href="#c"
rel={null}
>
C
</a>
<a
aria-current="page"
className="bx--link"
dir="auto"
href="#c"
rel={null}
>
C
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand Down Expand Up @@ -199,13 +256,21 @@ exports[`Breadcrumb should support rendering without a trailing slash 1`] = `
<Link
href="www.carbondesignsystem.com"
>
<a
<Text
as="a"
className="bx--link"
href="www.carbondesignsystem.com"
rel={null}
>
Breadcrumb 1
</a>
<a
className="bx--link"
dir="auto"
href="www.carbondesignsystem.com"
rel={null}
>
Breadcrumb 1
</a>
</Text>
</Link>
</li>
</BreadcrumbItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React from 'react';
import { settings } from 'carbon-components';
import Button from '../Button';
import TableActionList from './TableActionList';
import { Text } from '../Text';

const { prefix } = settings;

Expand Down Expand Up @@ -59,11 +60,11 @@ const TableBatchActions = ({
{...rest}>
<div className={batchSummaryClasses}>
<p className={`${prefix}--batch-summary__para`}>
<span>
<Text as="span">
{totalSelected > 1 || totalSelected === 0
? t('carbon.table.batch.items.selected', { totalSelected })
: t('carbon.table.batch.item.selected', { totalSelected })}
</span>
</Text>
</p>
</div>
<TableActionList>
Expand Down
15 changes: 11 additions & 4 deletions packages/react/src/components/DataTable/TableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { settings } from 'carbon-components';
import { Text } from '../Text';

const { prefix } = settings;

Expand All @@ -34,10 +35,16 @@ const TableContainer = ({
<div {...rest} className={tableContainerClasses}>
{title && (
<div className={`${prefix}--data-table-header`}>
<h4 className={`${prefix}--data-table-header__title`}>{title}</h4>
<p className={`${prefix}--data-table-header__description`}>
{description}
</p>
<Text as="h4" className={`${prefix}--data-table-header__title`}>
{title}
</Text>
{description && (
<Text
as="p"
className={`${prefix}--data-table-header__description`}>
{description}
</Text>
)}
</div>
)}
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ describe('DataTable.TableBatchActions', () => {
const singleWrapper = mount(
<TableBatchActions {...mockProps} totalSelected={1} />
);
expect(singleWrapper.find(`.${prefix}--batch-summary__para`).text()).toBe(
expect(singleWrapper.find(`p.${prefix}--batch-summary__para`).text()).toBe(
'1 item selected'
);

const multiWrapper = mount(
<TableBatchActions {...mockProps} totalSelected={2} />
);
expect(multiWrapper.find(`.${prefix}--batch-summary__para`).text()).toBe(
expect(multiWrapper.find(`p.${prefix}--batch-summary__para`).text()).toBe(
'2 items selected'
);
});
Expand Down
Loading