Skip to content

Commit 4c47d9d

Browse files
authored
Merge pull request #354 from serlo/331-show-birdie-in-more-places
show birdie in more places
2 parents 0f1bf62 + 9a13ba3 commit 4c47d9d

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

src/components/BirdieOverlay.tsx

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
import { faArrowRight, faCaretRight } from '@fortawesome/free-solid-svg-icons'
1+
import { faArrowRight } from '@fortawesome/free-solid-svg-icons'
22
import { FaIcon } from './ui/FaIcon'
3-
import { Play } from 'next/font/google'
4-
import { PlayerProfileStore } from '../../store/player-profile-store'
3+
import {
4+
PlayerProfileStore,
5+
updatePlayerProfileStore,
6+
} from '../../store/player-profile-store'
7+
import { ExerciseViewStore } from './exercise-view/state/exercise-view-store'
58

6-
export function BirdieOverlay({ context }: { context: 'map' }) {
9+
export function BirdieOverlay({ context }: { context: 'map' | 'exercise' }) {
710
const birdieIntros = PlayerProfileStore.useState(s => s.birdieIntros)
811

912
let text = ''
1013
let step = ''
1114

15+
const exerciseWithExample =
16+
ExerciseViewStore.getRawState().hasExamplePrescreen
17+
18+
const tag = ExerciseViewStore.getRawState().tag
19+
20+
console.log(tag)
21+
1222
if (context == 'map') {
1323
if (!birdieIntros.includes('map-1')) {
1424
text =
@@ -29,6 +39,29 @@ export function BirdieOverlay({ context }: { context: 'map' }) {
2939
}
3040
}
3141

42+
if (context == 'exercise') {
43+
if (exerciseWithExample) {
44+
if (!birdieIntros.includes('exercise-example-1')) {
45+
text =
46+
'Schau dir diese Beispiel-Aufgabe an. Unten findest du die Lösung dazu.'
47+
step = 'exercise-example-1'
48+
} else if (!birdieIntros.includes('exercise-example-2')) {
49+
text =
50+
'Wenn du die Lösung verstanden hast, gehe weiter zur nächsten Aufgabe.'
51+
step = 'exercise-example-2'
52+
}
53+
} else if (tag == 'Grundlagen - Challenge 1#') {
54+
if (!birdieIntros.includes('challenge-1')) {
55+
text = 'Jetzt hast du schon die ersten Skills gemeistert!'
56+
step = 'challenge-1'
57+
} else if (!birdieIntros.includes('challenge-2')) {
58+
text =
59+
'Bist du bereit für die 1. Challenge? Hier kannst du zeigen, was du gelernt hast!'
60+
step = 'challenge-2'
61+
}
62+
}
63+
}
64+
3265
if (!text) return null
3366

3467
return (
@@ -41,7 +74,7 @@ export function BirdieOverlay({ context }: { context: 'map' }) {
4174
<button
4275
className="w-12 h-12 bg-blue-300 rounded-full hover:bg-blue-400 mt-5"
4376
onClick={() => {
44-
PlayerProfileStore.update(s => {
77+
updatePlayerProfileStore(s => {
4578
s.birdieIntros.push(step)
4679
})
4780
}}

src/components/exercise-view/ExerciseViewLayout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ExerciseViewFooter } from './ExerciseViewFooter'
55
import { ChatOverlay } from './ChatOverlay'
66
import { CropImageOverlay } from './CropImageOverlay'
77
import { EndScreen } from './EndScreen'
8+
import { BirdieOverlay } from '../BirdieOverlay'
89

910
export function ExerciseViewLayout() {
1011
return (
@@ -20,6 +21,7 @@ export function ExerciseViewLayout() {
2021
</IonFooter>
2122
<ChatOverlay />
2223
<CropImageOverlay />
24+
<BirdieOverlay context="exercise" />
2325
<EndScreen />
2426
</IonPage>
2527
)

0 commit comments

Comments
 (0)