Skip to content

Commit

Permalink
improve highlight avail rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jho44 committed Sep 26, 2023
1 parent 6beafbb commit 1817f4a
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/routes/calendar/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Legend from '../Legend.svelte';
import Button from '../Button.svelte';
import { invalidate } from '$app/navigation';
import { onMount, tick, afterUpdate } from 'svelte';
import { onMount, tick } from 'svelte';
import { page } from '$app/stores';
import NavBar from '../NavBar.svelte';
import { writeReq } from '$lib/utils';
Expand Down Expand Up @@ -88,6 +88,23 @@
let timeErrs = new Set();
let schedDiffs: string[] = [];
const rowColors = [...Array(21).keys()].map((_, i) => getRowColor(i));
function getRowColor(i: number) {
if (i >= rows.length) return i % 2 ? '#f2f2f2' : 'white';
if (rows[i].availRange && rows[i].availRange !== 'Busy' && !shownRows.has(i)) {
return '#dbf4ff';
}
return i % 2 ? '#f2f2f2' : 'white';
}
const updateRowColors = () => {
[...Array(21).keys()].map((_, i) => {
tick().then(() => {
rowColors[i] = getRowColor(i);
});
});
};
async function markAs(i: number, status: string, updateUI = true) {
const availRangeParts =
status === AvailabilityStatus.AVAILABLE
Expand Down Expand Up @@ -174,6 +191,7 @@
};
schedDiffs = generateDiffSchedule(ogRows, rows);
schedFull = generateFullSchedule(rows);
updateRowColors();
}
return 'ok';
}
Expand Down Expand Up @@ -201,6 +219,8 @@
}));
schedDiffs = generateDiffSchedule(ogRows, rows);
schedFull = generateFullSchedule(rows);
updateRowColors();
}
function toggleEmoticon(i: number, emoticon: string) {
Expand Down Expand Up @@ -241,20 +261,7 @@
});
}
const rowColors = [...Array(21).keys()].map((_, i) => getRowColor(i));
function getRowColor(i: number) {
if (i >= rows.length) return i % 2 ? '#f2f2f2' : 'white';
if (rows[i].availRange && rows[i].availRange !== 'Busy' && !shownRows.has(i)) {
return '#dbf4ff';
}
return i % 2 ? '#f2f2f2' : 'white';
}
$: [...Array(21).keys()].map((_, i) => {
tick().then(() => {
rowColors[i] = getRowColor(i);
});
});
$: updateRowColors();
function showEditor(i: number) {
shownRows.add(i);
Expand Down

0 comments on commit 1817f4a

Please sign in to comment.