index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div v-if="isExternal" :style="styleExternalIcon" class="svg-external-icon svg-icon" v-on="$listeners" />
  3. <!-- <svg v-else :class="svgClass" aria-hidden="true" v-on="$listeners">
  4. <use :xlink:href="iconName" />
  5. </svg> -->
  6. <img v-else :class="svgClass" src="../../public/logo.png" alt="" v-on="$listeners">
  7. </template>
  8. <script>
  9. import { isExternal } from '@/utils/validate'
  10. export default {
  11. name: 'VabRemixIcon',
  12. props: {
  13. iconClass: {
  14. type: String,
  15. required: true,
  16. },
  17. className: {
  18. type: String,
  19. default: '',
  20. },
  21. },
  22. computed: {
  23. isExternal() {
  24. return isExternal(this.iconClass)
  25. },
  26. iconName() {
  27. return `#remix-icon-${this.iconClass}`
  28. },
  29. svgClass() {
  30. if (this.className) {
  31. return 'svg-icon ' + this.className
  32. } else {
  33. return 'svg-icon'
  34. }
  35. },
  36. styleExternalIcon() {
  37. return {
  38. mask: `url(${this.iconClass}) no-repeat 50% 50%`,
  39. '-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%`,
  40. }
  41. },
  42. },
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .svg-icon {
  47. width: 1.125em;
  48. height: 1.125em;
  49. overflow: hidden;
  50. fill: currentColor;
  51. &:hover {
  52. opacity: 0.8;
  53. }
  54. }
  55. .svg-external-icon {
  56. display: inline-block;
  57. background-color: currentColor;
  58. mask-size: cover !important;
  59. }
  60. </style>