Skip to content

Commit

Permalink
Add component prop to EuiTextColor.
Browse files Browse the repository at this point in the history
- Fix bug: `EuiDescribedFormGroup` renders its `description` inside of a `div` instead of a `span`.
  • Loading branch information
cjcenizal committed Jul 13, 2018
1 parent fc54395 commit d5c003f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
- Make some proprties of `EuiFlyout` optional ([#1003](https://github.com/elastic/eui/pull/1003))
- Add typings for `EuiFlyout`, `EuiFlyoutBody`, `EuiFlyoutHeader`, and `EuiFlyoutFooter` ([#1001](https://github.com/elastic/eui/pull/1001))
- Gave `EuiFlyout` close button a data-test-subj ([#1000](https://github.com/elastic/eui/pull/1000))
- Updated `react-vis` version to `1.10.2`. ([#999](https://github.com/elastic/eui/pull/999))
- Updated `react-vis` version to `1.10.2` ([#999](https://github.com/elastic/eui/pull/999))
- Added `component` prop to `EuiTextColor`

**Breaking changes**

- Altered `EuiPage` and sub-component layout ([#998](https://github.com/elastic/eui/pull/998))
- `EuiPageHeader` must now be contained within `EuiPageBody`
- `EuiPageSideBar` must now be **outside** of `EuiPageBody`

**Bug fixes**

- `EuiDescribedFormGroup` renders its `description` inside of a `div` instead of a `span`

## [`1.2.1`](https://github.com/elastic/eui/tree/v1.2.1)

**Bug fixes**
Expand Down
9 changes: 5 additions & 4 deletions src-docs/src/views/form_layouts/described_form_group.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
Component,
Fragment,
} from 'react';

import {
Expand Down Expand Up @@ -81,11 +82,11 @@ export default class extends Component {
idAria="single-example-aria"
title={<h3>Single text field</h3>}
description={
<span>
<Fragment>
When using this with a single form row where this text serves as the help text for the input,
it is a good idea to pass <EuiCode>idAria=&quot;someID&quot;</EuiCode> to the form group and pass
<EuiCode>describedByIds=&#123;[someID]&#125;</EuiCode> to its form row.
</span>
</Fragment>
}
>
<EuiFormRow
Expand Down Expand Up @@ -141,11 +142,11 @@ export default class extends Component {
title={<h2>Full width</h2>}
titleSize="xxxs"
description={
<span>
<Fragment>
By default, <EuiCode>EuiDescribedFormGroup</EuiCode> will be double the default width of form elements.
However, you can pass <EuiCode>fullWidth</EuiCode> prop to this, the individual field and row components
to expand to their container.
</span>
</Fragment>
}
fullWidth
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,13 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
>
<EuiTextColor
color="subdued"
component="div"
>
<span
<div
className="euiTextColor euiTextColor--subdued"
>
Test description
</span>
</div>
</EuiTextColor>
</div>
</EuiText>
Expand Down
2 changes: 1 addition & 1 deletion src/components/text/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EuiText = ({ size, color, grow, textAlign, children, className, ...
let optionallyAlteredText;
if (color) {
optionallyAlteredText = (
<EuiTextColor color={color}>
<EuiTextColor color={color} component="div">
{children}
</EuiTextColor>
);
Expand Down
7 changes: 5 additions & 2 deletions src/components/text/text_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const EuiTextColor = ({
children,
color,
className,
component: Component,
...rest
}) => {
const classes = classNames(
Expand All @@ -27,21 +28,23 @@ export const EuiTextColor = ({
);

return (
<span
<Component
className={classes}
{...rest}
>
{children}
</span>
</Component>
);
};

EuiTextColor.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
color: PropTypes.oneOf(COLORS),
component: PropTypes.oneOf(['div', 'span']),
};

EuiTextColor.defaultProps = {
color: 'default',
component: 'span',
};

0 comments on commit d5c003f

Please sign in to comment.