Skip to content

Commit

Permalink
Removed isSelected and isComplete props from EuiHorizontalStep
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed May 4, 2022
1 parent 07f0348 commit 90bc8c1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 70 deletions.
50 changes: 15 additions & 35 deletions src/components/steps/__snapshots__/step_horizontal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`EuiStepHorizontal is rendered 1`] = `
</button>
`;

exports[`EuiStepHorizontal props isComplete 1`] = `
exports[`EuiStepHorizontal props status complete is rendered 1`] = `
<button
class="euiStepHorizontal euiStepHorizontal-isComplete"
title="Step 1 is complete"
Expand All @@ -49,7 +49,7 @@ exports[`EuiStepHorizontal props isComplete 1`] = `
</button>
`;

exports[`EuiStepHorizontal props isSelected 1`] = `
exports[`EuiStepHorizontal props status current is rendered 1`] = `
<button
class="euiStepHorizontal euiStepHorizontal-isSelected"
title="Current step is 1"
Expand All @@ -75,19 +75,19 @@ exports[`EuiStepHorizontal props isSelected 1`] = `
</button>
`;

exports[`EuiStepHorizontal props status complete is rendered 1`] = `
exports[`EuiStepHorizontal props status danger is rendered 1`] = `
<button
class="euiStepHorizontal euiStepHorizontal-isComplete"
title="Step 1 is complete"
class="euiStepHorizontal"
title="Step 1"
>
<span
class="euiStepNumber euiStepNumber--complete euiStepHorizontal__number"
class="euiStepNumber euiStepNumber--danger euiStepHorizontal__number"
>
<span
class="euiStepNumber__icon"
data-euiicon-type="check"
data-euiicon-type="cross"
>
Step 1 is complete
Step 1 has errors
</span>
</span>
<span
Expand All @@ -96,18 +96,18 @@ exports[`EuiStepHorizontal props status complete is rendered 1`] = `
</button>
`;

exports[`EuiStepHorizontal props status current is rendered 1`] = `
exports[`EuiStepHorizontal props status disabled is rendered 1`] = `
<button
class="euiStepHorizontal euiStepHorizontal-isSelected"
title="Current step is 1"
class="euiStepHorizontal euiStepHorizontal-isDisabled"
title="Step 1 is disabled"
>
<span
class="euiStepNumber euiStepHorizontal__number"
class="euiStepNumber euiStepNumber--disabled euiStepHorizontal__number"
>
<span
class="euiScreenReaderOnly"
>
Current step is 1
Step 1 is disabled
</span>
<span
aria-hidden="true"
Expand All @@ -122,30 +122,10 @@ exports[`EuiStepHorizontal props status current is rendered 1`] = `
</button>
`;

exports[`EuiStepHorizontal props status danger is rendered 1`] = `
<button
class="euiStepHorizontal"
title="Step 1"
>
<span
class="euiStepNumber euiStepNumber--danger euiStepHorizontal__number"
>
<span
class="euiStepNumber__icon"
data-euiicon-type="cross"
>
Step 1 has errors
</span>
</span>
<span
class="euiStepHorizontal__title"
/>
</button>
`;

