|
@ -1,38 +1,47 @@ |
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import type { IconName } from "../external/icons"; |
|
|
|
|
|
import type { GoalResult } from "../models/goal"; |
|
|
import type { GoalResult } from "../models/goal"; |
|
|
import type { ModalData } from "../stores/modal"; |
|
|
import type { ModalData } from "../stores/modal"; |
|
|
import DaysLeft from "./DaysLeft.svelte"; |
|
|
|
|
|
import Icon from "./Icon.svelte"; |
|
|
|
|
|
import Option from "./Option.svelte"; |
|
|
import Option from "./Option.svelte"; |
|
|
import OptionRow from "./OptionRow.svelte"; |
|
|
import OptionRow from "./OptionRow.svelte"; |
|
|
|
|
|
import ParentEntry from "./ParentEntry.svelte"; |
|
|
import Progress from "./Progress.svelte"; |
|
|
import Progress from "./Progress.svelte"; |
|
|
|
|
|
|
|
|
export let goal: GoalResult = null; |
|
|
export let goal: GoalResult = null; |
|
|
export let showAllOptions = false; |
|
|
export let showAllOptions = false; |
|
|
|
|
|
export let linkGoal = false; |
|
|
|
|
|
|
|
|
let iconName: IconName = "question"; |
|
|
|
|
|
let mdGoalEdit: ModalData; |
|
|
let mdGoalEdit: ModalData; |
|
|
let mdGoalDelete: ModalData; |
|
|
let mdGoalDelete: ModalData; |
|
|
|
|
|
let msLength: number; |
|
|
|
|
|
let msElapsed: number; |
|
|
|
|
|
|
|
|
$: iconName = goal.group.icon as IconName; |
|
|
|
|
|
$: mdGoalEdit = {name:"goal.edit", goal}; |
|
|
$: mdGoalEdit = {name:"goal.edit", goal}; |
|
|
$: mdGoalDelete = {name:"goal.delete", goal}; |
|
|
$: mdGoalDelete = {name:"goal.delete", goal}; |
|
|
|
|
|
|
|
|
|
|
|
$: { |
|
|
|
|
|
const now = Date.now() |
|
|
|
|
|
const start = Date.parse(goal.startTime) |
|
|
|
|
|
const length = Date.parse(goal.endTime) - start; |
|
|
|
|
|
|
|
|
|
|
|
msLength = length; |
|
|
|
|
|
msElapsed = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (now > start) { |
|
|
|
|
|
if (now > start + length) { |
|
|
|
|
|
msElapsed = length; |
|
|
|
|
|
} else { |
|
|
|
|
|
msElapsed = Math.round(now - start); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<div class="goal" class:full={showAllOptions}> |
|
|
|
|
|
<div class="icon"><Icon block name={iconName} /></div> |
|
|
|
|
|
<div class="body"> |
|
|
|
|
|
<div class="header"> |
|
|
|
|
|
<div class="name">{goal.name}</div> |
|
|
|
|
|
<div class="times"> |
|
|
|
|
|
<DaysLeft startTime={goal.startTime} endTime={goal.endTime} /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<ParentEntry |
|
|
|
|
|
full={showAllOptions} |
|
|
|
|
|
entry={goal} |
|
|
|
|
|
headerLink={linkGoal ? "/goals#"+goal.id : ""} |
|
|
|
|
|
> |
|
|
{#if showAllOptions} |
|
|
{#if showAllOptions} |
|
|
<div class="description"> |
|
|
|
|
|
<p>{goal.description}</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
<OptionRow> |
|
|
<OptionRow> |
|
|
<Option open={mdGoalEdit}>Edit</Option> |
|
|
<Option open={mdGoalEdit}>Edit</Option> |
|
|
<Option open={mdGoalDelete}>Delete</Option> |
|
|
<Option open={mdGoalDelete}>Delete</Option> |
|
@ -40,54 +49,12 @@ |
|
|
{/if} |
|
|
{/if} |
|
|
<div class="progress"> |
|
|
<div class="progress"> |
|
|
<Progress count={goal.completedAmount} target={goal.amount} /> |
|
|
<Progress count={goal.completedAmount} target={goal.amount} /> |
|
|
|
|
|
<Progress thinner gray count={msElapsed} target={msLength} /> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ParentEntry> |
|
|
<style> |
|
|
<style> |
|
|
div.goal { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
flex-direction: row; |
|
|
|
|
|
padding-bottom: 0.5em; |
|
|
|
|
|
} |
|
|
|
|
|
div.goal.full { |
|
|
|
|
|
padding-bottom: 1em; |
|
|
|
|
|
} |
|
|
|
|
|
div.icon { |
|
|
|
|
|
font-size: 2em; |
|
|
|
|
|
padding: 0 0.5ch; |
|
|
|
|
|
width: 2ch; |
|
|
|
|
|
padding-top: 0.125em; |
|
|
|
|
|
color: #333; |
|
|
|
|
|
} |
|
|
|
|
|
div.body { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
flex-direction: column; |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
} |
|
|
|
|
|
div.header { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
flex-direction: row; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
div.name { |
|
|
|
|
|
font-size: 1em; |
|
|
|
|
|
margin: auto 0; |
|
|
|
|
|
vertical-align: middle; |
|
|
|
|
|
font-weight: 100; |
|
|
|
|
|
} |
|
|
|
|
|
div.times { |
|
|
|
|
|
margin-left: auto; |
|
|
|
|
|
margin-right: 0.25ch; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
div.progress { |
|
|
div.progress { |
|
|
padding-top: 0.125em; |
|
|
padding-top: 0.125em; |
|
|
font-size: 1.25em; |
|
|
font-size: 1.25em; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
div.description > p { |
|
|
|
|
|
padding: 0; |
|
|
|
|
|
margin: 0.25em 0; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|
</style> |