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.

64 lines
1.2 KiB

  1. <script lang="ts">
  2. import Icon from "./Icon.svelte";
  3. export let checked = false;
  4. export let centered = false;
  5. export let disabled = false;
  6. export let label = "(Missing label property)";
  7. function handleClick() {
  8. if (!disabled) {
  9. checked = !checked;
  10. }
  11. }
  12. </script>
  13. <div class="checkbox" class:centered on:click={handleClick}>
  14. <div class="box" class:disabled class:checked class:unchecked={!checked}>
  15. <Icon name="check" />
  16. </div>
  17. <div class="label">{label}</div>
  18. </div>
  19. <style>
  20. div.checkbox {
  21. display: flex;
  22. flex-direction: row;
  23. flex-shrink: 0;
  24. margin-top: 0.5em;
  25. margin-bottom: 1em;
  26. -webkit-user-select: none;
  27. -moz-user-select: none;
  28. }
  29. div.checkbox.centered {
  30. margin: auto
  31. }
  32. div.box {
  33. border: 0.5px solid;
  34. padding: 0.025em 0.5ch;
  35. padding-top: 0.25em;
  36. background-color: #111;
  37. color: #555;
  38. font-size: 1.25em;
  39. }
  40. div.box.checked {
  41. color: #fC1;
  42. background-color: #5c4d20;
  43. }
  44. div.box.disabled {
  45. color: #777;
  46. background-color: #444;
  47. }
  48. div.box.unchecked :global(*) {
  49. opacity: 0;
  50. }
  51. div.label {
  52. margin: auto 0;
  53. margin-left: 1ch;
  54. -webkit-user-select: none;
  55. -moz-user-select: none;
  56. }
  57. </style>