|
1 | 1 | <template>
|
2 |
| - <div class="relative inline-block items-start justify-between"> |
| 2 | + <div |
| 3 | + class="relative inline-block items-start justify-between" |
| 4 | + :class="{'leading-none': displayAsEllipsis}" |
| 5 | + > |
3 | 6 | <Menu as="div">
|
4 |
| - <div> |
5 |
| - <MenuButton |
6 |
| - class="hover:bg-gray-50 inline-flex w-full justify-center gap-x-1.5 rounded" |
7 |
| - :class=" |
8 |
| - displayAsEllipsis |
9 |
| - ? 'text-3xl-normal' |
10 |
| - : 'border border-light bg-secondary px-3 py-2 text-lg-normal' |
11 |
| - " |
12 |
| - :aria-label="ariaLabel || null" |
13 |
| - > |
14 |
| - <span v-if="!displayAsEllipsis">{{ label }}</span> |
15 |
| - <Icon |
16 |
| - v-if="!displayAsEllipsis" |
17 |
| - class="h-5 w-5 text-primary" |
18 |
| - icon="Dropdown" |
19 |
| - aria-hidden="true" |
20 |
| - /> |
21 |
| - <ButtonIcon |
22 |
| - v-else |
23 |
| - icon="MoreOptions" |
24 |
| - :aria-label="label" |
25 |
| - ></ButtonIcon> |
26 |
| - </MenuButton> |
27 |
| - </div> |
| 7 | + <MenuButton |
| 8 | + :class="menuButtonStyle" |
| 9 | + :aria-label="displayAsEllipsis ? label : ariaLabel" |
| 10 | + > |
| 11 | + <span v-if="!displayAsEllipsis">{{ label }}</span> |
| 12 | + <Icon |
| 13 | + v-if="!displayAsEllipsis" |
| 14 | + class="h-5 w-5 text-primary" |
| 15 | + icon="Dropdown" |
| 16 | + aria-hidden="true" |
| 17 | + /> |
| 18 | + <Icon v-else class="h-6 w-6" icon="MoreOptions" aria-hidden="true" /> |
| 19 | + </MenuButton> |
28 | 20 |
|
29 | 21 | <transition
|
30 | 22 | enter-active-class="transition ease-out duration-100"
|
|
80 | 72 | <script setup>
|
81 | 73 | import {Menu, MenuButton, MenuItem, MenuItems} from '@headlessui/vue';
|
82 | 74 | import PkpButton from '@/components/Button/Button.vue';
|
83 |
| -import ButtonIcon from '@/components/ButtonIcon/ButtonIcon.vue'; |
84 | 75 | import Icon from '@/components/Icon/Icon.vue';
|
| 76 | +import {computed} from 'vue'; |
85 | 77 |
|
86 |
| -defineProps({ |
| 78 | +const props = defineProps({ |
87 | 79 | /**
|
88 | 80 | * An array of action objects.
|
89 | 81 | * Each object should contain
|
@@ -140,6 +132,16 @@ const emitAction = (action) => {
|
140 | 132 | }
|
141 | 133 | };
|
142 | 134 |
|
| 135 | +const menuButtonStyle = computed(() => ({ |
| 136 | + // Base |
| 137 | + 'hover:bg-gray-50 w-full justify-center rounded': true, |
| 138 | + // Default |
| 139 | + 'inline-flex border border-light bg-secondary px-3 py-2 text-lg-normal gap-x-1.5': |
| 140 | + !props.displayAsEllipsis, |
| 141 | + // Ellipsis Menu |
| 142 | + 'leading-none hover:text-on-dark hover:bg-hover': props.displayAsEllipsis, |
| 143 | +})); |
| 144 | +
|
143 | 145 | const isValidAction = (action) => {
|
144 | 146 | return action?.label && (action?.url || action?.name);
|
145 | 147 | };
|
|
0 commit comments