swatch.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div
  3. class="color"
  4. :data-color="color"
  5. :class="{ active: active }"
  6. v-tooltip="{ content: name || color }"
  7. :style="{ backgroundColor: color }"
  8. >
  9. <i v-if="active" class="material-icons activeTick">done</i>
  10. </div>
  11. </template>
  12. <style scoped lang="scss">
  13. .color {
  14. @apply inline-flex;
  15. @apply items-center;
  16. @apply justify-center;
  17. @apply relative;
  18. @apply m-2;
  19. @apply p-4;
  20. @apply rounded-full;
  21. @apply border-2;
  22. @apply border-bgDarkColor;
  23. @apply cursor-pointer;
  24. @apply transition;
  25. @apply ease-in-out;
  26. @apply duration-200;
  27. &.fg {
  28. @apply text-actColor;
  29. }
  30. &.active {
  31. @apply border-2;
  32. @apply border-acColor;
  33. }
  34. &.fg.active {
  35. @apply border-2;
  36. @apply border-fgColor;
  37. }
  38. .activeTick {
  39. @apply absolute;
  40. @apply m-auto;
  41. @apply inset-0;
  42. }
  43. }
  44. </style>
  45. <script>
  46. export default {
  47. props: {
  48. color: {
  49. type: String,
  50. required: true,
  51. },
  52. name: {
  53. type: String,
  54. },
  55. active: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. },
  60. }
  61. </script>