Skip to content

Commit f20f1ce

Browse files
committed
[EuiTextColor] Opinionated: Remove classNames entirely
- since they're no longer setting CSS - we should convert Kibana usages to the component
1 parent df30c1d commit f20f1ce

2 files changed

Lines changed: 5 additions & 21 deletions

File tree

src/components/text/__snapshots__/text_color.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
exports[`EuiTextColor is rendered 1`] = `
44
<span
55
aria-label="aria-label"
6-
class="euiTextColor euiTextColor--default testClass1 testClass2 css-7fidck-euiTextColor-default"
6+
class="testClass1 testClass2 css-7fidck-euiTextColor-default"
77
data-test-subj="test subject string"
88
/>
99
`;
1010

1111
exports[`EuiTextColor props color is rendered with custom color 1`] = `
1212
<span
13-
class="euiTextColor euiTextColor--custom css-tseiet-euiTextColor"
13+
class="css-tseiet-euiTextColor"
1414
style="color:#ff0000"
1515
>
1616
<p>
@@ -21,7 +21,7 @@ exports[`EuiTextColor props color is rendered with custom color 1`] = `
2121

2222
exports[`EuiTextColor props color is rendered with named color 1`] = `
2323
<span
24-
class="euiTextColor euiTextColor--warning css-1yjx65l-euiTextColor-warning"
24+
class="css-1yjx65l-euiTextColor-warning"
2525
>
2626
<p>
2727
Content

src/components/text/text_color.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import React, { FunctionComponent, HTMLAttributes, CSSProperties } from 'react';
10-
import classNames from 'classnames';
1110
import { CommonProps } from '../common';
1211

1312
import { useEuiTheme } from '../../services';
@@ -43,11 +42,11 @@ export type EuiTextColorProps = CommonProps &
4342
export const EuiTextColor: FunctionComponent<EuiTextColorProps> = ({
4443
children,
4544
color = 'default',
46-
className,
4745
component = 'span',
4846
style,
4947
...rest
5048
}) => {
49+
const Component = component;
5150
const isNamedColor = COLORS.includes(color as TextColor);
5251

5352
const euiTheme = useEuiTheme();
@@ -57,16 +56,6 @@ export const EuiTextColor: FunctionComponent<EuiTextColorProps> = ({
5756
isNamedColor ? styles[color as TextColor] : undefined,
5857
];
5958

60-
const classes = classNames(
61-
'euiTextColor',
62-
{
63-
[`euiTextColor--${color}`]: isNamedColor,
64-
'euiTextColor--custom': !isNamedColor,
65-
},
66-
className
67-
);
68-
const Component = component;
69-
7059
// We're checking if is a custom color.
7160
// If it is a custom color we set the `color` of the `.euiTextColor` div to that custom color.
7261
// This way the children text elements can `inherit` that color and border and backgrounds can get that `currentColor`.
@@ -78,12 +67,7 @@ export const EuiTextColor: FunctionComponent<EuiTextColorProps> = ({
7867
: { ...style };
7968

8069
return (
81-
<Component
82-
css={cssStyles}
83-
className={classes}
84-
style={euiTextStyle}
85-
{...rest}
86-
>
70+
<Component css={cssStyles} style={euiTextStyle} {...rest}>
8771
{children}
8872
</Component>
8973
);

0 commit comments

Comments
 (0)