DivBtn.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div ref="btn" class="clickable row justify-center items-center">
  3. <q-icon :name="icon" :size="`${iconSize}px`" />
  4. <slot></slot>
  5. </div>
  6. </template>
  7. <script>
  8. //-----------------------------------------------------------------------------
  9. import vueComponent from '../vueComponent.js';
  10. //import * as utils from '../../share/utils';
  11. const componentOptions = {
  12. watch: {
  13. size() {
  14. this.updateSizes();
  15. },
  16. }
  17. };
  18. class DivBtn {
  19. _options = componentOptions;
  20. _props = {
  21. size: { type: Number, default: 24 },
  22. icon: { type: String, default: '' },
  23. iconSize: { type: Number, default: 14 },
  24. round: { type: Boolean },
  25. };
  26. created() {
  27. }
  28. mounted() {
  29. this.updateSizes();
  30. }
  31. updateSizes() {
  32. this.$refs.btn.style.width = `${this.size}px`;
  33. this.$refs.btn.style.height = `${this.size}px`;
  34. if (this.round)
  35. this.$refs.btn.style.borderRadius = `${this.size}px`;
  36. }
  37. }
  38. export default vueComponent(DivBtn);
  39. //-----------------------------------------------------------------------------
  40. </script>
  41. <style scoped>
  42. .clickable-icon {
  43. cursor: pointer;
  44. }
  45. </style>