added a progress bar
This commit is contained in:
@@ -1,28 +1,50 @@
|
|||||||
<script>
|
<script>
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { currentModule } from "./stores"
|
import { currentModule, position } from "./stores"
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher()
|
const dispatcher = createEventDispatcher()
|
||||||
|
|
||||||
export let module
|
export let module
|
||||||
$: klass = $currentModule && $currentModule.name === module.name ? "current" : ""
|
const duration = module.end - module.start
|
||||||
|
const getProgress = pos => (pos - module.start) / duration * 100
|
||||||
|
|
||||||
|
let styl; let selected; let progress;
|
||||||
|
$: selected = $currentModule && $currentModule.name === module.name
|
||||||
|
$: if (selected) progress = getProgress($position)
|
||||||
|
$: styl = selected
|
||||||
|
? `background: linear-gradient(to right, var(--finished-bg) 0%, var(--finished-bg) ${progress + 1}%, var(--pending-bg) ${100 - progress}%, var(--pending-bg) 100%)`
|
||||||
|
: ""
|
||||||
|
|
||||||
// TODO: add checkboxes for 'want to watch'
|
// TODO: add checkboxes for 'want to watch'
|
||||||
// TODO: gray out watched modules
|
// TODO: gray out watched modules
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={() => dispatcher("selectModule", { module })} class="{klass}"><span>I want to {module.outcome}.</span></div>
|
<div on:click={() => dispatcher("selectModule", { module })} ><span style="{styl}" >I want to {module.outcome}.</span></div>
|
||||||
|
{#if progress}
|
||||||
|
<div>
|
||||||
|
<progress value={progress} max=100>Hi</progress>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
div.current span { background-color: yellow;}
|
/* span.current { background-color: yellow;} */
|
||||||
div span:hover { background-color: lightgrey; }
|
span.current:hover { background-color: lightgrey; }
|
||||||
|
:root {
|
||||||
|
--pending-bg: yellow;
|
||||||
|
--finished-bg: white;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
div.current span { background-color: blue; }
|
:root {
|
||||||
div span:hover {
|
--pending-bg: #222;
|
||||||
|
--finished-bg: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* span.current { background-color: blue; } */
|
||||||
|
span:hover {
|
||||||
background-color: lavender;
|
background-color: lavender;
|
||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
@@ -33,4 +55,5 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: .3em;
|
padding: .3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user