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.

127 lines
2.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 ProjectProgress from "./ProjectProgress.svelte";
  9. import TimeProgress from "./TimeProgress.svelte";
  10. interface EntryIconHolder {
  11. icon: IconName
  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. group?: EntryIconHolder
  22. project?: EntryIconHolder
  23. tasks?: TaskResult[]
  24. active?: boolean
  25. }
  26. export let entry: EntryCommon;
  27. export let full = false;
  28. export let headerLink = "";
  29. export let hideProgress: boolean = false;
  30. export let hideIcon: boolean = false;
  31. export let showTimeProgress: boolean = false;
  32. let iconName: IconName;
  33. $: {
  34. if (entry.project != null) {
  35. iconName = entry.project.icon;
  36. } else if (entry.group != null) {
  37. iconName = entry.group.icon;
  38. } else {
  39. iconName = entry.icon || "question";
  40. }
  41. }
  42. </script>
  43. <div class="parent-entry" class:full={full}>
  44. <LinkHook id={entry.id} />
  45. {#if !hideIcon}
  46. <div class="icon" class:completed={entry.active === false}>
  47. <Icon block name={iconName} />
  48. </div>
  49. {/if}
  50. <div class="body">
  51. <div class="header">
  52. <div class="name">
  53. {#if headerLink}
  54. <a href={headerLink}>{entry.name}</a>
  55. {:else}
  56. {entry.name}
  57. {/if}
  58. </div>
  59. {#if entry.endTime != null}
  60. <div class="days-left">
  61. <DaysLeft startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
  62. </div>
  63. {/if}
  64. </div>
  65. {#if (!hideProgress && entry.tasks != null)}
  66. <ProjectProgress project={entry} />
  67. {#if showTimeProgress && entry.endTime}
  68. <TimeProgress startTime={entry.startTime || entry.createdTime} endTime={entry.endTime} />
  69. {/if}
  70. {/if}
  71. {#if (full)}
  72. <Markdown source={entry.description} />
  73. {/if}
  74. <slot></slot>
  75. </div>
  76. </div>
  77. <style>
  78. div.parent-entry {
  79. display: flex;
  80. flex-direction: row;
  81. padding-bottom: 0.5em;
  82. }
  83. div.parent-entry.full {
  84. padding-bottom: 1em;
  85. }
  86. div.icon {
  87. font-size: 2em;
  88. padding: 0 0.5ch;
  89. width: 2ch;
  90. padding-top: 0.125em;
  91. color: #333;
  92. }
  93. div.icon.completed {
  94. color: #484;
  95. }
  96. div.body {
  97. display: flex;
  98. flex-direction: column;
  99. width: 100%;
  100. }
  101. div.header {
  102. display: flex;
  103. flex-direction: row;
  104. }
  105. div.name {
  106. font-size: 1em;
  107. margin: auto 0;
  108. vertical-align: middle;
  109. font-weight: 100;
  110. }
  111. div.days-left {
  112. margin-left: auto;
  113. margin-right: 0.25ch;
  114. }
  115. a {
  116. color: inherit;
  117. text-decoration-color: #777;
  118. }
  119. </style>