From 630b518254b3408e60c3ecfd161ec431039eee68 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 24 Jun 2020 12:33:04 -0700 Subject: [PATCH 1/9] adding props, first changes --- .../src/views/progress/progress_size_color.js | 9 +++++++- src/components/progress/progress.tsx | 22 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src-docs/src/views/progress/progress_size_color.js b/src-docs/src/views/progress/progress_size_color.js index 74d541c0c0f..96cb7321603 100644 --- a/src-docs/src/views/progress/progress_size_color.js +++ b/src-docs/src/views/progress/progress_size_color.js @@ -4,7 +4,14 @@ import { EuiProgress, EuiSpacer } from '../../../../src/components'; export default () => (
- + diff --git a/src/components/progress/progress.tsx b/src/components/progress/progress.tsx index 53b1b5aef67..2fc7da2e38d 100644 --- a/src/components/progress/progress.tsx +++ b/src/components/progress/progress.tsx @@ -70,6 +70,8 @@ type Indeterminate = EuiProgressProps & HTMLAttributes; type Determinate = EuiProgressProps & ProgressHTMLAttributes & { max?: number; + valueText?: string; + label?: string; }; export const EuiProgress: FunctionComponent< @@ -80,6 +82,8 @@ export const EuiProgress: FunctionComponent< size = 'm', position = 'static', max, + valueText, + label, value, ...rest }) => { @@ -100,12 +104,18 @@ export const EuiProgress: FunctionComponent< // See https://css-tricks.com/html5-progress-element/ if (determinate) { return ( - } - /> +
+
+
{label}
+
{valueText}
+
+ } + /> +
); } else { return ( From af000e8929d608ade4665826b20feae61517c83f Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Thu, 25 Jun 2020 13:31:37 -0700 Subject: [PATCH 2/9] add valueText and label to EuiProgress --- src-docs/src/views/progress/progress_chart.js | 47 +++++++++++++ .../src/views/progress/progress_example.js | 41 +++++++++++ .../src/views/progress/progress_size_color.js | 11 +-- .../__snapshots__/progress.test.tsx.snap | 68 +++++++++++++++---- src/components/progress/_progress.scss | 13 ++++ src/components/progress/progress.test.tsx | 14 ++++ src/components/progress/progress.tsx | 34 ++++++++-- 7 files changed, 200 insertions(+), 28 deletions(-) create mode 100644 src-docs/src/views/progress/progress_chart.js diff --git a/src-docs/src/views/progress/progress_chart.js b/src-docs/src/views/progress/progress_chart.js new file mode 100644 index 00000000000..3a365b7dd20 --- /dev/null +++ b/src-docs/src/views/progress/progress_chart.js @@ -0,0 +1,47 @@ +import React, { Fragment } from 'react'; + +import { EuiProgress, EuiSpacer } from '../../../../src/components'; + +const data = [ + { label: "Men's Clothing", valueText: '80' }, + { label: "Women's Clothing", valueText: '60' }, + { label: "Women's Shoes", valueText: '45' }, + { label: "Men's Shoes", valueText: '40' }, + { label: "Women's Accessories", valueText: '24' }, +]; + +export default () => ( + +
+ {data.map(item => ( + <> + + + + ))} +
+ +
+ {data.map(item => ( + <> + + + + ))} +
+
+); diff --git a/src-docs/src/views/progress/progress_example.js b/src-docs/src/views/progress/progress_example.js index a5031a8e6d3..87b7ffd06f0 100644 --- a/src-docs/src/views/progress/progress_example.js +++ b/src-docs/src/views/progress/progress_example.js @@ -30,6 +30,22 @@ const progressFixedSnippet = ` import ProgressSizeColor from './progress_size_color'; const progressSizeColorSource = require('!!raw-loader!./progress_size_color'); const progressSizeColorHtml = renderToHtml(ProgressSizeColor); +const progressSizeColorSnippet = ``; + +import ProgressChart from './progress_chart'; +const progressChartSource = require('!!raw-loader!./progress_chart'); +const progressChartHtml = renderToHtml(ProgressChart); +const progressChartSnippet = ``; export const ProgressExample = { title: 'Progress', @@ -139,6 +155,31 @@ export const ProgressExample = {

), demo: , + snippet: progressSizeColorSnippet, + }, + { + title: 'Progress for charts', + source: [ + { + type: GuideSectionTypes.JS, + code: progressChartSource, + }, + { + type: GuideSectionTypes.HTML, + code: progressChartHtml, + }, + ], + text: ( +

+ Determinate progress bar can be used as simple bar charts. Use them + with the label and valueText{' '} + props to show the data corresponding to each bar.{' '} + valueText takes the same color that is passed to{' '} + EuiProgress. +

+ ), + demo: , + snippet: progressChartSnippet, }, ], }; diff --git a/src-docs/src/views/progress/progress_size_color.js b/src-docs/src/views/progress/progress_size_color.js index 96cb7321603..c291e4087cb 100644 --- a/src-docs/src/views/progress/progress_size_color.js +++ b/src-docs/src/views/progress/progress_size_color.js @@ -4,14 +4,7 @@ import { EuiProgress, EuiSpacer } from '../../../../src/components'; export default () => (
- + @@ -25,4 +18,4 @@ export default () => (
-); +); \ No newline at end of file diff --git a/src/components/progress/__snapshots__/progress.test.tsx.snap b/src/components/progress/__snapshots__/progress.test.tsx.snap index b0e9f5d087e..86f75b3c589 100644 --- a/src/components/progress/__snapshots__/progress.test.tsx.snap +++ b/src/components/progress/__snapshots__/progress.test.tsx.snap @@ -1,12 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiProgress has max 1`] = ` - +
+ +
`; exports[`EuiProgress has value 1`] = ` @@ -17,14 +19,54 @@ exports[`EuiProgress has value 1`] = ` /> `; +exports[`EuiProgress has valueText and Label 1`] = ` +
+
+
+
+ Label +
+
+
+
+
+ 50 +
+
+
+
+ +
+`; + exports[`EuiProgress is determinate 1`] = ` - +
+ +
`; exports[`EuiProgress is indeterminate 1`] = ` diff --git a/src/components/progress/_progress.scss b/src/components/progress/_progress.scss index 6178b1a6cbc..23e47b5aef5 100644 --- a/src/components/progress/_progress.scss +++ b/src/components/progress/_progress.scss @@ -128,3 +128,16 @@ $euiProgressColors: ( transform: scaleX(1) translateX(100%); } } + +.euiProgress__data { + display: flex; + justify-content: space-between; + + .euiProgress__label { + overflow: hidden; + } +} + +.euiProgress__data--primary .euiProgress__valueText { + color: $euiColorPrimary; +} \ No newline at end of file diff --git a/src/components/progress/progress.test.tsx b/src/components/progress/progress.test.tsx index 6cccc5e4947..7e6e3bbd39d 100644 --- a/src/components/progress/progress.test.tsx +++ b/src/components/progress/progress.test.tsx @@ -59,4 +59,18 @@ describe('EuiProgress', () => { expect(component).toMatchSnapshot(); }); + + test('has valueText and Label', () => { + const component = render( + + ); + + expect(component).toMatchSnapshot(); + }); }); diff --git a/src/components/progress/progress.tsx b/src/components/progress/progress.tsx index 2fc7da2e38d..0f831a66032 100644 --- a/src/components/progress/progress.tsx +++ b/src/components/progress/progress.tsx @@ -21,10 +21,12 @@ import React, { FunctionComponent, HTMLAttributes, ProgressHTMLAttributes, + ReactNode, } from 'react'; import classNames from 'classnames'; import { CommonProps, ExclusiveUnion } from '../common'; import { isNil } from '../../services/predicate'; +import { EuiText } from '../text'; const sizeToClassNameMap = { xs: 'euiProgress--xs', @@ -70,8 +72,8 @@ type Indeterminate = EuiProgressProps & HTMLAttributes; type Determinate = EuiProgressProps & ProgressHTMLAttributes & { max?: number; - valueText?: string; - label?: string; + valueText?: ReactNode; + label?: ReactNode; }; export const EuiProgress: FunctionComponent< @@ -99,16 +101,36 @@ export const EuiProgress: FunctionComponent< positionsToClassNameMap[position], className ); + const dataClasses = classNames('euiProgress__data', { + 'euiProgress__data--primary': color === 'primary', + }); // Because of a Firefox animation issue, indeterminate progress needs to not use . // See https://css-tricks.com/html5-progress-element/ if (determinate) { return (
-
-
{label}
-
{valueText}
-
+ {label || valueText ? ( +
+
+ + {label} + +
+
+ + {valueText} + +
+
+ ) : ( + undefined + )} Date: Thu, 25 Jun 2020 14:16:22 -0700 Subject: [PATCH 3/9] cl --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e649171278..ce2fe72cabf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Added `gutterSize` prop to `EuiFacetGroup` ([#3639](https://github.com/elastic/eui/pull/3639)) - Updated props of `EuiCode` and `EuiCodeBlock` to reflect only functional props ([#3647](https://github.com/elastic/eui/pull/3647)) +- Add `label` and `valueText` props to `EuiProgress` ([#3661](https://github.com/elastic/eui/pull/3661)) **Bug fixes** From c25a0111f75e965b1c64650714dcc56fc0b33a02 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 29 Jun 2020 16:37:56 -0700 Subject: [PATCH 4/9] remove euiText and improved design in Amsterdam --- .../src/views/progress/progress_size_color.js | 2 +- .../__snapshots__/progress.test.tsx.snap | 64 +++++++------------ src/components/progress/_progress.scss | 22 ++++++- src/components/progress/progress.tsx | 41 ++++++------ .../eui-amsterdam/overrides/_index.scss | 1 + .../eui-amsterdam/overrides/_progress.scss | 3 + 6 files changed, 68 insertions(+), 65 deletions(-) create mode 100644 src/themes/eui-amsterdam/overrides/_progress.scss diff --git a/src-docs/src/views/progress/progress_size_color.js b/src-docs/src/views/progress/progress_size_color.js index c291e4087cb..74d541c0c0f 100644 --- a/src-docs/src/views/progress/progress_size_color.js +++ b/src-docs/src/views/progress/progress_size_color.js @@ -18,4 +18,4 @@ export default () => (
-); \ No newline at end of file +); diff --git a/src/components/progress/__snapshots__/progress.test.tsx.snap b/src/components/progress/__snapshots__/progress.test.tsx.snap index 86f75b3c589..eda9aedaf29 100644 --- a/src/components/progress/__snapshots__/progress.test.tsx.snap +++ b/src/components/progress/__snapshots__/progress.test.tsx.snap @@ -1,14 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiProgress has max 1`] = ` -
- -
+ `; exports[`EuiProgress has value 1`] = ` @@ -20,53 +18,39 @@ exports[`EuiProgress has value 1`] = ` `; exports[`EuiProgress has valueText and Label 1`] = ` -
+Array [
-
-
- Label -
-
-
+ -
-
- 50 -
-
-
-
+ 50 + +
, -
+ />, +] `; exports[`EuiProgress is determinate 1`] = ` -
- -
+ `; exports[`EuiProgress is indeterminate 1`] = ` diff --git a/src/components/progress/_progress.scss b/src/components/progress/_progress.scss index 23e47b5aef5..df44439334b 100644 --- a/src/components/progress/_progress.scss +++ b/src/components/progress/_progress.scss @@ -117,6 +117,12 @@ $euiProgressColors: ( } } } + + .euiProgress__data--#{$name} { + .euiProgress__valueText { + color: $color; + } + } } @keyframes euiProgress { @@ -134,10 +140,20 @@ $euiProgressColors: ( justify-content: space-between; .euiProgress__label { - overflow: hidden; + @include euiTextTruncate; } } -.euiProgress__data--primary .euiProgress__valueText { - color: $euiColorPrimary; +.euiProgress__label, +.euiProgress__valueText { + @include euiText; + @include euiFontSize; + @include fontSize($euiFontSizeXS); +} + +.euiProgress__data--l { + .euiProgress__label, + .euiProgress__valueText { + @include fontSize($euiFontSizeS); + } } \ No newline at end of file diff --git a/src/components/progress/progress.tsx b/src/components/progress/progress.tsx index 0f831a66032..0b36d3af4f5 100644 --- a/src/components/progress/progress.tsx +++ b/src/components/progress/progress.tsx @@ -22,11 +22,11 @@ import React, { HTMLAttributes, ProgressHTMLAttributes, ReactNode, + Fragment, } from 'react'; import classNames from 'classnames'; import { CommonProps, ExclusiveUnion } from '../common'; import { isNil } from '../../services/predicate'; -import { EuiText } from '../text'; const sizeToClassNameMap = { xs: 'euiProgress--xs', @@ -51,6 +51,14 @@ export const COLORS = Object.keys(colorToClassNameMap); export type EuiProgressColor = keyof typeof colorToClassNameMap; +const dataColorToClassNameMap = { + primary: 'euiProgress__data--primary', + secondary: 'euiProgress__data--secondary', + danger: 'euiProgress__data--danger', + subdued: 'euiProgress__data--subdued', + accent: 'euiProgress__data--accent', +}; + const positionsToClassNameMap = { fixed: 'euiProgress--fixed', absolute: 'euiProgress--absolute', @@ -101,32 +109,23 @@ export const EuiProgress: FunctionComponent< positionsToClassNameMap[position], className ); - const dataClasses = classNames('euiProgress__data', { - 'euiProgress__data--primary': color === 'primary', - }); + const dataClasses = classNames( + 'euiProgress__data', + { + 'euiProgress__data--l': size === 'l', + }, + dataColorToClassNameMap[color] + ); // Because of a Firefox animation issue, indeterminate progress needs to not use . // See https://css-tricks.com/html5-progress-element/ if (determinate) { return ( -
+ {label || valueText ? (
-
- - {label} - -
-
- - {valueText} - -
+ {label} + {valueText}
) : ( undefined @@ -137,7 +136,7 @@ export const EuiProgress: FunctionComponent< value={value} {...rest as ProgressHTMLAttributes} /> -
+ ); } else { return ( diff --git a/src/themes/eui-amsterdam/overrides/_index.scss b/src/themes/eui-amsterdam/overrides/_index.scss index a8fcf7a02d1..62618cf0c41 100644 --- a/src/themes/eui-amsterdam/overrides/_index.scss +++ b/src/themes/eui-amsterdam/overrides/_index.scss @@ -10,5 +10,6 @@ @import 'modal'; @import 'overlay_mask'; @import 'popover'; +@import 'progress'; @import 'text'; diff --git a/src/themes/eui-amsterdam/overrides/_progress.scss b/src/themes/eui-amsterdam/overrides/_progress.scss new file mode 100644 index 00000000000..f9aecd478f3 --- /dev/null +++ b/src/themes/eui-amsterdam/overrides/_progress.scss @@ -0,0 +1,3 @@ +.euiProgress--native { + border-radius: $euiBorderRadius; +} From 0969284e48d8dc8bba7839d1f4524f7943f66d93 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 30 Jun 2020 13:17:44 -0700 Subject: [PATCH 5/9] a11y and changing the way valueText works --- src-docs/src/views/progress/progress_chart.js | 18 +++++------ .../__snapshots__/progress.test.tsx.snap | 5 +++- src/components/progress/progress.test.tsx | 2 +- src/components/progress/progress.tsx | 30 +++++++++++++++++-- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src-docs/src/views/progress/progress_chart.js b/src-docs/src/views/progress/progress_chart.js index 3a365b7dd20..4af42fe9e0a 100644 --- a/src-docs/src/views/progress/progress_chart.js +++ b/src-docs/src/views/progress/progress_chart.js @@ -3,11 +3,11 @@ import React, { Fragment } from 'react'; import { EuiProgress, EuiSpacer } from '../../../../src/components'; const data = [ - { label: "Men's Clothing", valueText: '80' }, - { label: "Women's Clothing", valueText: '60' }, - { label: "Women's Shoes", valueText: '45' }, - { label: "Men's Shoes", valueText: '40' }, - { label: "Women's Accessories", valueText: '24' }, + { label: "Men's Clothing", value: '80' }, + { label: "Women's Clothing", value: '60' }, + { label: "Women's Shoes", value: '45' }, + { label: "Men's Shoes", value: '40' }, + { label: "Women's Accessories", value: '24' }, ]; export default () => ( @@ -17,8 +17,8 @@ export default () => ( <> ( <> - 50 + 150 ,