From 4ccbc815ea2a6208c6366ee0d3fcaab3ff02c0e7 Mon Sep 17 00:00:00 2001 From: Caroline Horn <549577+cchaos@users.noreply.github.com> Date: Fri, 2 Aug 2019 17:56:08 -0400 Subject: [PATCH] Fix and TS EuiSteps (#2186) * Fixed alignment of Steps if text causes wrapping * Converted EuiStep to TS * Convert EuiSubSteps to TS * Convert EuiStepHorizontal to TS * Converted EuiStepsHorizontal to TS * Converted EuiSteps to TS --- CHANGELOG.md | 3 + src-docs/src/i18ntokens.json | 44 +-- src-docs/src/views/modal/modal.js | 8 +- src-docs/src/views/steps/steps.js | 3 +- src-docs/src/views/steps/steps_example.js | 33 +- src-docs/src/views/steps/steps_horizontal.js | 8 +- src/components/index.d.ts | 1 - .../steps/__snapshots__/step.test.js.snap | 32 -- .../steps/__snapshots__/step.test.tsx.snap | 257 ++++++++++++++++ .../step_horizontal.test.js.snap | 30 -- .../step_horizontal.test.tsx.snap | 287 ++++++++++++++++++ .../steps/__snapshots__/steps.test.js.snap | 256 ---------------- .../steps/__snapshots__/steps.test.tsx.snap | 256 ++++++++++++++++ ...js.snap => steps_horizontal.test.tsx.snap} | 0 ...s.test.js.snap => sub_steps.test.tsx.snap} | 0 src/components/steps/_steps.scss | 72 +++-- src/components/steps/_variables.scss | 4 +- src/components/steps/index.d.ts | 86 ------ src/components/steps/{index.js => index.ts} | 2 + src/components/steps/step.js | 75 ----- src/components/steps/step.test.js | 21 -- src/components/steps/step.test.tsx | 54 ++++ src/components/steps/step.tsx | 73 +++++ src/components/steps/step_horizontal.test.js | 49 --- src/components/steps/step_horizontal.test.tsx | 88 ++++++ ...step_horizontal.js => step_horizontal.tsx} | 85 +++--- .../steps/{steps.test.js => steps.test.tsx} | 4 +- src/components/steps/{steps.js => steps.tsx} | 64 ++-- src/components/steps/steps_horizontal.js | 51 ---- ...ntal.test.js => steps_horizontal.test.tsx} | 0 src/components/steps/steps_horizontal.tsx | 32 ++ src/components/steps/sub_steps.js | 18 -- .../{sub_steps.test.js => sub_steps.test.tsx} | 0 src/components/steps/sub_steps.tsx | 21 ++ 34 files changed, 1241 insertions(+), 776 deletions(-) delete mode 100644 src/components/steps/__snapshots__/step.test.js.snap create mode 100644 src/components/steps/__snapshots__/step.test.tsx.snap delete mode 100644 src/components/steps/__snapshots__/step_horizontal.test.js.snap create mode 100644 src/components/steps/__snapshots__/step_horizontal.test.tsx.snap delete mode 100644 src/components/steps/__snapshots__/steps.test.js.snap create mode 100644 src/components/steps/__snapshots__/steps.test.tsx.snap rename src/components/steps/__snapshots__/{steps_horizontal.test.js.snap => steps_horizontal.test.tsx.snap} (100%) rename src/components/steps/__snapshots__/{sub_steps.test.js.snap => sub_steps.test.tsx.snap} (100%) delete mode 100644 src/components/steps/index.d.ts rename src/components/steps/{index.js => index.ts} (78%) delete mode 100644 src/components/steps/step.js delete mode 100644 src/components/steps/step.test.js create mode 100644 src/components/steps/step.test.tsx create mode 100644 src/components/steps/step.tsx delete mode 100644 src/components/steps/step_horizontal.test.js create mode 100644 src/components/steps/step_horizontal.test.tsx rename src/components/steps/{step_horizontal.js => step_horizontal.tsx} (62%) rename src/components/steps/{steps.test.js => steps.test.tsx} (90%) rename src/components/steps/{steps.js => steps.tsx} (52%) delete mode 100644 src/components/steps/steps_horizontal.js rename src/components/steps/{steps_horizontal.test.js => steps_horizontal.test.tsx} (100%) create mode 100644 src/components/steps/steps_horizontal.tsx delete mode 100644 src/components/steps/sub_steps.js rename src/components/steps/{sub_steps.test.js => sub_steps.test.tsx} (100%) create mode 100644 src/components/steps/sub_steps.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 22366a4adbb..6055c4effe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Converted `EuiStep`, `EuiSteps`, `EuiStepHorizontal`, `EuiStepsHorizontal`, and `EuiSubSteps` to Typescript ([#2186](https://github.com/elastic/eui/pull/2186)) + **Bug fixes** - Fixed `EuiBadge` truncation and auto-applied `title` attribute with `innerText` ([#2190](https://github.com/elastic/eui/pull/2190)) - Remove exported TypeScript type and interface exports from built artifacts when they originate from `node_modules` ([#2191](https://github.com/elastic/eui/pull/2191)) - Fixed `EuiBadge` truncation in IE and for the global filters pattern ([#2194](https://github.com/elastic/eui/pull/2194)) +- Fixed alignment of long titles in `EuiStep` ([#2186](https://github.com/elastic/eui/pull/2186)) ## [`13.1.1`](https://github.com/elastic/eui/tree/v13.1.1) diff --git a/src-docs/src/i18ntokens.json b/src-docs/src/i18ntokens.json index 88c2de0dff5..7ed52b0dcf7 100644 --- a/src-docs/src/i18ntokens.json +++ b/src-docs/src/i18ntokens.json @@ -725,15 +725,15 @@ "highlighting": "code", "loc": { "start": { - "line": 48, + "line": 75, "column": 4 }, "end": { - "line": 60, + "line": 87, "column": 53 } }, - "filepath": "src/components/steps/step_horizontal.js" + "filepath": "src/components/steps/step_horizontal.tsx" }, { "token": "euiStepHorizontal.step", @@ -741,15 +741,15 @@ "highlighting": "string", "loc": { "start": { - "line": 74, + "line": 102, "column": 16 }, "end": { - "line": 74, + "line": 102, "column": 73 } }, - "filepath": "src/components/steps/step_horizontal.js" + "filepath": "src/components/steps/step_horizontal.tsx" }, { "token": "euiStepNumber.isComplete", @@ -800,36 +800,20 @@ "filepath": "src/components/steps/step_number.tsx" }, { - "token": "euiStep.incompleteStep", - "defString": "Incomplete Step", - "highlighting": "string", - "loc": { - "start": { - "line": 27, - "column": 6 - }, - "end": { - "line": 27, - "column": 74 - } - }, - "filepath": "src/components/steps/step.js" - }, - { - "token": "euiStep.completeStep", - "defString": "Step", - "highlighting": "string", + "token": "euiStep.ariaLabel", + "defString": "({\n status\n}) => {\n if (status === 'incomplete') return 'Incomplete Step';\n return 'Step';\n};", + "highlighting": "code", "loc": { "start": { - "line": 30, - "column": 23 + "line": 49, + "column": 8 }, "end": { - "line": 30, - "column": 78 + "line": 55, + "column": 30 } }, - "filepath": "src/components/steps/step.js" + "filepath": "src/components/steps/step.tsx" }, { "token": "euiTableSortMobile.sorting", diff --git a/src-docs/src/views/modal/modal.js b/src-docs/src/views/modal/modal.js index 3ac2b377787..5f5efa69b32 100644 --- a/src-docs/src/views/modal/modal.js +++ b/src-docs/src/views/modal/modal.js @@ -74,9 +74,7 @@ export class Modal extends Component { - { - '

Titleisonelonglinejfdklsjaflkdsajfkldsajfklsdajfkldsjafkldsjalfkjdsklafjdsklafjkldsajfkldsajfkldsjfkdsjaflsdjaf;djsakfjdskafjdsklafjdksljfkdlsa;jfldksjfkldsajfkldsjflkdsjaklfadjs;

' - } + {'

Title

'}
); @@ -88,9 +86,7 @@ export class Modal extends Component { - - Titleisonelonglinejfdklsjaflkdsajfkldsajfklsdajfkldsjafkldsjalfkjdsklafjdsklafjkldsajfkldsajfkldsjfkdsjaflsdjaf - + Modal title {formSample} diff --git a/src-docs/src/views/steps/steps.js b/src-docs/src/views/steps/steps.js index a05c88481e1..0a297910c55 100644 --- a/src-docs/src/views/steps/steps.js +++ b/src-docs/src/views/steps/steps.js @@ -9,7 +9,8 @@ import { const firstSetOfSteps = [ { - title: 'Step 1', + title: + 'Step 1 with a long title to check what happens during wrapping which should have been fixed.', children:

Do this first

, }, { diff --git a/src-docs/src/views/steps/steps_example.js b/src-docs/src/views/steps/steps_example.js index 406b5e34263..30ed5841414 100644 --- a/src-docs/src/views/steps/steps_example.js +++ b/src-docs/src/views/steps/steps_example.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { renderToHtml } from '../../services'; @@ -18,8 +18,7 @@ import Steps from './steps'; const stepsSource = require('!!raw-loader!./steps'); const stepsHtml = renderToHtml(Steps); const stepsSnippet = [ - ``, - ` +const stepsHorizontalSnippet = ` `; import Status from './status'; const statusSource = require('!!raw-loader!./status'); const statusHtml = renderToHtml(Steps); -const statusSnippet = `, }, { - title: 'Horizontal', + title: 'Horizontal steps', source: [ { type: GuideSectionTypes.JS, @@ -177,10 +181,17 @@ export const StepsExample = { }, ], text: ( -

- For use when forms/setup instructions can and should be split into - multiple pages. -

+ +

+ For use when forms/setup instructions can and should be split into + multiple pages. +

+

+ For each step object, be sure to signify previous/completed steps + with isComplete: true and the current/selected + step with isSelected: true. +

+
), demo: , snippet: stepsHorizontalSnippet, diff --git a/src-docs/src/views/steps/steps_horizontal.js b/src-docs/src/views/steps/steps_horizontal.js index 6a1611f0701..1b21ecda31d 100644 --- a/src-docs/src/views/steps/steps_horizontal.js +++ b/src-docs/src/views/steps/steps_horizontal.js @@ -4,21 +4,21 @@ import { EuiStepsHorizontal } from '../../../../src/components'; const horizontalSteps = [ { - title: 'Completed Step 1', + title: 'Completed step 1', isComplete: true, onClick: () => window.alert('Step 1 clicked'), }, { - title: 'Selected Step 2', + title: 'Selected step 2', isSelected: true, onClick: () => window.alert('Step 2 clicked'), }, { - title: 'Incomplete Step 3 which will wrap to the next line', + title: 'Incomplete step 3 which will wrap to the next line', onClick: () => window.alert('Step 3 clicked'), }, { - title: 'Disabled Step 4', + title: 'Disabled step 4', disabled: true, onClick: () => window.alert('Step 4 clicked'), }, diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 77e550cbdf5..571bd6f1622 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -22,7 +22,6 @@ /// /// /// -/// /// /// diff --git a/src/components/steps/__snapshots__/step.test.js.snap b/src/components/steps/__snapshots__/step.test.js.snap deleted file mode 100644 index ba9b4124a7a..00000000000 --- a/src/components/steps/__snapshots__/step.test.js.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EuiStep is rendered 1`] = ` -
- - Step  - -
- 1 -
-

- First step -

-
-

- Do this -

-
-
-`; diff --git a/src/components/steps/__snapshots__/step.test.tsx.snap b/src/components/steps/__snapshots__/step.test.tsx.snap new file mode 100644 index 00000000000..ff9f26b51bd --- /dev/null +++ b/src/components/steps/__snapshots__/step.test.tsx.snap @@ -0,0 +1,257 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiStep is rendered 1`] = ` +
+
+
+ 1 +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props headingElement 1`] = ` +
+
+
+ 1 +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props status complete is rendered 1`] = ` +
+
+
+ +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props status danger is rendered 1`] = ` +
+
+
+ +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props status disabled is rendered 1`] = ` +
+
+
+ 1 +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props status incomplete is rendered 1`] = ` +
+
+
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props status warning is rendered 1`] = ` +
+
+
+ +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; + +exports[`EuiStep props step 1`] = ` +
+
+
+ 5 +
+

+ First step +

+
+
+

+ Do this +

+
+
+`; diff --git a/src/components/steps/__snapshots__/step_horizontal.test.js.snap b/src/components/steps/__snapshots__/step_horizontal.test.js.snap deleted file mode 100644 index fc3d40cedbd..00000000000 --- a/src/components/steps/__snapshots__/step_horizontal.test.js.snap +++ /dev/null @@ -1,30 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EuiStepHorizontal is rendered 1`] = ` - -`; diff --git a/src/components/steps/__snapshots__/step_horizontal.test.tsx.snap b/src/components/steps/__snapshots__/step_horizontal.test.tsx.snap new file mode 100644 index 00000000000..8501189d02d --- /dev/null +++ b/src/components/steps/__snapshots__/step_horizontal.test.tsx.snap @@ -0,0 +1,287 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiStepHorizontal is rendered 1`] = ` +