Skip to content

Commit cfb5316

Browse files
authored
Merge pull request #2953 from SUI-Components/updtae-indicator-color
ADD color tint to the indicator properly
2 parents 229e5e6 + e41e9c4 commit cfb5316

File tree

8 files changed

+77
-32
lines changed

8 files changed

+77
-32
lines changed

components/atom/progressBar/src/ProgressBarCircle/Indicator.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import cx from 'classnames'
22
import PropTypes from 'prop-types'
33

4-
import {SIZES, STATUS} from '../settings.js'
4+
import {SIZES, STATUS, COLORS} from '../settings.js'
55
import {INDICATOR_CLASS_NAME} from './settings.js'
66

7-
const Indicator = ({percentage, status, errorIcon, size, children}) => {
7+
const Indicator = ({percentage, status, errorIcon, size, children, color}) => {
88
if (status === STATUS.LOADING) return null
99
return (
10-
<span
11-
className={cx(INDICATOR_CLASS_NAME, `${INDICATOR_CLASS_NAME}--${status}`, `${INDICATOR_CLASS_NAME}--${size}`)}
10+
<div
11+
className={cx(INDICATOR_CLASS_NAME, `${INDICATOR_CLASS_NAME}--${status}`, `${INDICATOR_CLASS_NAME}--${size}`, {
12+
[`${INDICATOR_CLASS_NAME}--color-${color}`]: color
13+
})}
1214
>
13-
{status === STATUS.PROGRESS && (children || `${percentage}%`)}
14-
{status === STATUS.ERROR && errorIcon}
15-
</span>
15+
<span>
16+
{status === STATUS.PROGRESS && (children || `${percentage}%`)}
17+
{status === STATUS.ERROR && errorIcon}
18+
</span>
19+
</div>
1620
)
1721
}
1822

@@ -21,6 +25,7 @@ Indicator.propTypes = {
2125
status: PropTypes.oneOf(Object.values(STATUS)),
2226
errorIcon: PropTypes.node,
2327
size: PropTypes.oneOf(Object.values(SIZES)),
28+
color: PropTypes.oneOf(Object.values(COLORS)),
2429
children: PropTypes.node
2530
}
2631

components/atom/progressBar/src/ProgressBarCircle/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const ProgressBarCircle = ({
3636
color={color}
3737
/>
3838
{!hideIndicator && (
39-
<Indicator percentage={percentage} size={size} status={status} errorIcon={errorIcon}>
39+
<Indicator color={color} percentage={percentage} size={size} status={status} errorIcon={errorIcon}>
4040
{children}
4141
</Indicator>
4242
)}

components/atom/progressBar/src/ProgressBarCircle/index.scss

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ $base-class-circle: '#{$base-class}Circle';
44
background-color: transparent;
55
font-size: $fz-atom-circle-progress-bar-text--outer;
66
position: relative;
7+
display: flex;
8+
flex-direction: row;
9+
flex-wrap: nowrap;
710

811
&--small {
912
height: $h-atom-circle-progress-bar-circle-small;
@@ -48,8 +51,15 @@ $base-class-circle: '#{$base-class}Circle';
4851
padding: 0;
4952
position: absolute;
5053
text-align: center;
51-
&--small:not(&--error) {
52-
margin-left: $ml-atom-circle-progress-bar-text--outer;
54+
&--small {
55+
top: 0;
56+
bottom: 0;
57+
left: 100%;
58+
display: flex;
59+
align-items: center;
60+
&:not(&--error) {
61+
margin-left: $ml-atom-circle-progress-bar-text--outer;
62+
}
5363
}
5464

5565
&--medium {
@@ -83,6 +93,13 @@ $base-class-circle: '#{$base-class}Circle';
8393
fill: $c-atom-circle-progress-bar-trail--error;
8494
}
8595
}
96+
&--color {
97+
@each $colorName, $colorValue in $c-progress-bar-fill-array {
98+
&-#{$colorName} {
99+
color: $colorValue;
100+
}
101+
}
102+
}
86103
}
87104

88105
&-circle {

components/atom/progressBar/src/ProgressBarLine/Indicator/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@ import cx from 'classnames'
22
import PropTypes from 'prop-types'
33

44
import {CLASS_INDICATOR} from './settings.js'
5+
import {COLORS} from '../../settings.js'
56

6-
const Indicator = ({indicatorBottom, indicatorTotal, percentage}) => {
7+
const Indicator = ({indicatorBottom, indicatorTotal, percentage, color}) => {
78
return (
8-
<span className={cx(CLASS_INDICATOR, `${CLASS_INDICATOR}--${indicatorBottom ? 'bottom' : 'top'}`)}>
9+
<div
10+
className={cx(
11+
CLASS_INDICATOR,
12+
{
13+
[`${CLASS_INDICATOR}--color-${color}`]: color
14+
},
15+
`${CLASS_INDICATOR}--${indicatorBottom ? 'bottom' : 'top'}`
16+
)}
17+
>
918
<strong>{percentage}</strong>
1019
{indicatorTotal ? `/100` : `%`}
11-
</span>
20+
</div>
1221
)
1322
}
1423

@@ -17,7 +26,8 @@ Indicator.displayName = 'Indicator'
1726
Indicator.propTypes = {
1827
indicatorBottom: PropTypes.string,
1928
indicatorTotal: PropTypes.number,
20-
percentage: PropTypes.number
29+
percentage: PropTypes.number,
30+
color: PropTypes.oneOf(Object.values(COLORS))
2131
}
2232

2333
export default Indicator

components/atom/progressBar/src/ProgressBarLine/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const ProgressBarLine = ({
3535
hideIndicator,
3636
indicatorBottom,
3737
percentage: percentageArray[0],
38-
indicatorTotal
38+
indicatorTotal,
39+
color
3940
})
4041

4142
return (

components/atom/progressBar/src/ProgressBarLine/index.scss

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
$base-class-line: '#{$base-class}Line';
22

33
#{$base-class} {
4-
&-indicator {
5-
display: inline-block;
6-
font-size: $fz-s;
7-
line-height: $lh-s;
8-
9-
&--top {
10-
margin-bottom: $m-base;
11-
}
12-
13-
&--bottom {
14-
margin-top: $m-base;
15-
}
16-
}
17-
184
&-container {
195
&--error {
206
background: $bg-progress-bar--error;
@@ -57,6 +43,27 @@ $base-class-line: '#{$base-class}Line';
5743
overflow: hidden;
5844
position: absolute;
5945

46+
&-indicator {
47+
display: inline-block;
48+
font-size: $fz-s;
49+
line-height: $lh-s;
50+
51+
&--top {
52+
margin-bottom: $m-base;
53+
}
54+
55+
&--bottom {
56+
margin-top: $m-base;
57+
}
58+
&--color {
59+
@each $colorName, $colorValue in $c-progress-bar-fill-array {
60+
&-#{$colorName} {
61+
color: $colorValue;
62+
}
63+
}
64+
}
65+
}
66+
6067
&#{$this}--color {
6168
@each $colorName, $colorValue in $c-progress-bar-fill-array {
6269
&-#{$colorName}:not(#{$this}--status-error):not(#{$this}--status-loading):not(#{$this}--status-success) {

components/atom/progressBar/src/ProgressBarLine/useIndicator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import Indicator from './Indicator/index.js'
22

3-
const useIndicator = ({hideIndicator, indicatorBottom, percentage, indicatorTotal}) => {
3+
const useIndicator = ({hideIndicator, indicatorBottom, percentage, indicatorTotal, color}) => {
44
if (hideIndicator) return []
55
const indicator = (
6-
<Indicator indicatorBottom={indicatorBottom} percentage={percentage} indicatorTotal={indicatorTotal} />
6+
<Indicator
7+
color={color}
8+
indicatorBottom={indicatorBottom}
9+
percentage={percentage}
10+
indicatorTotal={indicatorTotal}
11+
/>
712
)
813
return [!indicatorBottom ? indicator : null, indicatorBottom ? indicator : null]
914
}

components/atom/progressBar/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ProgressBarCircle from './ProgressBarCircle/index.js'
44
import ProgressBarLine from './ProgressBarLine/index.js'
55
import {COLORS, LINE_CAPS, SIZES, STATUS, STROKE_SIZES, TYPES} from './settings.js'
66

7-
const AtomProgressBar = ({type = TYPES.LINE, status = STATUS.PROGRESS, color = COLORS.PRIMARY, size, ...props}) => {
7+
const AtomProgressBar = ({type = TYPES.LINE, status = STATUS.PROGRESS, color, size, ...props}) => {
88
switch (type) {
99
case TYPES.CIRCLE:
1010
return <ProgressBarCircle size={size} status={status} color={color} {...props} />

0 commit comments

Comments
 (0)