Skip to content

Commit

Permalink
Couleur des barres de conférence
Browse files Browse the repository at this point in the history
  • Loading branch information
laem committed Apr 26, 2021
1 parent 51fbd61 commit b630a6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/sites/publicodes/conference/Conference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default () => {
return (
<div>
<h1>{emoji('🏟️ ')} Conférence</h1>
<Stats {...{ elements: Object.values(elements), users, username }} />
<Stats {...{ elements, users, username }} />

{room && <Instructions {...{ users, username, room }} />}
{!room && (
Expand Down
19 changes: 11 additions & 8 deletions source/sites/publicodes/conference/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const computeHumanMean = (simulationArray) => {
const testResults = [12, 25, 22, 8, 4, 7, 9, 8, 11, 10]

export default ({ elements, users, username }) => {
const mean = computeMean(elements),
humanMean = computeHumanMean(elements)
if (!users) return null
const values = Object.values(elements)
const mean = computeMean(values),
humanMean = computeHumanMean(values)

return (
<div>
Expand All @@ -43,20 +45,21 @@ export default ({ elements, users, username }) => {
}
`}
>
<li key="legendLeft">{Math.round(Math.min(...elements) / 1000)}</li>
{elements.map((el) => (
<li key="legendLeft">{Math.round(Math.min(...values) / 1000)}</li>
{Object.entries(elements).map(([usernameI, value]) => (
<li
key={el}
key={usernameI}
css={`
height: 100%;
width: 10px;
left: ${(el / Math.max(...elements)) * 100 * 0.8}%;
background: black;
left: ${(value / Math.max(...values)) * 100 * 0.8}%;
background: ${users.find((u) => u.name === usernameI)?.color ||
'black'};
opacity: 0.2;
`}
></li>
))}
<li key="legendRight">{Math.round(Math.max(...elements) / 1000)}</li>
<li key="legendRight">{Math.round(Math.max(...values) / 1000)}</li>
</div>
)}
</div>
Expand Down

0 comments on commit b630a6b

Please sign in to comment.