refactored ProjectEntry and GroupEntry to share common style.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -18,10 +18,12 @@ body {
|
|||||||
a {
|
a {
|
||||||
color: #FC1;
|
color: #FC1;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
text-decoration-color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
text-decoration-color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
|||||||
@@ -1,96 +1,35 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
|
||||||
import type { IconName } from "../external/icons";
|
|
||||||
import type { GroupResult } from "../models/group";
|
import type { GroupResult } from "../models/group";
|
||||||
import type { ModalData } from "../stores/modal";
|
import type { ModalData } from "../stores/modal";
|
||||||
import Icon from "./Icon.svelte";
|
|
||||||
import ItemEntry from "./ItemEntry.svelte";
|
import ItemEntry from "./ItemEntry.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";
|
||||||
|
|
||||||
export let group: GroupResult = null;
|
export let group: GroupResult = null;
|
||||||
export let showAllOptions: boolean = false;
|
export let showAllOptions: boolean = false;
|
||||||
|
|
||||||
let iconName: IconName = "question";
|
|
||||||
let mdItemAdd: ModalData;
|
let mdItemAdd: ModalData;
|
||||||
let mdGroupEdit: ModalData;
|
let mdGroupEdit: ModalData;
|
||||||
let mdGroupDelete: ModalData;
|
let mdGroupDelete: ModalData;
|
||||||
let linkHook: HTMLElement;
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (window.location.hash === "#" + group.id) {
|
|
||||||
window.scrollTo({top: linkHook.getBoundingClientRect().top});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$: iconName = group.icon as IconName;
|
|
||||||
$: mdItemAdd = {name:"item.add", group};
|
$: mdItemAdd = {name:"item.add", group};
|
||||||
$: mdGroupEdit = {name:"group.edit", group};
|
$: mdGroupEdit = {name:"group.edit", group};
|
||||||
$: mdGroupDelete = {name:"group.delete", group};
|
$: mdGroupDelete = {name:"group.delete", group};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="group">
|
<ParentEntry
|
||||||
<div class="link-hook" id={group.id} bind:this={linkHook}></div>
|
full={showAllOptions}
|
||||||
<div class="icon"><Icon block name={iconName} /></div>
|
entry={group}
|
||||||
<div class="body">
|
>
|
||||||
<div class="header">
|
{#if showAllOptions}
|
||||||
<div class="name">{group.name}</div>
|
<OptionRow>
|
||||||
</div>
|
<Option open={mdItemAdd}>Add Item</Option>
|
||||||
{#if showAllOptions}
|
<Option open={mdGroupEdit}>Edit</Option>
|
||||||
<div class="description">
|
<Option open={mdGroupDelete}>Delete</Option>
|
||||||
<p>{group.description}</p>
|
</OptionRow>
|
||||||
</div>
|
{#each group.items as item (item.id)}
|
||||||
<OptionRow>
|
<ItemEntry item={item} group={group} />
|
||||||
<Option open={mdItemAdd}>Add Item</Option>
|
{/each}
|
||||||
<Option open={mdGroupEdit}>Edit</Option>
|
{/if}
|
||||||
<Option open={mdGroupDelete}>Delete</Option>
|
</ParentEntry>
|
||||||
</OptionRow>
|
|
||||||
{/if}
|
|
||||||
<div class="list" class:full={showAllOptions}>
|
|
||||||
{#each group.items as item (item.id)}
|
|
||||||
<ItemEntry item={item} group={group} />
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
div.link-hook {
|
|
||||||
position: relative;
|
|
||||||
top: -2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.group {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
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;
|
|
||||||
font-weight: 100;
|
|
||||||
margin: auto 0;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.description > p {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0.25em 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
|
export let id = "";
|
||||||
|
|
||||||
|
let linkHook: HTMLElement;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (window.location.hash === "#" + id) {
|
||||||
|
window.scrollTo({top: linkHook.getBoundingClientRect().top});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="link-hook" id={id} bind:this={linkHook}></div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div.link-hook {
|
||||||
|
position: relative;
|
||||||
|
top: -2em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { IconName } from "../external/icons";
|
||||||
|
import DaysLeft from "./DaysLeft.svelte";
|
||||||
|
import Icon from "./Icon.svelte";
|
||||||
|
import LinkHook from "./LinkHook.svelte";
|
||||||
|
import Progress from "./Progress.svelte";
|
||||||
|
|
||||||
|
interface EntryIconHolder {
|
||||||
|
icon: IconName
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EntryCommon {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
icon?: IconName
|
||||||
|
startTime?: string
|
||||||
|
endTime?: string
|
||||||
|
createdTime?: string
|
||||||
|
group?: EntryIconHolder
|
||||||
|
project?: EntryIconHolder
|
||||||
|
}
|
||||||
|
|
||||||
|
export let entry: EntryCommon;
|
||||||
|
export let full = false;
|
||||||
|
export let headerLink = "";
|
||||||
|
|
||||||
|
export let progressAmount: number = null;
|
||||||
|
export let progressTarget: number = null;
|
||||||
|
|
||||||
|
let iconName: IconName;
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (entry.project != null) {
|
||||||
|
iconName = entry.project.icon;
|
||||||
|
} else if (entry.group != null) {
|
||||||
|
iconName = entry.group.icon;
|
||||||
|
} else {
|
||||||
|
iconName = entry.icon || "question";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="parent-entry" class:full={full}>
|
||||||
|
<LinkHook id={entry.id} />
|
||||||
|
<div class="icon"><Icon block name={iconName} /></div>
|
||||||
|
<div class="body">
|
||||||
|
<div class="header">
|
||||||
|
<div class="name">
|
||||||
|
{#if headerLink}
|
||||||
|
<a href={headerLink}>{entry.name}</a>
|
||||||
|
{:else}
|
||||||
|
{entry.name}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{#if entry.endTime != null}
|
||||||
|
<div class="days-left">
|
||||||
|
<DaysLeft startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{#if (progressAmount != null)}
|
||||||
|
<Progress thin green count={progressAmount} target={progressTarget} />
|
||||||
|
{/if}
|
||||||
|
{#if (full)}
|
||||||
|
<div class="description">
|
||||||
|
<p>{entry.description}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div.parent-entry {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div.parent-entry.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.days-left {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 0.25ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration-color: #777;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.description > p {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0.25em 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
|
||||||
import type { ProjectResult } from "../models/project";
|
import type { ProjectResult } from "../models/project";
|
||||||
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 Progress from "./Progress.svelte";
|
import ParentEntry from "./ParentEntry.svelte";
|
||||||
import TaskEntry from "./TaskEntry.svelte";
|
import TaskEntry from "./TaskEntry.svelte";
|
||||||
|
|
||||||
export let project: ProjectResult = null;
|
export let project: ProjectResult = null;
|
||||||
@@ -19,13 +16,6 @@
|
|||||||
let mdProjectDelete: ModalData;
|
let mdProjectDelete: ModalData;
|
||||||
let progressAmount: number;
|
let progressAmount: number;
|
||||||
let progressTarget: number;
|
let progressTarget: number;
|
||||||
let linkHook: HTMLElement;
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (window.location.hash === "#" + project.id) {
|
|
||||||
window.scrollTo({top: linkHook.getBoundingClientRect().top});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$: mdAddTask = {name:"task.add", project};
|
$: mdAddTask = {name:"task.add", project};
|
||||||
$: mdProjectEdit = {name:"project.edit", project};
|
$: mdProjectEdit = {name:"project.edit", project};
|
||||||
@@ -37,101 +27,23 @@
|
|||||||
$: progressTarget = Math.max(project.tasks.map(t => t.itemAmount * t.item.groupWeight).reduce((n,m) => n+m, 0), 1);
|
$: progressTarget = Math.max(project.tasks.map(t => t.itemAmount * t.item.groupWeight).reduce((n,m) => n+m, 0), 1);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="project">
|
<ParentEntry
|
||||||
<div class="link-hook" id={project.id} bind:this={linkHook}></div>
|
full={showAllOptions}
|
||||||
<div class="icon" class:inactive={!project.active}><Icon block name={project.icon} /></div>
|
entry={project}
|
||||||
<div class="body">
|
headerLink={linkProject ? "/projects#"+project.id : ""}
|
||||||
<div class="header">
|
progressAmount={progressAmount}
|
||||||
<div class="name">
|
progressTarget={progressTarget}
|
||||||
{#if linkProject}
|
>
|
||||||
<a href="/projects#{project.id}">{project.name}</a>
|
{#if showAllOptions}
|
||||||
{:else}
|
<OptionRow>
|
||||||
{project.name}
|
<Option open={mdAddTask}>Add Task</Option>
|
||||||
{/if}
|
<Option open={mdProjectEdit}>Edit</Option>
|
||||||
</div>
|
<Option open={mdProjectDelete}>Delete</Option>
|
||||||
{#if (project.endTime != null)}
|
</OptionRow>
|
||||||
<div class="times">
|
{/if}
|
||||||
<DaysLeft startTime={project.createdTime} endTime={project.endTime} />
|
{#each project.tasks as task (task.id)}
|
||||||
</div>
|
{#if !hideInactive || task.active}
|
||||||
{/if}
|
<TaskEntry showAllOptions={showAllOptions} task={task} project={project} />
|
||||||
</div>
|
|
||||||
<Progress thin green count={progressAmount} target={progressTarget} />
|
|
||||||
{#if showAllOptions}
|
|
||||||
<div class="description">
|
|
||||||
<p>{project.description}</p>
|
|
||||||
</div>
|
|
||||||
<OptionRow>
|
|
||||||
<Option open={mdAddTask}>Add Task</Option>
|
|
||||||
<Option open={mdProjectEdit}>Edit</Option>
|
|
||||||
<Option open={mdProjectDelete}>Delete</Option>
|
|
||||||
</OptionRow>
|
|
||||||
{/if}
|
{/if}
|
||||||
<div class="list" class:full={showAllOptions}>
|
{/each}
|
||||||
{#each project.tasks as task (task.id)}
|
</ParentEntry>
|
||||||
{#if !hideInactive || task.active}
|
|
||||||
<TaskEntry showAllOptions={showAllOptions} task={task} project={project} />
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
div.link-hook {
|
|
||||||
position: relative;
|
|
||||||
top: -2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.project {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
padding-bottom: 1em;
|
|
||||||
}
|
|
||||||
div.icon {
|
|
||||||
font-size: 2em;
|
|
||||||
padding: 0 0.5ch;
|
|
||||||
width: 2ch;
|
|
||||||
padding-top: 0.125em;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
div.icon.inactive {
|
|
||||||
color: #484;
|
|
||||||
}
|
|
||||||
div.body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
div.header {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.name {
|
|
||||||
font-size: 1em;
|
|
||||||
font-weight: 100;
|
|
||||||
margin: auto 0;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
div.name a {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
div.times {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: 0.25ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.description > p {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0.25em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 550px) {
|
|
||||||
div.icon {
|
|
||||||
color: #777;
|
|
||||||
}
|
|
||||||
div.icon.inactive {
|
|
||||||
color: #78ff78;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Reference in New Issue
Block a user