Skip to content

Commit aee3e32

Browse files
committed
UserOptions - Update with new features for VueUiCarouselTable
1 parent 0c99555 commit aee3e32

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

src/atoms/UserOptions.vue

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { ref, onMounted, onBeforeUnmount, computed, watch } from "vue";
2+
import { ref, onMounted, onBeforeUnmount } from "vue";
33
import vClickOutside from '../directives/vClickOutside';
44
import BaseIcon from "./BaseIcon.vue";
55
@@ -80,6 +80,14 @@ const props = defineProps({
8080
type: Boolean,
8181
default: false,
8282
},
83+
hasAnimation: {
84+
type: Boolean,
85+
default: false,
86+
},
87+
isAnimation: {
88+
type: Boolean,
89+
default: false,
90+
},
8391
titles: {
8492
type: Object,
8593
default() {
@@ -89,10 +97,18 @@ const props = defineProps({
8997
showTooltips: {
9098
type: Boolean,
9199
default: true
100+
},
101+
zIndex: {
102+
type: Number,
103+
default: 1
104+
},
105+
noOffset: {
106+
type: Boolean,
107+
default: false
92108
}
93109
});
94110
95-
const emit = defineEmits(['generatePdf', 'generateCsv', 'generateImage', 'toggleTable', 'toggleLabels', 'toggleSort', 'toggleFullscreen', 'toggleStack', 'toggleTooltip']);
111+
const emit = defineEmits(['generatePdf', 'generateCsv', 'generateImage', 'toggleTable', 'toggleLabels', 'toggleSort', 'toggleFullscreen', 'toggleStack', 'toggleTooltip', 'toggleAnimation']);
96112
97113
function generatePdf() {
98114
emit('generatePdf');
@@ -141,6 +157,13 @@ function toggleLabels() {
141157
emit('toggleLabels')
142158
}
143159
160+
const isAnimated = ref(props.isAnimation);
161+
162+
function toggleAnimation() {
163+
isAnimated.value = !isAnimated.value;
164+
emit('toggleAnimation');
165+
}
166+
144167
function toggleSort() {
145168
emit('toggleSort')
146169
}
@@ -174,7 +197,7 @@ function toggleFullscreen(state) {
174197
}
175198
}
176199
177-
function fullscreenchanged(event) {
200+
function fullscreenchanged(_event) {
178201
if (document.fullscreenElement) {
179202
isFullscreen.value = true;
180203
} else {
@@ -202,16 +225,17 @@ const isInfo = ref({
202225
sort: false,
203226
stack: false,
204227
fullscreen: false,
228+
animation: false,
205229
})
206230
207231
</script>
208232

209233
<template>
210-
<div v-click-outside="closeIfOpen" data-html2canvas-ignore class="vue-ui-user-options" :style="`height: 34px; position: ${isFullscreen ? 'fixed' : 'absolute'}; top: 0; right:${isFullscreen ? '12px': '0'}; padding: 4px; background:transparent; z-index: 1`">
211-
<div tabindex="0" :title="isOpen ? titles.close || '' : titles.open || ''" data-cy="user-options-summary" :style="`width:32px; position: absolute; top: 0; right:4px; padding: 0 0px; display: flex; align-items:center;justify-content:center;height: 36px; cursor:pointer; background:${backgroundColor}`" @click.stop="toggle" @keypress.enter="toggle">
234+
<div v-click-outside="closeIfOpen" data-html2canvas-ignore class="vue-ui-user-options" :style="`z-index: ${zIndex}; height: 34px; position: ${isFullscreen ? 'fixed' : 'absolute'}; top: 0; right:${isFullscreen ? '12px': '0'}; padding: 4px; background:transparent;`">
235+
<div tabindex="0" :title="isOpen ? titles.close || '' : titles.open || ''" data-cy="user-options-summary" :style="`width:32px; position: absolute; top: 0; right: ${noOffset ? 0 : 4}px; padding: 0 0px; display: flex; align-items:center;justify-content:center;height: 36px; cursor:pointer; background:${backgroundColor}`" @click.stop="toggle" @keypress.enter="toggle">
212236
<BaseIcon :name="isOpen ? 'close' : 'menu'" stroke="#CCCCCC" :stroke-width="2" />
213237
</div>
214-
<div data-cy="user-options-drawer" :data-open="isOpen" :class="{'vue-ui-user-options-drawer': true}" :style="`background:${backgroundColor};`">
238+
<div data-cy="user-options-drawer" :data-open="isOpen" :class="{'vue-ui-user-options-drawer': true}" :style="`background:${backgroundColor}; right:${noOffset ? 0 : 4}px`">
215239

216240
<button tabindex="0" v-if="hasTooltip" data-cy="user-options-tooltip" class="vue-ui-user-options-button" @click="toggleTooltip" @mouseenter="isInfo.tooltip = true" @mouseout="isInfo.tooltip = false">
217241
<template v-if="$slots.optionTooltip">
@@ -326,21 +350,30 @@ const isInfo = ref({
326350
</div>
327351
</button>
328352

353+
<button tabindex="0" v-if="hasAnimation" data-cy="user-options-anim" class="vue-ui-user-options-button" @mouseenter="isInfo.animation = true" @mouseout="isInfo.animation = false" @click="toggleAnimation">
354+
<template v-if="$slots.optionAnimation">
355+
<slot name="optionAnimation" v-bind="{ toggleAnimation, isAnimated }"/>
356+
</template>
357+
<template v-else>
358+
<BaseIcon v-if="isAnimated" name="play" :stroke="color" style="pointer-events: none;"/>
359+
<BaseIcon v-if="!isAnimated" name="pause" :stroke="color" style="pointer-events: none;"/>
360+
</template>
361+
<div v-if="isDesktop && titles.fullscreen && !$slots.optionAnimation" :class="{'button-info' : true, 'button-info-visible': isInfo.animation }" :style="{ background: backgroundColor, color: color }">
362+
{{ titles.animation }}
363+
</div>
364+
</button>
365+
329366
</div>
330367
</div>
331368
</template>
332369

333370
<style scoped>
334-
.vue-ui-user-options {
335-
z-index: 1;
336-
}
337371
.vue-ui-user-options-drawer[data-open="false"] {
338372
display: none;
339373
}
340374
341375
.vue-ui-user-options-drawer[data-open="true"] {
342376
position: absolute;
343-
right: 4px;
344377
top: 36px;
345378
display: flex;
346379
flex-direction: column;

0 commit comments

Comments
 (0)