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
d2c8f3d7
Commit
d2c8f3d7
authored
11 months ago
by
Malin Haugland Høli
Browse files
Options
Downloads
Patches
Plain Diff
feat:
Add confetti package and dependency
parent
db4c77bb
No related branches found
No related tags found
3 merge requests
!66
Final merge
,
!17
Navbar component
,
!4
Pipeline fix
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
package-lock.json
+10
-0
10 additions, 0 deletions
package-lock.json
package.json
+1
-0
1 addition, 0 deletions
package.json
src/views/HomeView.vue
+35
-20
35 additions, 20 deletions
src/views/HomeView.vue
with
46 additions
and
20 deletions
package-lock.json
+
10
−
0
View file @
d2c8f3d7
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
"version"
:
"0.0.0"
,
"version"
:
"0.0.0"
,
"dependencies"
:
{
"dependencies"
:
{
"animejs"
:
"^3.2.2"
,
"animejs"
:
"^3.2.2"
,
"canvas-confetti"
:
"^1.9.2"
,
"pinia"
:
"^2.1.7"
,
"pinia"
:
"^2.1.7"
,
"vue"
:
"^3.4.21"
,
"vue"
:
"^3.4.21"
,
"vue-router"
:
"^4.3.1"
"vue-router"
:
"^4.3.1"
...
@@ -2345,6 +2346,15 @@
...
@@ -2345,6 +2346,15 @@
}
}
]
]
},
},
"node_modules/canvas-confetti"
:
{
"version"
:
"1.9.2"
,
"resolved"
:
"https://registry.npmjs.org/canvas-confetti/-/canvas-confetti-1.9.2.tgz"
,
"integrity"
:
"sha512-6Xi7aHHzKwxZsem4mCKoqP6YwUG3HamaHHAlz1hTNQPCqXhARFpSXnkC9TWlahHY5CG6hSL5XexNjxK8irVErg=="
,
"funding"
:
{
"type"
:
"donate"
,
"url"
:
"https://www.paypal.me/kirilvatev"
}
},
"node_modules/caseless"
:
{
"node_modules/caseless"
:
{
"version"
:
"0.12.0"
,
"version"
:
"0.12.0"
,
"resolved"
:
"https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz"
,
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
0
View file @
d2c8f3d7
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"
animejs
"
:
"
^3.2.2
"
,
"
animejs
"
:
"
^3.2.2
"
,
"
canvas-confetti
"
:
"
^1.9.2
"
,
"
pinia
"
:
"
^2.1.7
"
,
"
pinia
"
:
"
^2.1.7
"
,
"
vue
"
:
"
^3.4.21
"
,
"
vue
"
:
"
^3.4.21
"
,
"
vue-router
"
:
"
^4.3.1
"
"
vue-router
"
:
"
^4.3.1
"
...
...
This diff is collapsed.
Click to expand it.
src/views/HomeView.vue
+
35
−
20
View file @
d2c8f3d7
...
@@ -15,16 +15,19 @@
...
@@ -15,16 +15,19 @@
<div
class=
"flex flex-col basis-2/3 max-h-full mx-auto max-w-5/6 md:basis-1/2"
>
<div
class=
"flex flex-col basis-2/3 max-h-full mx-auto max-w-5/6 md:basis-1/2"
>
<div
class=
"flex justify-center align-center"
>
<div
class=
"flex justify-center align-center"
>
<span
<span
class=
"w-full max-w-60 max-h-12
bg-green-500
text-
white
font-bold py-2 rounded mt-8 text-center space-x-2 drop-shadow-lg"
class=
"w-full max-w-60 max-h-12
text-black
text-
2xl
font-bold py-2 rounded mt-8 text-center space-x-2 drop-shadow-lg"
>
>
Din Sparesti
Din Sparesti
</span>
</span>
</div>
</div>
<div
class=
"h-1 w-4/6
bg-black
mx-auto my-2 opacity-10"
></div>
<div
class=
"h-1 w-4/6 mx-auto my-2 opacity-10"
></div>
<div
<div
ref=
"containerRef"
ref=
"containerRef"
class=
"container relative mx-auto pt-6 w-4/5 md:w-3/5 no-scrollbar h-full max-h-[60vh] md:max-h-[60v] overflow-y-auto border-2 border-
b
la
ck
rounded-lg bg-white shadow-lg"
class=
"container relative mx-auto pt-6 w-4/5 md:w-3/5 no-scrollbar h-full max-h-[60vh] md:max-h-[60v] overflow-y-auto border-2 border-
s
la
te-300
rounded-lg bg-white shadow-lg"
>
>
<div>
<img
src=
"@/assets/start.png"
alt=
"Spare"
class=
"md:w-1/6 md:h-auto h-20 "
/>
</div>
<div
<div
v-for=
"(challenge, index) in challenges"
v-for=
"(challenge, index) in challenges"
:key=
"challenge.title"
:key=
"challenge.title"
...
@@ -43,13 +46,13 @@
...
@@ -43,13 +46,13 @@
v-if=
"index === 3"
v-if=
"index === 3"
src=
"@/assets/sleepingSpare.gif"
src=
"@/assets/sleepingSpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"w-32 h-32 border-2
border-black
"
class=
"w-32 h-32 border-2
rounded-lg border-stale-400
"
/>
/>
<img
<img
v-else-if=
"index === 1"
v-else-if=
"index === 1"
src=
"@/assets/golfSpare.gif"
src=
"@/assets/golfSpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"w-32 h-32 border-2
border-black
"
class=
"w-32 h-32 border-2
rounded-lg border-stale-400
"
/>
/>
</div>
</div>
<!-- Challenge Icon and Details -->
<!-- Challenge Icon and Details -->
...
@@ -92,7 +95,7 @@
...
@@ -92,7 +95,7 @@
<button
<button
@
click=
"incrementSaved(challenge)"
@
click=
"incrementSaved(challenge)"
type=
"button"
type=
"button"
class=
"inline-block mb-2 ml-2 h-
8
w-8 rounded-full
bg-green-500
p-1 uppercase leading-normal t
ext-white bg-color-green shadow-green-500 transition duration-150 ease-in-out hover:bg-green-700 hover:shadow-green-200
focus:bg-green-accent-300 focus:shadow-green-2 focus:outline-none focus:ring-0 active:bg-green-600 active:shadow-green-200 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong"
class=
"inline-block mb-2 ml-2 h-
7
w-8 rounded-full p-1 uppercase leading-normal t
ransition duration-150 ease-in-out
focus:bg-green-accent-300 focus:shadow-green-2 focus:outline-none focus:ring-0 active:bg-green-600 active:shadow-green-200 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong"
>
>
+
+
</button>
</button>
...
@@ -108,11 +111,11 @@
...
@@ -108,11 +111,11 @@
challenge.completion !== undefined &&
challenge.completion !== undefined &&
challenge.completion >= 100
challenge.completion >= 100
"
"
class=
"max-w-1
6
max-h-1
6
"
class=
"max-w-1
0
max-h-1
0
"
>
>
<img
src=
"@/assets/completed.png"
alt=
""
/>
️
<img
src=
"@/assets/completed.png"
alt=
""
/>
️
</div>
</div>
<div
v-else
class=
"max-w-
1
6 max-h-
1
6"
>
<div
v-else
class=
"max-w-6 max-h-6"
>
<img
src=
"@/assets/pending.png"
alt=
""
/>
️
<img
src=
"@/assets/pending.png"
alt=
""
/>
️
</div>
</div>
</div>
</div>
...
@@ -121,12 +124,12 @@
...
@@ -121,12 +124,12 @@
v-if=
"index === 0"
v-if=
"index === 0"
src=
"@/assets/cowboySpare.gif"
src=
"@/assets/cowboySpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"h-32 w-32 border-2
border-black
"
class=
"h-32 w-32 border-2
rounded-lg border-stale-400
"
/>
/>
<img
<img
v-else-if=
"index === 2"
v-else-if=
"index === 2"
src=
"@/assets/hotAirBalloonSpare.gif"
src=
"@/assets/hotAirBalloonSpare.gif"
class=
"h-32 w-32 border-
black border-2
"
class=
"h-32 w-32 border-
stale-400 border-2 rounded-lg
"
alt=
"could not load"
alt=
"could not load"
/>
/>
</div>
</div>
...
@@ -163,7 +166,7 @@
...
@@ -163,7 +166,7 @@
</div>
</div>
<img
<img
src=
"@/assets/finishLine.png"
src=
"@/assets/finishLine.png"
class=
"w-full max-h-
4
mx-auto mt-
10
"
class=
"w-full max-h-
auto
mx-auto mt-
4
"
alt=
"Finish Line"
alt=
"Finish Line"
/>
/>
<!-- Sparemannen -->
<!-- Sparemannen -->
...
@@ -182,9 +185,9 @@
...
@@ -182,9 +185,9 @@
</div>
</div>
<div
class=
"flex flex-col items-end"
>
<div
class=
"flex flex-col items-end"
>
<div
@
click=
"goToEditGoal"
class=
"cursor-pointer"
>
<div
@
click=
"goToEditGoal"
class=
"cursor-pointer"
>
<h3
class=
"text-bl
ue-500
text-base"
>
Endre mål
</h3>
<h3
class=
"text-bl
ack
text-base"
>
Endre mål
</h3>
</div>
</div>
<div
ref=
"targetRef"
class=
"bg-yellow-400 px-4 py-1 rounded-full text-black"
>
<div
ref=
"targetRef"
class=
"bg-yellow-400 px-4 py-1 rounded-full text-black
font-bold
"
>
{{
goal
.
saved
}}
kr /
{{
goal
.
target
}}
kr
{{
goal
.
saved
}}
kr /
{{
goal
.
target
}}
kr
</div>
</div>
</div>
</div>
...
@@ -192,8 +195,8 @@
...
@@ -192,8 +195,8 @@
</div>
</div>
<!-- Animation icon -->
<!-- Animation icon -->
<img
<img
src=
"@/assets/
coins
.png"
src=
"@/assets/
penger
.png"
alt=
"
Coins
"
alt=
"
Penger
"
ref=
"iconRef"
ref=
"iconRef"
class=
"max-w-20 max-h-20 absolute opacity-0"
class=
"max-w-20 max-h-20 absolute opacity-0"
/>
/>
...
@@ -205,10 +208,11 @@
...
@@ -205,10 +208,11 @@
import
{
nextTick
,
onMounted
,
ref
,
watch
}
from
'
vue
'
import
{
nextTick
,
onMounted
,
ref
,
watch
}
from
'
vue
'
import
anime
from
'
animejs
'
import
anime
from
'
animejs
'
import
InteractiveSpare
from
'
@/components/InteractiveSpare.vue
'
import
InteractiveSpare
from
'
@/components/InteractiveSpare.vue
'
import
ButtonAddGoalOrChallenge
from
'
@/components/ButtonAddGoalOrChall
a
nge.vue
'
import
ButtonAddGoalOrChallenge
from
'
@/components/ButtonAddGoalOrChall
e
nge.vue
'
import
router
from
'
@/router
'
import
router
from
'
@/router
'
import
type
{
Challenge
}
from
'
@/types/challenge
'
import
type
{
Challenge
}
from
'
@/types/challenge
'
import
type
{
Goal
}
from
'
@/types/goal
'
import
type
{
Goal
}
from
'
@/types/goal
'
import
confetti
from
'
canvas-confetti
'
;
// Define your speech array
// Define your speech array
const
speechArray
=
[
const
speechArray
=
[
...
@@ -248,13 +252,13 @@ const challenge: Challenge = {
...
@@ -248,13 +252,13 @@ const challenge: Challenge = {
completedOn
:
undefined
// Not yet completed
completedOn
:
undefined
// Not yet completed
}
}
const
challenge1
:
Challenge
=
{
const
challenge1
:
Challenge
=
{
title
:
'
Snacks
'
,
title
:
'
Mat
'
,
saved
:
200
,
saved
:
200
,
target
:
400
,
target
:
400
,
description
:
'
Saving monthly for a year-end vacation to Bali
'
,
description
:
'
Saving monthly for a year-end vacation to Bali
'
,
createdOn
:
new
Date
(
'
2023-01-01T00:00:00Z
'
),
createdOn
:
new
Date
(
'
2023-01-01T00:00:00Z
'
),
dueDate
:
new
Date
(
'
2023-12-31T23:59:59Z
'
),
dueDate
:
new
Date
(
'
2023-12-31T23:59:59Z
'
),
type
:
'
SNACKS
'
,
type
:
'
MAT
'
,
completion
:
50
,
completion
:
50
,
completedOn
:
undefined
// Not yet completed
completedOn
:
undefined
// Not yet completed
}
}
...
@@ -314,11 +318,22 @@ const animateChallenge = (challenge: Challenge) => {
...
@@ -314,11 +318,22 @@ const animateChallenge = (challenge: Challenge) => {
!
animatedChallenges
.
value
.
has
(
challenge
.
title
)
!
animatedChallenges
.
value
.
has
(
challenge
.
title
)
)
{
)
{
console
.
log
(
'
Animating for:
'
,
challenge
.
title
)
console
.
log
(
'
Animating for:
'
,
challenge
.
title
)
recalculateAndAnimate
()
// Assumes this function triggers the actual animation
triggerConfetti
();
recalculateAndAnimate
()
saveAnimatedState
(
challenge
.
title
)
saveAnimatedState
(
challenge
.
title
)
}
}
}
}
function
triggerConfetti
()
{
confetti
({
particleCount
:
400
,
spread
:
80
,
origin
:
{
x
:
0.8
,
y
:
0.8
}
});
}
watch
(
watch
(
challenges
,
challenges
,
(
newChallenges
)
=>
{
(
newChallenges
)
=>
{
...
@@ -412,7 +427,7 @@ function animateIcon() {
...
@@ -412,7 +427,7 @@ function animateIcon() {
// Helper methods to get icons
// Helper methods to get icons
function
getChallengeIcon
(
challenge
:
Challenge
):
string
{
function
getChallengeIcon
(
challenge
:
Challenge
):
string
{
if
(
challenge
.
type
===
undefined
)
{
if
(
challenge
.
type
===
undefined
)
{
return
'
src/assets/
coins
.png
'
return
'
src/assets/
penger
.png
'
}
}
return
`src/assets/
${
challenge
.
type
.
toLowerCase
()}
.png`
return
`src/assets/
${
challenge
.
type
.
toLowerCase
()}
.png`
}
}
...
...
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