Skip to content

Commit 65de44e

Browse files
committed
refactor: update titles
1 parent c2ef1c7 commit 65de44e

4 files changed

Lines changed: 34 additions & 15 deletions

File tree

public/icon.png

-6.24 KB
Binary file not shown.

public/icon.svg

Lines changed: 3 additions & 0 deletions
Loading

public/index.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
8-
<link rel="shortcut icon" type="image/png" href="/icon.png" />
8+
<link rel="shortcut icon" type="image/svg+xml" href="/icon.svg" />
99

1010
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap" rel="stylesheet" />
1111

@@ -26,11 +26,21 @@
2626
<div class="sidebar">
2727
<div class="header">
2828
<svg class="logo" width="52" height="52" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
29-
<path d="M10 90 L40 10 L70 90 L90 50" stroke="white" stroke-width="10" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
29+
<path d="M10 90 L40 10 L70 90 L90 50" stroke="white" stroke-width="10" fill="#34495e" stroke-linecap="round"
30+
stroke-linejoin="round" />
3031
</svg>
3132
<div class="popover-container">
3233
<button class="location-btn">
33-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-locate-fixed-icon lucide-locate-fixed"><line x1="2" x2="5" y1="12" y2="12"/><line x1="19" x2="22" y1="12" y2="12"/><line x1="12" x2="12" y1="2" y2="5"/><line x1="12" x2="12" y1="19" y2="22"/><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="3"/></svg>
34+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
35+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
36+
class="lucide lucide-locate-fixed-icon lucide-locate-fixed">
37+
<line x1="2" x2="5" y1="12" y2="12" />
38+
<line x1="19" x2="22" y1="12" y2="12" />
39+
<line x1="12" x2="12" y1="2" y2="5" />
40+
<line x1="12" x2="12" y1="19" y2="22" />
41+
<circle cx="12" cy="12" r="7" />
42+
<circle cx="12" cy="12" r="3" />
43+
</svg>
3444
</button>
3545
<div class="popover"></div>
3646
</div>

public/script.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const LOCATE_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="
1717
class Workout {
1818
id = (Date.now() + '').slice(-10);
1919
date = new Date();
20-
workoutDate;
20+
formattedDate;
21+
cardTitle;
22+
popupTitle;
2123
clicks = 0;
2224
/**
2325
* @param {number} distance
@@ -28,7 +30,11 @@ class Workout {
2830
this.distance = distance;
2931
this.duration = duration;
3032
this.coords = coords;
33+
this.calcDate();
34+
this.setPopupTitle();
35+
this.setCardTitle();
3136
}
37+
3238
calcDate() {
3339
const months = [
3440
'January',
@@ -44,7 +50,13 @@ class Workout {
4450
'November',
4551
'December',
4652
];
47-
this.workoutDate = `${this.distance}km, ${this.duration}m - ${months[this.date.getMonth()]} ${this.date.getDate()}, ${this.date.getFullYear()}`;
53+
this.formattedDate = `${months[this.date.getMonth()]} ${this.date.getDate()}, ${this.date.getFullYear()}`;
54+
}
55+
setPopupTitle() {
56+
this.popupTitle = `${this.type === 'running' ? '🏃‍♂️' : '🚴‍♀️'}${this.distance}km in ${this.duration}min — ${this.formattedDate}`
57+
}
58+
setCardTitle() {
59+
this.cardTitle = `${this.type === 'running' ? 'Running' : 'Cycling'} on ${this.formattedDate}`
4860
}
4961
addClick() {
5062
this.clicks++;
@@ -57,7 +69,6 @@ class Running extends Workout {
5769
super(distance, duration, coords);
5870
this.cadence = cadence;
5971
this.calcPace();
60-
this.calcDate();
6172
}
6273

6374
calcPace() {
@@ -71,7 +82,6 @@ class Cycling extends Workout {
7182
super(distance, duration, coords);
7283
this.elevationGain = elevationGain;
7384
this.calcSpeed();
74-
this.calcDate();
7585
}
7686

7787
calcSpeed() {
@@ -268,16 +278,14 @@ class App {
268278
.addTo(this.#map)
269279
.bindPopup(
270280
L.popup({
271-
maxWidth: 250,
281+
maxWidth: 300,
272282
minWidth: 100,
273283
autoClose: false,
274284
closeOnClick: false,
275285
className: `${workout.type}-popup`,
276286
})
277287
)
278-
.setPopupContent(
279-
`${workout.type === 'running' ? '🏃‍♂️' : '🚴‍♀️'}${workout.workoutDate}`
280-
)
288+
.setPopupContent(workout.popupTitle)
281289
.openPopup();
282290
}
283291

@@ -295,16 +303,14 @@ class App {
295303
className: `${workout.type}-popup`,
296304
})
297305
)
298-
.setPopupContent(
299-
`${workout.type === 'running' ? '🏃‍♂️' : '🚴‍♀️'}${workout.workoutDate}`
300-
)
306+
.setPopupContent(workout.popupTitle)
301307
.openPopup();
302308
}
303309

304310
_renderWorkout(workout) {
305311
let html = `
306312
<li class="workout workout--${workout.type}" data-id="${workout.id}">
307-
<h2 class="workout__title">${workout.workoutDate}</h2>
313+
<h2 class="workout__title">${workout.cardTitle}</h2>
308314
<div class="workout__details">
309315
<span class="workout__icon">${workout.type === 'running' ? '🏃‍♂️' : '🚴‍♀️'
310316
}</span>

0 commit comments

Comments
 (0)