ButtonGroup.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="button-group" :class="{ 'passive': passive }" ref="groupRef">
  3. <slot></slot>
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. withDefaults(defineProps<{
  8. passive?: boolean
  9. }>(), {
  10. passive: false,
  11. })
  12. </script>
  13. <style lang="scss" scoped>
  14. .button-group {
  15. display: flex;
  16. align-items: center;
  17. ::v-deep(button.button) {
  18. border-radius: 0;
  19. border-left-width: 1px;
  20. border-right-width: 0;
  21. display: inline-block;
  22. }
  23. &:not(.passive) {
  24. ::v-deep(button.button) {
  25. &:not(:last-child, .radio, .checkbox):hover {
  26. position: relative;
  27. &::after {
  28. content: '';
  29. width: 1px;
  30. height: calc(100% + 2px);
  31. background-color: $themeColor;
  32. position: absolute;
  33. top: -1px;
  34. right: -1px;
  35. }
  36. }
  37. &:first-child {
  38. border-top-left-radius: $borderRadius;
  39. border-bottom-left-radius: $borderRadius;
  40. border-left-width: 1px;
  41. }
  42. &:last-child {
  43. border-top-right-radius: $borderRadius;
  44. border-bottom-right-radius: $borderRadius;
  45. border-right-width: 1px;
  46. }
  47. }
  48. }
  49. &.passive {
  50. ::v-deep(button.button) {
  51. &:not(.last, .radio, .checkbox):hover {
  52. position: relative;
  53. &::after {
  54. content: '';
  55. width: 1px;
  56. height: calc(100% + 2px);
  57. background-color: $themeColor;
  58. position: absolute;
  59. top: -1px;
  60. right: -1px;
  61. }
  62. }
  63. &.first {
  64. border-top-left-radius: $borderRadius;
  65. border-bottom-left-radius: $borderRadius;
  66. border-left-width: 1px;
  67. }
  68. &.last {
  69. border-top-right-radius: $borderRadius;
  70. border-bottom-right-radius: $borderRadius;
  71. border-right-width: 1px;
  72. }
  73. }
  74. }
  75. }
  76. </style>