-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add PercentageBar component (#1232)
- Loading branch information
Showing
6 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
``` | ||
import PercentageBar from 'cozy-ui/transpiled/react/PercentageBar'; | ||
initialState = { percentage: 0.5 * 100 }; | ||
<> | ||
<button onClick={() => setState({ percentage: Math.random() * 100})}>Random percentage</button> | ||
{(state.percentage).toFixed(2)}% | ||
<PercentageBar | ||
color="var(--primaryColor)" | ||
value={state.percentage} | ||
style={{ marginBottom: '2rem' }} | ||
/> | ||
<PercentageBar | ||
color="var(--emerald)" | ||
value={state.percentage} | ||
/> | ||
</> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import PercentageLine from '../PercentageLine' | ||
import styles from './styles.styl' | ||
import cx from 'classnames' | ||
|
||
const PercentageBar = props => { | ||
const { value, color, className, ...rest } = props | ||
|
||
return ( | ||
<div className={cx(styles.PercentageBar, className)} {...rest}> | ||
<PercentageLine | ||
value={value} | ||
color={color} | ||
className={styles.PercentageBar__line} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default PercentageBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
radius = 4px | ||
|
||
.PercentageBar | ||
background-color var(--paleGrey) | ||
border 1px solid var(--silver) | ||
height 1.5rem | ||
border-radius radius | ||
|
||
.PercentageBar__line | ||
height 100% | ||
border-radius radius |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters