Skip to content
Snippets Groups Projects
Commit e4f6e237 authored by Valdemar Åstorp Beere's avatar Valdemar Åstorp Beere
Browse files

refactor(component):

Made Interactive responsive
parent 5eb69232
No related branches found
No related tags found
3 merge requests!66Final merge,!12feat(homepage):,!4Pipeline fix
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!-- Image --> <!-- Image -->
<img :src="spareImageSrc" :class="['w-' + pngSize, 'h-' + pngSize, imageClass]" alt="Sparemannen" @click="nextSpeech"> <img :src="spareImageSrc" :class="['w-' + pngSize, 'h-' + pngSize, imageClass]" alt="Sparemannen" @click="nextSpeech">
<!-- Speech Bubble --> <!-- Speech Bubble -->
<div class="rounded-lg bg-white p-4 text-black border-black border-2" :style="{ minHeight: '4rem' }"> <div v-if="currentSpeech" class="rounded-lg bg-white p-4 text-black border-black border-2 min-h-16 max-w-48">
<span>{{ currentSpeech }}</span> <span>{{ currentSpeech }}</span>
</div> </div>
</div> </div>
...@@ -36,16 +36,26 @@ const props = defineProps<Props>(); ...@@ -36,16 +36,26 @@ const props = defineProps<Props>();
const speech = ref<string[]>(props.speech || []); const speech = ref<string[]>(props.speech || []);
const currentSpeechIndex = ref(0); const currentSpeechIndex = ref(0);
const currentSpeech = ref(props.speech[0] || '...'); const currentSpeech = computed(() => speech.value[currentSpeechIndex.value]);
const nextSpeech = () => { const nextSpeech = () => {
if (speech.value.length > 0) { if (speech.value.length > 0) {
currentSpeechIndex.value = (currentSpeechIndex.value + 1) % speech.value.length; // Remove the currently displayed speech first
currentSpeech.value = props.speech[currentSpeechIndex.value]; speech.value.splice(currentSpeechIndex.value, 1);
// Check if there are any speeches left after removal
if (speech.value.length > 0) {
// Move to the next speech or reset to the beginning if the current index is out of range
currentSpeechIndex.value = currentSpeechIndex.value % speech.value.length;
} else {
// If no speeches left, reset index to indicate no available speech
currentSpeechIndex.value = -1;
}
} }
}; };
const imageClass = computed(() => { const imageClass = computed(() => {
return [ return [
'transform', 'transform',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment