@woosmap/ui 4.57.0 → 4.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/encodings.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +18 -0
- package/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/ui.iml +15 -0
- package/.idea/vcs.xml +6 -0
- package/package.json +1 -1
- package/src/components/Modal/Modal.js +6 -2
- package/src/components/Modal/Modal.stories.js +1 -0
- package/src/components/Modal/Modal.styl +2 -0
- package/src/components/ProgressBar/ProgressBar.js +70 -0
- package/src/components/ProgressBar/ProgressBar.stories.js +41 -0
- package/src/components/ProgressBar/ProgressBar.styl +33 -0
- package/src/components/ProgressBar/ProgressBar.test.js +44 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
5
|
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
|
6
|
+
<option name="ignoredPackages">
|
|
7
|
+
<value>
|
|
8
|
+
<list size="4">
|
|
9
|
+
<item index="0" class="java.lang.String" itemvalue="Fabric" />
|
|
10
|
+
<item index="1" class="java.lang.String" itemvalue="PyYAML" />
|
|
11
|
+
<item index="2" class="java.lang.String" itemvalue="Jinja2" />
|
|
12
|
+
<item index="3" class="java.lang.String" itemvalue="github3.py" />
|
|
13
|
+
</list>
|
|
14
|
+
</value>
|
|
15
|
+
</option>
|
|
16
|
+
</inspection_tool>
|
|
17
|
+
</profile>
|
|
18
|
+
</component>
|
package/.idea/misc.xml
ADDED
package/.idea/ui.iml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
<component name="TemplatesService">
|
|
9
|
+
<option name="TEMPLATE_FOLDERS">
|
|
10
|
+
<list>
|
|
11
|
+
<option value="$MODULE_DIR$/node_modules/@storybook/core/dist/server/templates" />
|
|
12
|
+
</list>
|
|
13
|
+
</option>
|
|
14
|
+
</component>
|
|
15
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import Button from '../Button/Button';
|
|
|
7
7
|
import withClickOutside from '../withClickOutside/withClickOutside';
|
|
8
8
|
import { tr } from '../utils/locale';
|
|
9
9
|
import Icon from '../Icon/Icon';
|
|
10
|
+
import ProgressBar from '../ProgressBar/ProgressBar';
|
|
10
11
|
|
|
11
12
|
class Modal extends Component {
|
|
12
13
|
constructor(props) {
|
|
@@ -141,11 +142,12 @@ class Modal extends Component {
|
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
renderLoadingLayer = () => {
|
|
144
|
-
const { loadingLayerMessage } = this.props;
|
|
145
|
+
const { loadingLayerMessage, loadingProgression } = this.props;
|
|
145
146
|
return (
|
|
146
147
|
<div className="modal__body__loading-layer">
|
|
147
|
-
<Icon isLoad icon="load" size={60} />
|
|
148
|
+
{loadingProgression === undefined && <Icon isLoad icon="load" size={60} />}
|
|
148
149
|
<span>{loadingLayerMessage}</span>
|
|
150
|
+
{loadingProgression !== undefined && <ProgressBar percentage={loadingProgression} />}
|
|
149
151
|
</div>
|
|
150
152
|
);
|
|
151
153
|
};
|
|
@@ -214,6 +216,7 @@ Modal.defaultProps = {
|
|
|
214
216
|
noHeader: false,
|
|
215
217
|
loadingLayerMessage: '',
|
|
216
218
|
loadingLayer: false,
|
|
219
|
+
loadingProgression: undefined,
|
|
217
220
|
};
|
|
218
221
|
|
|
219
222
|
Modal.propTypes = {
|
|
@@ -241,6 +244,7 @@ Modal.propTypes = {
|
|
|
241
244
|
noHeader: PropTypes.bool,
|
|
242
245
|
loadingLayerMessage: PropTypes.string,
|
|
243
246
|
loadingLayer: PropTypes.bool,
|
|
247
|
+
loadingProgression: PropTypes.number,
|
|
244
248
|
};
|
|
245
249
|
|
|
246
250
|
export default withClickOutside(Modal, '.ignore-click-outside-modal');
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import './ProgressBar.styl';
|
|
5
|
+
|
|
6
|
+
class ProgressBar extends Component {
|
|
7
|
+
getColor = (percentage) => {
|
|
8
|
+
const { colorThreshold } = this.props;
|
|
9
|
+
if (!colorThreshold || colorThreshold.length !== 2 || percentage < colorThreshold[0]) return 'green';
|
|
10
|
+
if (percentage >= colorThreshold[0] && percentage < colorThreshold[1]) return 'orange';
|
|
11
|
+
return 'red';
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
getExtremitiesText = (text) => <span>{text}</span>;
|
|
15
|
+
|
|
16
|
+
render() {
|
|
17
|
+
const { percentage, leftText, rightText, description, colorThreshold } = this.props;
|
|
18
|
+
return (
|
|
19
|
+
<div className="progress">
|
|
20
|
+
{description && <div className="progress__legend">{description}</div>}
|
|
21
|
+
<div className="progress__wrapper">
|
|
22
|
+
{leftText && this.getExtremitiesText(leftText)}
|
|
23
|
+
<div
|
|
24
|
+
className={classNames('progress__bar', {
|
|
25
|
+
[`progress__bar--${this.getColor(percentage)}`]: !!colorThreshold,
|
|
26
|
+
})}
|
|
27
|
+
>
|
|
28
|
+
<div className="progress__gauge" style={{ width: `${percentage}%` }} />
|
|
29
|
+
</div>
|
|
30
|
+
{rightText && this.getExtremitiesText(rightText)}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function withinHundred(isRequired) {
|
|
38
|
+
return function fn(props, propName, componentName = 'ANONYMOUS') {
|
|
39
|
+
const value = props[propName];
|
|
40
|
+
if (value === null && isRequired) {
|
|
41
|
+
return new Error(`Required ${propName} was not specified in ${componentName}.`);
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === 'number') {
|
|
44
|
+
return value >= 0 && value <= 100
|
|
45
|
+
? null
|
|
46
|
+
: new Error(`${propName} in ${componentName} is not within 0 to 100`);
|
|
47
|
+
}
|
|
48
|
+
return new Error(`${propName} in ${componentName} is not a number`);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const customPropType = withinHundred(false);
|
|
53
|
+
customPropType.isRequired = withinHundred(true);
|
|
54
|
+
|
|
55
|
+
ProgressBar.defaultProps = {
|
|
56
|
+
colorThreshold: null,
|
|
57
|
+
leftText: '',
|
|
58
|
+
rightText: '',
|
|
59
|
+
description: '',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
ProgressBar.propTypes = {
|
|
63
|
+
percentage: customPropType.isRequired,
|
|
64
|
+
colorThreshold: PropTypes.arrayOf(PropTypes.number),
|
|
65
|
+
leftText: PropTypes.string,
|
|
66
|
+
rightText: PropTypes.string,
|
|
67
|
+
description: PropTypes.string,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default ProgressBar;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ProgressBar from './ProgressBar';
|
|
3
|
+
|
|
4
|
+
const Story = {
|
|
5
|
+
title: 'base/ProgressBar',
|
|
6
|
+
component: ProgressBar,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default Story;
|
|
10
|
+
|
|
11
|
+
const TemplateDefault = () => (
|
|
12
|
+
<div style={{ width: '30%' }}>
|
|
13
|
+
<ProgressBar percentage={34} />
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
export const Default = TemplateDefault.bind({});
|
|
17
|
+
Default.args = {};
|
|
18
|
+
|
|
19
|
+
const TemplateCustom = (args) => {
|
|
20
|
+
const { percentage, colorThreshold, leftText, rightText, description } = args;
|
|
21
|
+
return (
|
|
22
|
+
<div style={{ width: '30%' }}>
|
|
23
|
+
<ProgressBar
|
|
24
|
+
percentage={percentage}
|
|
25
|
+
colorThreshold={colorThreshold}
|
|
26
|
+
leftText={leftText}
|
|
27
|
+
rightText={rightText}
|
|
28
|
+
description={description}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const ProgressBarCustom = TemplateCustom.bind({});
|
|
35
|
+
ProgressBarCustom.args = {
|
|
36
|
+
percentage: 25,
|
|
37
|
+
colorThreshold: [30, 75],
|
|
38
|
+
leftText: 'leftText',
|
|
39
|
+
rightText: 'rightText',
|
|
40
|
+
description: 'description',
|
|
41
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.progress
|
|
2
|
+
width 100%
|
|
3
|
+
font-size 1.2rem
|
|
4
|
+
font-weight 600
|
|
5
|
+
margin-top 3rem
|
|
6
|
+
> :not(:last-child)
|
|
7
|
+
margin-bottom 1rem
|
|
8
|
+
&__legend
|
|
9
|
+
font-size 1.1rem
|
|
10
|
+
font-weight 400
|
|
11
|
+
text-align center
|
|
12
|
+
&__wrapper
|
|
13
|
+
display flex
|
|
14
|
+
align-items center
|
|
15
|
+
justify-content space-between
|
|
16
|
+
> :not(:last-child)
|
|
17
|
+
margin-right 1rem
|
|
18
|
+
&__bar
|
|
19
|
+
width 100%
|
|
20
|
+
margin auto
|
|
21
|
+
height 0.3rem
|
|
22
|
+
background-color lightgrey
|
|
23
|
+
border-radius .6rem
|
|
24
|
+
overflow hidden
|
|
25
|
+
&__gauge
|
|
26
|
+
background-color $primary
|
|
27
|
+
height 100%
|
|
28
|
+
.progress__bar--green &
|
|
29
|
+
background-color $progressGreen
|
|
30
|
+
.progress__bar--orange &
|
|
31
|
+
background-color $progressOrange
|
|
32
|
+
.progress__bar--red &
|
|
33
|
+
background-color $progressRed
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import ProgressBar from './ProgressBar';
|
|
5
|
+
|
|
6
|
+
describe('<ProgressBar />', () => {
|
|
7
|
+
it.each([['description'], ['leftText'], ['rightText']])('renders %s if provided via props', (prop) => {
|
|
8
|
+
const base = { percentage: 0 };
|
|
9
|
+
const { rerender } = render(<ProgressBar {...base} />);
|
|
10
|
+
expect(screen.queryByText(prop)).not.toBeInTheDocument();
|
|
11
|
+
base[prop] = prop;
|
|
12
|
+
rerender(<ProgressBar {...base} />);
|
|
13
|
+
expect(screen.queryByText(prop)).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
it('progress bar width is provided percentage', () => {
|
|
16
|
+
const { rerender, container } = render(<ProgressBar percentage={0} />);
|
|
17
|
+
const [progressBarDiv] = container.querySelectorAll('.progress__gauge');
|
|
18
|
+
expect(progressBarDiv).toHaveAttribute('style', 'width: 0%;');
|
|
19
|
+
rerender(<ProgressBar percentage={50} />);
|
|
20
|
+
expect(progressBarDiv).toHaveAttribute('style', 'width: 50%;');
|
|
21
|
+
rerender(<ProgressBar percentage={100} />);
|
|
22
|
+
expect(progressBarDiv).toHaveAttribute('style', 'width: 100%;');
|
|
23
|
+
});
|
|
24
|
+
it('progress bar container uses correct color class depending of its color threshold', () => {
|
|
25
|
+
const base = { colorThreshold: [40, 70] };
|
|
26
|
+
const renderBar = (percentage) => <ProgressBar percentage={percentage} {...base} />;
|
|
27
|
+
const { rerender, container } = render(renderBar(0));
|
|
28
|
+
const [progressDiv] = container.querySelectorAll('.progress__bar');
|
|
29
|
+
const expectColor = (color) => expect(progressDiv).toHaveClass(`progress__bar--${color}`);
|
|
30
|
+
expectColor('green');
|
|
31
|
+
rerender(renderBar(1));
|
|
32
|
+
expectColor('green');
|
|
33
|
+
rerender(renderBar(40));
|
|
34
|
+
expectColor('orange');
|
|
35
|
+
rerender(renderBar(41));
|
|
36
|
+
expectColor('orange');
|
|
37
|
+
rerender(renderBar(70));
|
|
38
|
+
expectColor('red');
|
|
39
|
+
rerender(renderBar(71));
|
|
40
|
+
expectColor('red');
|
|
41
|
+
rerender(renderBar(100));
|
|
42
|
+
expectColor('red');
|
|
43
|
+
});
|
|
44
|
+
});
|