You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
3.8 KiB

  1. <script lang="ts">
  2. import type { IconName } from "../external/icons";
  3. import type { TaskResult } from "../models/task";
  4. import DaysLeft from "./DaysLeft.svelte";
  5. import Icon from "./Icon.svelte";
  6. import LinkHook from "./LinkHook.svelte";
  7. import Markdown from "./Markdown.svelte";
  8. import ProjectIcon from "./ProjectIcon.svelte";
  9. import ProjectProgress from "./ProjectProgress.svelte";
  10. import Tag from "./Tag.svelte";
  11. import TimeProgress from "./TimeProgress.svelte";
  12. interface EntryIconHolder {
  13. icon: IconName
  14. }
  15. interface EntryCommon {
  16. id: string
  17. name: string
  18. description: string
  19. icon?: IconName
  20. startTime?: string
  21. endTime?: string
  22. createdTime?: string
  23. group?: EntryIconHolder
  24. project?: EntryIconHolder
  25. tasks?: TaskResult[]
  26. active?: boolean
  27. statusName?: string
  28. tags?: string[]
  29. }
  30. export let entry: EntryCommon;
  31. export let full = false;
  32. export let headerLink = "";
  33. export let hideProgress: boolean = false;
  34. export let hideIcon: boolean = false;
  35. export let showTimeProgress: boolean = false;
  36. export let annotations: IconName[] = [];
  37. export let removeHook: boolean = false;
  38. let iconName: IconName;
  39. $: {
  40. if (entry.project != null) {
  41. iconName = entry.project.icon;
  42. } else if (entry.group != null) {
  43. iconName = entry.group.icon;
  44. } else {
  45. iconName = entry.icon || "question";
  46. }
  47. }
  48. </script>
  49. <div class="parent-entry" class:full={full}>
  50. {#if !removeHook}
  51. <LinkHook id={entry.id} />
  52. {/if}
  53. {#if !hideIcon}
  54. <div class="icon" class:completed={entry.active === false}>
  55. {#if entry.active != null}
  56. <ProjectIcon project={entry} />
  57. {:else}
  58. <Icon block name={iconName} />
  59. {/if}
  60. </div>
  61. {/if}
  62. <div class="body">
  63. <div class="header">
  64. {#if entry.tags && entry.tags.length > 0}
  65. <Tag small value={entry.tags[0]} />
  66. {/if}
  67. <div class="name">
  68. {#if headerLink}
  69. <a href={headerLink}>{entry.name}</a>
  70. {:else}
  71. {entry.name}
  72. {/if}
  73. </div>
  74. <slot name="pre-annotation"></slot>
  75. {#each annotations as annotation (annotation)}
  76. <div class="annotation">
  77. <Icon block name={annotation} />
  78. </div>
  79. {/each}
  80. <div class="separator"></div>
  81. <slot name="post-seprator"></slot>
  82. {#if entry.endTime != null}
  83. <div class="days-left">
  84. <DaysLeft startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
  85. </div>
  86. {/if}
  87. </div>
  88. {#if (!hideProgress && entry.tasks != null)}
  89. <ProjectProgress project={entry} />
  90. {#if showTimeProgress && entry.endTime}
  91. <TimeProgress startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
  92. {/if}
  93. {/if}
  94. <slot name="above-description"></slot>
  95. {#if (full)}
  96. <Markdown source={entry.description} />
  97. {/if}
  98. <slot></slot>
  99. </div>
  100. </div>
  101. <style>
  102. div.parent-entry {
  103. display: flex;
  104. flex-direction: row;
  105. padding-bottom: 0.5em;
  106. }
  107. div.parent-entry.full {
  108. padding-bottom: 1em;
  109. }
  110. div.icon {
  111. font-size: 2em;
  112. padding: 0 0.5ch;
  113. width: 2ch;
  114. padding-top: 0.125em;
  115. color: #444;
  116. }
  117. div.icon.completed {
  118. color: #484;
  119. }
  120. div.body {
  121. display: flex;
  122. flex-direction: column;
  123. width: 100%;
  124. }
  125. div.header {
  126. display: flex;
  127. flex-direction: row;
  128. }
  129. div.name {
  130. font-size: 1em;
  131. margin: auto 0;
  132. vertical-align: middle;
  133. font-weight: 100;
  134. }
  135. div.annotation {
  136. margin: auto 0;
  137. padding: 0 0.5ch;
  138. line-height: 0em;
  139. color: #333;
  140. }
  141. div.annotation + div.annotation {
  142. padding-left: 0;
  143. }
  144. div.separator {
  145. margin-left: auto;
  146. }
  147. div.days-left {
  148. margin-right: 0.25ch;
  149. margin-left: 1ch;
  150. }
  151. a {
  152. color: inherit;
  153. text-decoration-color: #777;
  154. }
  155. </style>