exports[`EuiStepHorizontal props status disabled is rendered 1`] = `
exports[`EuiStepHorizontal props status disabled overrides the passed status 1`] = `
<button
class="euiStepHorizontal euiStepHorizontal-isDisabled"
disabled=""
title="Step 1 is disabled"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ exports[`EuiStepsHorizontal is rendered 1`] = `
>
<button
class="euiStepHorizontal euiStepHorizontal-isDisabled"
disabled=""
title="Step 4: Disabled Step 4 is disabled"
>
<span
Expand Down
24 changes: 8 additions & 16 deletions src/components/steps/step_horizontal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ describe('EuiStepHorizontal', () => {
expect(component).toMatchSnapshot();
});

test('isSelected', () => {
const component = render(
<EuiStepHorizontal isSelected onClick={() => {}} />
);

expect(component).toMatchSnapshot();
});

test('isComplete', () => {
const component = render(
<EuiStepHorizontal isComplete onClick={() => {}} />
);

expect(component).toMatchSnapshot();
});

describe('status', () => {
STATUS.forEach((status) => {
test(`${status} is rendered`, () => {
Expand All @@ -65,6 +49,14 @@ describe('EuiStepHorizontal', () => {
expect(component).toMatchSnapshot();
});
});

test('disabled overrides the passed status', () => {
const component = render(
<EuiStepHorizontal status="current" disabled onClick={() => {}} />
);

expect(component).toMatchSnapshot();
});
});

describe('onClick', () => {
Expand Down
14 changes: 0 additions & 14 deletions src/components/steps/step_horizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ import {
export interface EuiStepHorizontalProps
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>,
CommonProps {
/**
* **DEPRECATED: Use `status = 'current'` instead**
* Adds to the line before the indicator for showing current progress
*/
isSelected?: boolean;
/**
* **DEPRECATED: Use `status = 'complete'` instead**
* Adds to the line after the indicator for showing current progress
*/
isComplete?: boolean;
onClick: MouseEventHandler<HTMLButtonElement>;
/**
* Makes the whole step button disabled.
Expand All @@ -59,8 +49,6 @@ export const EuiStepHorizontal: FunctionComponent<EuiStepHorizontalProps> = ({
className,
step = 1,
title,
isSelected,
isComplete,
onClick,
disabled,
status = 'incomplete',
Expand All @@ -74,8 +62,6 @@ export const EuiStepHorizontal: FunctionComponent<EuiStepHorizontalProps> = ({
const currentTitle = useI18nCurrentStep({ number: step, title });

if (disabled) status = 'disabled';
else if (isComplete) status = 'complete';
else if (isSelected) status = 'current';

const classes = classNames('euiStepHorizontal', className, {
'euiStepHorizontal-isSelected': status === 'current',
Expand Down
7 changes: 4 additions & 3 deletions src/components/steps/steps_horizontal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test';

import { EuiStepStatus } from './step_number';
import { EuiStepsHorizontal } from './steps_horizontal';

const steps = [

This comment has been minimized.

Copy link
@cchaos

cchaos May 4, 2022

Contributor

Should we just set the type to EuiStepsHorizontalProps[steps] up here so you don't have to do as EuiStepStatus?

This comment has been minimized.

Copy link
@cee-chen

cee-chen May 4, 2022

Author Contributor

It's not hugely important either way as this is a test file, but I'd lean more towards singular as EuiStepStatus personally. Casting the entire thing vs. 1 key means that we may possibly pass in other invalid keys in the future that we would want to catch

This comment has been minimized.

Copy link
@cee-chen

cee-chen May 4, 2022

Author Contributor

oh wait! i see what you mean, you meant set via : and not as. let me give that a shot

This comment has been minimized.

Copy link
@cee-chen

cee-chen May 4, 2022

Author Contributor

yep that worked - 09d803b Thanks Caroline!!

This comment has been minimized.

Copy link
@cchaos

cchaos May 4, 2022

Contributor

Yeah exactly! Nice!

{
title: 'Completed Step 1',
isComplete: true,
status: 'complete' as EuiStepStatus,
onClick: () => {},
},
{
title: 'Selected Step 2',
isSelected: true,
status: 'current' as EuiStepStatus,
onClick: () => {},
},
{
Expand All @@ -29,7 +30,7 @@ const steps = [
},
{
title: 'Disabled Step 4',
disabled: true,
status: 'disabled' as EuiStepStatus,
onClick: () => {},
},
];
Expand Down
2 changes: 1 addition & 1 deletion src/components/steps/steps_horizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const EuiStepsHorizontal: FunctionComponent<EuiStepsHorizontalProps> = ({
<ol className={classes} {...rest}>
{steps.map((stepProps, index) => {
const isCurrent =
stepProps.isSelected || stepProps.status === 'current'
stepProps.status === 'current'
? { 'aria-current': 'step' as const }
: {};

Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/5868.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Removed `partition` prop from EuiCharts theme configuration - use `theme.partition` instead
- Removed `data-grid-cell-id` attribute from `EuiDataGrid` cells - use separate `data-gridcell-column-id` & `data-gridcell-row-index` attributes instead
- Removed `noDivider` prop from `EuiFilterButton` - use `withNext` prop instead
- Removed `isSelected` and `isComplete` props from `EuiHorizontalStep` - use `status` prop instead

0 comments on commit 90bc8c1

Please sign in to comment.