Skip to content

Commit

Permalink
random color for stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariaky committed Nov 28, 2023
1 parent 7686e2c commit b4a7605
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/components/Statistics/GetRandomColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getRandomColor() {
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, 0)}`;
}
3 changes: 2 additions & 1 deletion src/components/Statistics/Statistics.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import css from './Statistics.module.css';
import {getRandomColor} from './GetRandomColor';

export const Statistics =({ title, stats }) => {
return (
Expand All @@ -7,7 +8,7 @@ export const Statistics =({ title, stats }) => {

<ul className={css.statList}>{stats.map(item => {
return (
<li key={item.id} className={css.item} >
<li key={item.id} className={css.item} style={{backgroundColor: getRandomColor(), flex: 1, }}>
<span className={css.label}>{item.label}</span>
<span className={css.percentage}>{item.percentage}%</span>
</li>
Expand Down
2 changes: 0 additions & 2 deletions src/components/Statistics/Statistics.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
justify-content: space-between;
padding: 0;
margin-top: 30px;
background-color: white;
}

.item {
border: 1px solid rgb(213, 211, 211);
width: calc(100% / 5);
padding-bottom: 20px;
color: rgb(98, 97, 97);
}

.label {
Expand Down

0 comments on commit b4a7605

Please sign in to comment.