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(Text): add text to Accordion, Button, Checkbox, Combobox, Contentswitcher #9493

Merged
5 changes: 4 additions & 1 deletion packages/react/src/components/Accordion/AccordionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { settings } from 'carbon-components';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import { Text } from '../Text';
import { match, keys } from '../../internal/keyboard';
import { useId } from '../../internal/useId';
import deprecate from '../../prop-types/deprecate.js';
Expand Down Expand Up @@ -84,7 +85,9 @@ function AccordionItem({
onKeyDown={onKeyDown}
type="button">
<ChevronRight16 className={`${prefix}--accordion__arrow`} />
<div className={`${prefix}--accordion__title`}>{title}</div>
<Text as="div" className={`${prefix}--accordion__title`}>
{title}
</Text>
</Expando>
<div id={id} className={`${prefix}--accordion__content`}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports[`Accordion should render 1`] = `
</svg>
<div
class="bx--accordion__title"
dir="auto"
>
Heading A
</div>
Expand Down Expand Up @@ -68,6 +69,7 @@ exports[`Accordion should render 1`] = `
</svg>
<div
class="bx--accordion__title"
dir="auto"
>
Heading B
</div>
Expand Down Expand Up @@ -105,6 +107,7 @@ exports[`Accordion should render 1`] = `
</svg>
<div
class="bx--accordion__title"
dir="auto"
>
Heading C
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ exports[`AccordionItem should render 1`] = `
</svg>
</Icon>
</ForwardRef(ChevronRight16)>
<div
<Text
as="div"
className="bx--accordion__title"
>
A heading
</div>
<div
className="bx--accordion__title"
dir="auto"
>
A heading
</div>
</Text>
</button>
</defaultRenderExpando>
<div
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const Button = React.forwardRef(function Button(
component = 'a';
otherProps = anchorProps;
}

return React.createElement(
component,
{
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { Text } from '../Text';
import { useFeatureFlag } from '../FeatureFlags';
import { settings } from 'carbon-components';
import deprecate from '../../prop-types/deprecate';
Expand Down Expand Up @@ -69,7 +70,7 @@ const Checkbox = React.forwardRef(function Checkbox(
}}
/>
<label htmlFor={id} className={labelClasses} title={title || null}>
<span className={innerLabelClasses}>{labelText}</span>
<Text className={innerLabelClasses}>{labelText}</Text>
</label>
</div>
);
Expand Down
9 changes: 5 additions & 4 deletions packages/react/src/components/ComboBox/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cx from 'classnames';
import Downshift from 'downshift';
import PropTypes from 'prop-types';
import React, { useEffect, useState, useRef } from 'react';
import { Text } from '../Text';
import { settings } from 'carbon-components';
import {
Checkmark16,
Expand Down Expand Up @@ -293,9 +294,9 @@ const ComboBox = React.forwardRef((props, ref) => {
return (
<div className={wrapperClasses}>
{titleText && (
<label className={titleClasses} {...labelProps}>
<Text as="label" className={titleClasses} {...labelProps}>
{titleText}
</label>
</Text>
)}
<ListBox
className={className}
Expand Down Expand Up @@ -391,9 +392,9 @@ const ComboBox = React.forwardRef((props, ref) => {
</ListBox.Menu>
</ListBox>
{helperText && !invalid && !warn && (
<div id={comboBoxHelperId} className={helperClasses}>
<Text as="div" id={comboBoxHelperId} className={helperClasses}>
{helperText}
</div>
</Text>
)}
</div>
);
Expand Down