Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
idatt2106_2024_02_frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 - Gruppe 2
idatt2106_2024_02_frontend
Commits
ff8217d6
Commit
ff8217d6
authored
1 year ago
by
Ina Martini
Browse files
Options
Downloads
Patches
Plain Diff
refactor: put interactiveSpare in a modal
parent
85ee8282
Branches
feat/signup/config-new-user
Branches containing commit
No related tags found
3 merge requests
!66
Final merge
,
!42
Refactor interactiveSpare to modal
,
!4
Pipeline fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/InteractiveSpare.vue
+44
-21
44 additions, 21 deletions
src/components/InteractiveSpare.vue
with
44 additions
and
21 deletions
src/components/InteractiveSpare.vue
+
44
−
21
View file @
ff8217d6
<
template
>
<
div
class=
"flex items-center mr-10 max-w-[60vh]
"
:
cl
ass=
"
{ 'flex-row': direction === 'right', 'flex-row-reverse': direction === 'left' }
"
<
ModalComponent
:is-modal-open=
"isModalOpen
"
@
cl
ose=
"isModalOpen = false
"
>
<!-- Image -->
<img
:src=
"spareImageSrc"
:style=
"
{ width: pngSize + 'rem', height: pngSize + 'rem' }"
:class="['object-contain', ...imageClass]"
alt="Sparemannen"
class="w-dynamic h-dynamic object-contain"
@click="nextSpeech"
/>
<template
v-slot:input
>
<div
class=
"spareDiv flex items-center mr-10 max-w-[60vh] cursor-pointer"
:class=
"
{ 'flex-row': direction === 'right', 'flex-row-reverse': direction === 'left' }"
@click="nextSpeech"
>
<!-- Image -->
<img
:src=
"spareImageSrc"
:style=
"
{ width: pngSize + 'rem', height: pngSize + 'rem' }"
:class="['object-contain', ...imageClass]"
alt="Spare"
class="w-dynamic h-dynamic object-contain"
/>
<!-- Speech Bubble -->
<div
v-if=
"currentSpeech"
:class=
"`mb-40 inline-block relative w-64 bg-white p-4 rounded-3xl border border-gray-600 tri-right round $
{bubbleDirection}`"
>
<div
class=
"text-left leading-6"
>
<p
class=
"m-0"
>
{{
currentSpeech
}}
</p>
<!-- Speech Bubble -->
<div
v-if=
"currentSpeech"
:class=
"`mb-40 inline-block relative w-64 bg-white p-4 rounded-3xl border border-gray-600 tri-right round $
{bubbleDirection}`"
>
<div
class=
"text-left leading-6"
>
<p
class=
"speech m-0"
>
{{
currentSpeech
}}
</p>
</div>
</div>
</div>
</div>
</div>
<div
class=
" -mb-5 mt-8 text-xs text-gray-500"
>
<p
class=
"justify-center items-center"
>
Trykk for å se hva Spare har å si!
</p>
<a
@
click=
"closeModal"
class=
"underline hover:bg-transparent font-normal text-gray-500 cursor-pointer transition-none hover:transition-none hover:p-0"
>
Skip
</a>
</div>
</
template
>
</ModalComponent>
</template>
<
script
setup
lang=
"ts"
>
import
{
computed
,
defineProps
,
ref
}
from
'
vue
'
import
spareImageSrc
from
'
@/assets/spare.png
'
import
ModalComponent
from
'
@/components/ModalComponent.vue
'
interface
Props
{
speech
?:
string
[]
// Using TypeScript's type for speech as an array of strings
...
...
@@ -36,12 +52,17 @@ interface Props {
}
const
props
=
defineProps
<
Props
>
()
const
isModalOpen
=
ref
<
boolean
>
(
true
)
// Open modal by default
const
speech
=
ref
<
String
[]
>
(
props
.
speech
||
[])
const
currentSpeechIndex
=
ref
(
0
)
const
currentSpeech
=
computed
(()
=>
speech
.
value
[
currentSpeechIndex
.
value
])
const
closeModal
=
()
=>
{
isModalOpen
.
value
=
false
// Close modal
}
const
nextSpeech
=
()
=>
{
if
(
speech
.
value
.
length
>
0
)
{
// Remove the currently displayed speech first
...
...
@@ -54,6 +75,8 @@ const nextSpeech = () => {
}
else
{
// If no speeches left, reset index to indicate no available speech
currentSpeechIndex
.
value
=
-
1
// Close the modal if there are no speeches left
closeModal
()
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment