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.

82 lines
1.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <script lang="ts">
  2. import { commonIcons, uncommonIcons } from "../external/icons";
  3. import type { IconName } from "../external/icons";
  4. import Icon from "./Icon.svelte";
  5. export let value: IconName;
  6. export let disabled: boolean;
  7. let showAll = !commonIcons.includes(value);
  8. function toggleShowAll() {
  9. showAll = !showAll;
  10. }
  11. </script>
  12. <div class:disabled class="icon-select">
  13. {#each commonIcons as iconName (iconName)}
  14. <div class="icon-item" class:selected={value===iconName} on:click={() => {if (!disabled) { value = iconName }}}>
  15. <Icon name={iconName} />
  16. </div>
  17. {/each}
  18. <div class="show-all" on:click={toggleShowAll}>
  19. { showAll ? "Hide uncommon icons" : "Show uncommon icons" }
  20. </div>
  21. {#if showAll}
  22. {#each uncommonIcons as iconName (iconName)}
  23. <div class="icon-item" class:selected={value===iconName} on:click={() => {if (!disabled) { value = iconName }}}>
  24. <Icon name={iconName} />
  25. </div>
  26. {/each}
  27. {/if}
  28. </div>
  29. <style>
  30. div.icon-select {
  31. background: #222;
  32. margin: 0;
  33. padding: 0;
  34. border-radius: 0.05em;
  35. margin-bottom: 0.5em;
  36. }
  37. div.icon-select.disabled {
  38. background: #444;
  39. }
  40. div.icon-item {
  41. display: inline-block;
  42. box-sizing: border-box;
  43. width: calc(100% / 8);
  44. padding: 0.35em 0 0.25em 0;
  45. text-align: center;
  46. cursor: pointer;
  47. }
  48. div.icon-item:hover {
  49. background-color: #292929;
  50. }
  51. div.icon-item.selected {
  52. background-color: rgb(18, 63, 75);
  53. }
  54. div.icon-item.selected:hover {
  55. background-color: rgb(24, 83, 99);
  56. }
  57. div.icon-select.disabled > div.icon-item {
  58. background-color: #444;
  59. cursor: default;
  60. }
  61. div.icon-select.disabled > div.icon-item.selected {
  62. background-color: #555;
  63. }
  64. div.show-all {
  65. color: #777;
  66. cursor: pointer;
  67. text-align: center;
  68. padding: 0.25em 0;
  69. }
  70. div.show-all:hover {
  71. color: #ccc;
  72. background-color: #2c2c2c;
  73. }
  74. </style>