Browse Source
refactored Item, Task and Log entry to share code. TaskEntry is still a bit messy, but that's because of the weird icon stuffs.
main
refactored Item, Task and Log entry to share code. TaskEntry is still a bit messy, but that's because of the weird icon stuffs.
main
Gisle Aune
4 years ago
5 changed files with 199 additions and 288 deletions
-
111svelte-ui/src/components/ChildEntry.svelte
-
80svelte-ui/src/components/ItemEntry.svelte
-
34svelte-ui/src/components/ItemLink.svelte
-
102svelte-ui/src/components/LogEntry.svelte
-
76svelte-ui/src/components/TaskEntry.svelte
@ -0,0 +1,111 @@ |
|||
<script lang="ts"> |
|||
import type { IconName, iconNames } from "../external/icons"; |
|||
import DaysLeft from "./DaysLeft.svelte"; |
|||
import Icon from "./Icon.svelte"; |
|||
import LinkHook from "./LinkHook.svelte"; |
|||
|
|||
interface EntryCommon { |
|||
id: string |
|||
name?: string |
|||
description: string |
|||
icon?: IconName |
|||
|
|||
startTime?: string |
|||
endTime?: string |
|||
createdTime?: string |
|||
|
|||
active?: boolean |
|||
completedAmount?: number |
|||
itemAmount?: number |
|||
task?: EntryCommonSub |
|||
} |
|||
|
|||
interface EntryCommonSub { |
|||
name: string |
|||
icon: IconName |
|||
} |
|||
|
|||
export let entry: EntryCommon = null; |
|||
|
|||
let iconName: IconName; |
|||
let displayName: string; |
|||
|
|||
$: iconName = entry.task?.icon || entry.icon; |
|||
$: displayName = entry.name || entry.task?.name || ""; |
|||
</script> |
|||
|
|||
<div class="child-entry"> |
|||
<LinkHook id={entry.id} /> |
|||
<div class="body"> |
|||
<div class="header"> |
|||
<slot name="icon"> |
|||
<div class="icon"> |
|||
<Icon name={iconName} /> |
|||
</div> |
|||
</slot> |
|||
<div class="name">{entry.name}</div> |
|||
{#if (entry.endTime != null)} |
|||
<div class="times"> |
|||
<DaysLeft startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} /> |
|||
</div> |
|||
{/if} |
|||
</div> |
|||
<div class="description"> |
|||
<p>{entry.description}</p> |
|||
<slot></slot> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
div.child-entry { |
|||
display: flex; |
|||
flex-direction: row; |
|||
margin: 0.25em 0 0.75em 0; |
|||
} |
|||
div.icon { |
|||
display: flex; |
|||
flex-direction: column; |
|||
font-size: 1em; |
|||
padding: 0.2em .5ch; |
|||
|
|||
margin-right: 0.5em; |
|||
background: #444; |
|||
color: #CCC; |
|||
} |
|||
|
|||
div.body { |
|||
display: flex; |
|||
flex-direction: column; |
|||
width: 100%; |
|||
} |
|||
div.header { |
|||
display: flex; |
|||
flex-direction: row; |
|||
background: #333; |
|||
} |
|||
|
|||
div.name { |
|||
font-size: 1em; |
|||
font-weight: 100; |
|||
margin: auto 0; |
|||
vertical-align: middle; |
|||
padding: 0.125em .5ch; |
|||
} |
|||
div.times { |
|||
margin-left: auto; |
|||
margin-right: 0.25ch; |
|||
padding: 0.125em 0; |
|||
} |
|||
|
|||
div.description { |
|||
padding: 0.25em 1ch; |
|||
background: #222; |
|||
color: #aaa; |
|||
border-bottom-right-radius: 0.5em; |
|||
} |
|||
div.description p { |
|||
padding: 0; |
|||
margin: 0.25em 0; |
|||
} |
|||
</style> |
@ -0,0 +1,34 @@ |
|||
<script lang="ts"> |
|||
import type Item from "../models/item"; |
|||
import Icon from "./Icon.svelte"; |
|||
|
|||
export let item: Item = null; |
|||
</script> |
|||
|
|||
<div class="item"> |
|||
<div class="item-icon"> |
|||
<Icon name={item.icon} /> |
|||
</div> |
|||
<div class="item-name"> |
|||
<a href="/items#{item.groupId}">{item.name} ({item.groupWeight})</a> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
div.item { |
|||
display: flex; |
|||
flex-direction: row; |
|||
margin-top: 0.25em; |
|||
margin-bottom: 0em; |
|||
font-size: 0.75em; |
|||
} |
|||
div.item a { |
|||
color: inherit; |
|||
} |
|||
div.item div.item-icon { |
|||
padding: 0.25em 0.5ch 0.25em 0; |
|||
} |
|||
div.item div.item-name { |
|||
padding: 0.125em; |
|||
} |
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue