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
fa233910
Commit
fa233910
authored
11 months ago
by
Ina Martini
Browse files
Options
Downloads
Patches
Plain Diff
refactor: InteractiveSpare modal
parent
49144039
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
+14
-8
14 additions, 8 deletions
src/components/InteractiveSpare.vue
with
14 additions
and
8 deletions
src/components/InteractiveSpare.vue
+
14
−
8
View file @
fa233910
...
...
@@ -31,7 +31,7 @@
<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=
"
close
Modal"
@
click=
"Modal
Closed
"
class=
"underline hover:bg-transparent font-normal text-gray-500 cursor-pointer transition-none hover:transition-none hover:p-0"
>
Skip
...
...
@@ -42,7 +42,7 @@
</template>
<
script
setup
lang=
"ts"
>
import
{
computed
,
defineProps
,
ref
}
from
'
vue
'
import
{
computed
,
defineProps
,
ref
,
watch
}
from
'
vue
'
import
spareImageSrc
from
'
@/assets/spare.png
'
import
ModalComponent
from
'
@/components/ModalComponent.vue
'
...
...
@@ -50,20 +50,17 @@ interface Props {
speech
?:
string
[]
// Using TypeScript's type for speech as an array of strings
direction
:
'
left
'
|
'
right
'
// This restricts direction to either 'left' or 'right'
pngSize
:
number
// Just declaring the type directly since it's simple
isModalOpen
:
boolean
}
const
props
=
defineProps
<
Props
>
()
const
isModalOpen
=
ref
<
boolean
>
(
true
)
// Open modal by default
const
speech
=
ref
<
String
[]
>
(
props
.
speech
||
[])
const
isModalOpen
=
ref
(
props
.
isModalOpen
)
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
...
...
@@ -77,7 +74,7 @@ const nextSpeech = () => {
// If no speeches left, reset index to indicate no available speech
currentSpeechIndex
.
value
=
-
1
// Close the modal if there are no speeches left
close
Modal
()
Modal
Closed
()
}
}
}
...
...
@@ -92,6 +89,15 @@ const imageClass = computed(() => {
const
bubbleDirection
=
computed
(()
=>
{
return
props
.
direction
===
'
right
'
?
'
btm-left-in
'
:
'
btm-right-in
'
})
const
ModalClosed
=
()
=>
{
isModalOpen
.
value
=
false
}
watch
(()
=>
props
.
isModalOpen
,
(
newVal
)
=>
{
isModalOpen
.
value
=
newVal
;
});
</
script
>
<
style
scoped
>
/* CSS talk bubble */
...
...
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