Name generation and gradient calculation

This commit is contained in:
Ben Grant 2021-03-04 19:00:38 +11:00
parent 8e5954e0ca
commit ba1697ffc7
12 changed files with 418 additions and 54 deletions

View file

@ -27,6 +27,8 @@ const AvailabilityViewer = ({
dates,
times,
people = [],
min = 0,
max = 0,
...props
}) => {
const [tooltip, setTooltip] = useState(null);
@ -52,14 +54,16 @@ const AvailabilityViewer = ({
{times.map((time, i) => {
const peopleHere = people.filter(person => person.availability.includes(`${time}-${date}`)).map(person => person.name);
return (
<Time
key={i}
time={time}
className="time"
people={peopleHere}
peopleCount={peopleHere.length}
aria-label={peopleHere.join(', ')}
totalPeople={people.length}
maxPeople={max}
minPeople={min}
onMouseEnter={(e) => {
const cellBox = e.currentTarget.getBoundingClientRect();
setTooltip({

View file

@ -58,7 +58,9 @@ export const Time = styled.div`
border-top: 1px dotted ${props.theme.primaryDark};
`}
background-color: ${props => `${props.theme.primary}${Math.round((props.people.length/(props.totalPeople))*255).toString(16)}`};
background-color: ${props => `${props.theme.primary}${Math.round(((props.peopleCount-props.minPeople)/(props.maxPeople-props.minPeople))*255).toString(16)}`};
count: ${props => props.peopleCount};
max: ${props => props.maxPeople};
`;
export const Spacer = styled.div`

View file

@ -10,13 +10,14 @@ import {
const Legend = ({
min,
max,
total,
...props
}) => {
const theme = useTheme();
return (
<Wrapper>
<Label>{min}/{max} available</Label>
<Label>{min}/{total} available</Label>
<Bar>
{[...Array(max-min+1).keys()].map(i =>
@ -24,7 +25,7 @@ const Legend = ({
)}
</Bar>
<Label>{max}/{max} available</Label>
<Label>{max}/{total} available</Label>
</Wrapper>
);
};