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

[EuiExpression] Allow the use of descriptions only #4014

Merged
merged 4 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Changed `value` prop in `EuiExpression` to not required ([#4014](https://github.com/elastic/eui/pull/4014))
- Added `fold` and `unfold` glyphs to `EuiIcon` ([#3994](https://github.com/elastic/eui/pull/3994))

**Bug fixes**
Expand Down
15 changes: 15 additions & 0 deletions src/components/expression/__snapshots__/expression.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ exports[`EuiExpression props uppercase true renders uppercase 1`] = `
</span>
`;

exports[`EuiExpression render with only description 1`] = `
<button
aria-label="aria-label"
class="euiExpression testClass1 testClass2 euiExpression-isClickable euiExpression-isUppercase euiExpression--secondary"
data-test-subj="test subject string"
>
<span
class="euiExpression__description"
>
the answer is
</span>

</button>
`;

exports[`EuiExpression renders 1`] = `
<button
aria-label="aria-label"
Expand Down
12 changes: 12 additions & 0 deletions src/components/expression/expression.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ describe('EuiExpression', () => {
expect(render(component)).toMatchSnapshot();
});

test('render with only description', () => {
const component = (
<EuiExpression
description="the answer is"
isActive={false}
onClick={() => {}}
{...requiredProps}
/>
);
expect(render(component)).toMatchSnapshot();
});

describe('props', () => {
describe('color', () => {
COLORS.forEach(color => {
Expand Down
10 changes: 6 additions & 4 deletions src/components/expression/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type EuiExpressionProps = CommonProps & {
/**
* Second part of the expression
*/
value: ReactNode;
value?: ReactNode;
valueProps?: HTMLAttributes<HTMLSpanElement>;
/**
* Color of the `description`
Expand Down Expand Up @@ -170,9 +170,11 @@ export const EuiExpression: FunctionComponent<ExclusiveUnion<
{...descriptionProps}>
{description}
</span>{' '}
<span className="euiExpression__value" {...valueProps}>
{value}
</span>
{value && (
<span className="euiExpression__value" {...valueProps}>
{value}
</span>
)}
{invalidIcon}
</Component>
);
Expand Down