wscn-icon-stack.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div class="icon-container" :style="containerStyle">
  3. <slot class="icon"></slot>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'wscn-icon-stack',
  9. props: {
  10. width: {
  11. type: Number,
  12. default: 20
  13. },
  14. shape: {
  15. type: String,
  16. default: 'circle',
  17. validator: val => {
  18. const validShapes = ['circle', 'square']
  19. return validShapes.indexOf(val) > -1
  20. }
  21. }
  22. },
  23. computed: {
  24. containerStyle() {
  25. return {
  26. width: `${this.width}px`,
  27. height: `${this.width}px`,
  28. fontSize: `${this.width * 0.6}px`,
  29. borderRadius: `${this.shape === 'circle' && '50%'}`
  30. }
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. .icon-container {
  37. display: inline-block;
  38. position: relative;
  39. overflow: hidden;
  40. background: #1482F0;
  41. .icon {
  42. position: absolute;
  43. color: #ffffff;
  44. top: 50%;
  45. left: 50%;
  46. transform: translate(-50%, -50%);
  47. }
  48. }
  49. </style>