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.

83 lines
1.9 KiB

4 years ago
  1. <script lang="ts">
  2. import type { IconName } from "../external/icons";
  3. import type { TaskResult } from "../models/task";
  4. import Icon from "./Icon.svelte";
  5. export let task: TaskResult;
  6. export let iconName: IconName;
  7. let showNumbersAnyway;
  8. let inactive;
  9. $: {
  10. switch (task.statusTag) {
  11. case "to do": iconName = "lightbulb"; break;
  12. case "on hold": iconName = "hourglass"; break;
  13. case "declined": iconName = "times"; break;
  14. case "failed": iconName = "times"; break;
  15. default: iconName = "check"; break;
  16. }
  17. }
  18. $: showNumbersAnyway = ["to do", "on hold"].includes(task.statusTag) && task.itemAmount > 1;
  19. $: inactive = !task.active || showNumbersAnyway;
  20. </script>
  21. <div class="icon sccsi" class:targetonly={showNumbersAnyway} class:inactive={inactive}>
  22. {#if !task.active || showNumbersAnyway}
  23. <span class="on">
  24. {#if showNumbersAnyway}
  25. {task.itemAmount}
  26. {:else}
  27. <Icon block name={iconName} />
  28. {/if}
  29. </span>
  30. <span class="off">
  31. {task.completedAmount}&nbsp;/&nbsp;{task.itemAmount}
  32. </span>
  33. {:else}
  34. {task.completedAmount}&nbsp;/&nbsp;{task.itemAmount}
  35. {/if}
  36. </div>
  37. <style>
  38. div.icon {
  39. display: flex;
  40. flex-direction: column;
  41. font-size: 1em;
  42. padding: 0.2em .5ch;
  43. margin-right: 0.5em;
  44. background: #444;
  45. color: #CCC;
  46. }
  47. div.icon.inactive {
  48. padding-top: 0.295em;
  49. padding-bottom: 0.115em;
  50. background: #484;
  51. color: #78ff78;
  52. }
  53. div.icon.targetonly {
  54. min-width: 1.5ch;
  55. text-align: center;
  56. padding-top: 0.205em;
  57. padding-bottom: 0.225em;
  58. }
  59. div.icon.targetonly span.on {
  60. font-weight: 800;
  61. }
  62. div.icon.inactive span.off {
  63. display: none;
  64. }
  65. div.icon.inactive:hover {
  66. padding-top: 0.16em;
  67. padding-bottom: 0.27em;
  68. }
  69. div.icon.inactive:hover span.on {
  70. display: none;
  71. }
  72. div.icon.inactive:hover span.off {
  73. display: inline;
  74. }
  75. </style>