Standa Lukeš
4 years ago
8 changed files with 118 additions and 47 deletions
@ -0,0 +1,23 @@ |
|||||
|
<script type="ts"> |
||||
|
import { grabAssignment } from "./ksp-task-grabber"; |
||||
|
import { nonNull } from './helpers' |
||||
|
export let task: string | null | undefined |
||||
|
</script> |
||||
|
<style> |
||||
|
div { |
||||
|
text-align: justify; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div> |
||||
|
{#if task != null} |
||||
|
{#await grabAssignment(nonNull(task))} |
||||
|
Načítám úlohu |
||||
|
{:then task} |
||||
|
{@html task.titleHtml} |
||||
|
<hr> |
||||
|
{@html task.description} |
||||
|
<div class="clearfloat" /> |
||||
|
{/await} |
||||
|
{/if} |
||||
|
</div> |
@ -1,42 +1,67 @@ |
|||||
<script lang="ts"> |
<script lang="ts"> |
||||
import { grabAssignment } from "./ksp-task-grabber"; |
import { grabAssignment } from "./ksp-task-grabber"; |
||||
import type { TasksFile, TaskDescriptor } from "./task-loader"; |
import type { TasksFile, TaskDescriptor } from "./task-loader"; |
||||
|
import TaskDisplay from "./TaskDisplay.svelte"; |
||||
|
|
||||
// export let tasks: TasksFile; |
// export let tasks: TasksFile; |
||||
export let selectedTask: string | null = null |
let selectedTask: TaskDescriptor | null = null |
||||
export let finalSelect: boolean = false |
|
||||
let mouse: boolean = false |
|
||||
|
|
||||
let height: string; |
let heightClass: "collapsed" | "full" | "preview" = "collapsed" |
||||
$: height = selectedTask == null && !mouse ? "0" : |
|
||||
finalSelect ? "100%" : |
|
||||
"100px" |
|
||||
|
|
||||
let taskPromise: Promise<string | null> |
let taskPromise: Promise<string | null> |
||||
|
|
||||
|
|
||||
|
export function preSelect(task: TaskDescriptor) { |
||||
|
if (heightClass != "full") { |
||||
|
selectedTask = task |
||||
|
heightClass = "preview" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export function unPreselect(task: TaskDescriptor) { |
||||
|
setTimeout(() => { |
||||
|
if (selectedTask && task.id == selectedTask.id && heightClass != "full") { |
||||
|
heightClass = "collapsed" |
||||
|
} |
||||
|
}, 10); |
||||
|
} |
||||
|
|
||||
|
export function select(task: TaskDescriptor) { |
||||
|
selectedTask = task |
||||
|
heightClass = "full" |
||||
|
} |
||||
|
|
||||
$: { |
$: { |
||||
if (selectedTask != null) |
if (selectedTask != null) |
||||
taskPromise = grabAssignment(selectedTask) |
taskPromise = grabAssignment(selectedTask.id) |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<style> |
<style> |
||||
.panel { |
.panel { |
||||
position: absolute; |
position: absolute; |
||||
width: 100%; |
width: calc(100%-200px); |
||||
background-color: #222; |
background-color: #222; |
||||
overflow: hidden; |
overflow: hidden; |
||||
|
padding: 0 100px 0 100px; |
||||
|
} |
||||
|
.panel.collapsed:not(:hover) { |
||||
|
display: none; |
||||
|
} |
||||
|
.panel.preview, .panel:not(.full):hover { |
||||
|
height: 100px; |
||||
|
} |
||||
|
.panel.full { |
||||
|
min-height: 100%; |
||||
} |
} |
||||
|
.closeButton { display: none } |
||||
|
.panel.full .closeButton { display: inherit } |
||||
</style> |
</style> |
||||
|
|
||||
<div class="panel" style="height: {height}" on:mouseover={() => mouse = false} on:mouseout={() => mouse = false}> |
<div class="panel {heightClass}" |
||||
{#if selectedTask != null} |
on:click={() => selectedTask && select(selectedTask)}> |
||||
{#await taskPromise} |
<TaskDisplay task={selectedTask?.id} /> |
||||
Načítám úložku {selectedTask} ;) |
<button type=button class="closeButton" on:click|stopPropagation={() => heightClass = "collapsed"}> |
||||
{:then task} |
|
||||
{@html task} |
|
||||
{/await} |
|
||||
<button type=button on:click={() => finalSelect = false}> |
|
||||
Zavřít |
Zavřít |
||||
</button> |
</button> |
||||
{/if} |
|
||||
</div> |
</div> |
||||
|
@ -0,0 +1 @@ |
|||||
|
export function nonNull<T>(a: T | null | undefined): T { return a! } |
Reference in new issue