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.

114 lines
2.2 KiB

2 years ago
  1. <template>
  2. <div class="tw-flex tw-flex-col">
  3. <label class="tw-body-4 container-checkbox" :for="input.id">
  4. {{ $t(input.label) }}
  5. <input :id="input.id" type="checkbox" :value="value" v-model="inputVal" />
  6. <span class="checkmark"></span>
  7. </label>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: "ElementCheckBox",
  13. props: {
  14. input: {
  15. type: Object,
  16. },
  17. default: {
  18. type: String,
  19. },
  20. },
  21. data() {
  22. return {
  23. value: null,
  24. };
  25. },
  26. mounted() { },
  27. watch: {
  28. default: {
  29. handler: function () {
  30. this.value = this.default;
  31. },
  32. },
  33. },
  34. computed: {
  35. inputVal: {
  36. get() {
  37. return this.value;
  38. },
  39. set(val) {
  40. this.value = val;
  41. this.$emit("update", val);
  42. },
  43. },
  44. },
  45. };
  46. </script>
  47. <style lang="scss" scoped>
  48. /* The container */
  49. .container-checkbox {
  50. display: block;
  51. position: relative;
  52. padding-left: 37px;
  53. cursor: pointer;
  54. -webkit-user-select: none;
  55. -moz-user-select: none;
  56. -ms-user-select: none;
  57. user-select: none;
  58. }
  59. /* Hide the browser's default checkbox */
  60. .container-checkbox input {
  61. position: absolute;
  62. opacity: 0;
  63. cursor: pointer;
  64. }
  65. /* Create a custom checkbox */
  66. .container-checkbox .checkmark {
  67. position: absolute;
  68. top: 0;
  69. left: 0;
  70. height: 18px;
  71. width: 18px;
  72. background-color: transparent;
  73. border: 1px solid #f48800;
  74. border-radius: 4px;
  75. }
  76. /* On mouse-over, add a grey background color */
  77. .container-checkbox:hover input~.checkmark {
  78. border-color: #f48800;
  79. }
  80. /* When the checkbox is checked, add a blue background */
  81. .container-checkbox input:checked~.checkmark {
  82. background-color: #f48800;
  83. border-color: #f48800;
  84. }
  85. /* Create the checkmark/indicator (hidden when not checked) */
  86. .container-checkbox .checkmark:after {
  87. content: "";
  88. position: absolute;
  89. display: none;
  90. }
  91. /* Show the checkmark when checked */
  92. .container-checkbox input:checked~.checkmark:after {
  93. display: block;
  94. }
  95. /* Style the checkmark/indicator */
  96. .container-checkbox .checkmark:after {
  97. left: 5px;
  98. top: 2px;
  99. width: 5px;
  100. height: 10px;
  101. border: solid #ffffff;
  102. border-width: 0 2px 2px 0;
  103. -webkit-transform: rotate(45deg);
  104. -ms-transform: rotate(45deg);
  105. transform: rotate(45deg);
  106. }
  107. </style>