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.

171 lines
3.8 KiB

3 years ago
3 years ago
  1. <script lang="ts">
  2. import type { IconName, iconNames } from "../external/icons";
  3. import { formatTime } from "../utils/time";
  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. interface ActualParent {
  9. id: string
  10. groupId: string
  11. name: string
  12. }
  13. interface EntryCommon {
  14. id: string
  15. name?: string
  16. description: string
  17. icon?: IconName
  18. startTime?: string
  19. endTime?: string
  20. createdTime?: string
  21. loggedTime?: string
  22. active?: boolean
  23. completedAmount?: number
  24. itemAmount?: number
  25. task?: EntryCommonSub
  26. }
  27. interface EntryCommonSub {
  28. id?: string
  29. groupId?: string
  30. name: string
  31. icon: IconName
  32. project?: EntryCommonSub
  33. tags?: string[]
  34. }
  35. export let entry: EntryCommon = null;
  36. export let actualParent: ActualParent = null;
  37. export let hideParentName: boolean = false;
  38. let iconName: IconName;
  39. let displayName: string;
  40. let displayTime: string;
  41. $: iconName = entry.task?.icon || entry.icon;
  42. $: displayName = entry.name || entry.task?.name || "";
  43. $: displayTime = entry.loggedTime ? formatTime(entry.loggedTime) : "";
  44. </script>
  45. <div class="child-entry">
  46. <LinkHook id={entry.id} />
  47. <div class="body">
  48. <div class="header">
  49. <slot name="icon">
  50. <div class="icon">
  51. <Icon name={iconName} />
  52. </div>
  53. </slot>
  54. {#if (actualParent != null)}
  55. {#if !hideParentName}
  56. <div class="actual-parent-icon">
  57. <Icon block name="link" />
  58. </div>
  59. <div class="actual-parent">
  60. <a href={`/questlog/${actualParent.groupId}/${actualParent.id}`}>{actualParent.name}</a>
  61. </div>
  62. {/if}
  63. {:else if (entry.task && entry.task.project != null)}
  64. <div class="actual-parent">
  65. <a href={`/questlog/${entry.task.project.groupId}/${entry.task.project.id}`}>{entry.task.project.name}</a>
  66. </div>
  67. {/if}
  68. <div class="name">{displayName}</div>
  69. <div class="separator"></div>
  70. {#if (entry.endTime != null)}
  71. <div class="times">
  72. <DaysLeft startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
  73. </div>
  74. {/if}
  75. {#if (displayTime != null)}
  76. <div class="times">
  77. {displayTime}
  78. </div>
  79. {/if}
  80. </div>
  81. <div class="entry-body">
  82. <Markdown source={entry.description} />
  83. <slot></slot>
  84. </div>
  85. </div>
  86. </div>
  87. <style>
  88. div.child-entry {
  89. display: flex;
  90. flex-direction: row;
  91. margin: 0.25em 0 0.75em 0;
  92. }
  93. div.icon, div.child-entry div.header :global(div.icon-like) {
  94. display: flex;
  95. flex-direction: column;
  96. font-size: 1em;
  97. padding: 0.2em .5ch;
  98. margin-right: 0.5em;
  99. background: #444;
  100. color: #CCC;
  101. }
  102. div.body {
  103. display: flex;
  104. flex-direction: column;
  105. width: 100%;
  106. }
  107. div.header {
  108. display: flex;
  109. flex-direction: row;
  110. background: #333;
  111. }
  112. div.actual-parent-icon {
  113. display: flex;
  114. flex-direction: column;
  115. font-size: 1em;
  116. padding: 0.3em 0;
  117. padding-bottom: 0.1em;
  118. margin-right: 0.5em;
  119. color: #555;
  120. }
  121. div.actual-parent {
  122. font-size: 1em;
  123. font-weight: 100;
  124. margin: auto 0;
  125. vertical-align: middle;
  126. padding: 0.125em 0;
  127. padding-right: 1ch;
  128. display: flex;
  129. flex-direction: row;
  130. }
  131. div.actual-parent :global(div.icon) {
  132. display: none !important;
  133. }
  134. div.name {
  135. font-size: 1em;
  136. font-weight: 100;
  137. margin: auto 0;
  138. vertical-align: middle;
  139. padding: 0.125em .5ch;
  140. }
  141. div.times {
  142. margin-right: 0.25ch;
  143. padding: 0.125em 0;
  144. }
  145. div.separator {
  146. margin-left: auto;
  147. }
  148. div.entry-body {
  149. padding: 0.25em 1ch;
  150. background: #222;
  151. color: #aaa;
  152. border-bottom-right-radius: 0.5em;
  153. }
  154. </style>