Skip to content

Commit 42dca8e

Browse files
authored
Merge pull request #147 from raifdmueller/feature/onboarding-modal
feat: Embed YouTube video on mobile in onboarding modal
2 parents 19bf9bf + 72dcadf commit 42dca8e

2 files changed

Lines changed: 4 additions & 50 deletions

File tree

website/src/components/onboarding-modal.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function escapeHtml(str) {
7272
function buildModalContent() {
7373
const lang = i18n.currentLang()
7474
const videoId = YOUTUBE_VIDEOS[lang] || YOUTUBE_VIDEOS.en
75-
const youtubeUrl = `https://youtube.com/shorts/${videoId}`
7675
const embedUrl = `https://www.youtube.com/embed/${videoId}`
7776
const baseUrl = import.meta.env.BASE_URL
7877

@@ -111,9 +110,6 @@ function buildModalContent() {
111110
<div class="px-6 pb-4">
112111
<div class="flex flex-col sm:flex-row gap-6">
113112
<div class="sm:w-1/2 flex-shrink-0 flex items-center justify-center">
114-
${
115-
window.matchMedia('(min-width: 640px)').matches
116-
? `
117113
<div class="rounded-xl overflow-hidden bg-black aspect-[9/16] max-h-[400px] w-full">
118114
<iframe
119115
src="${embedUrl}"
@@ -124,21 +120,6 @@ function buildModalContent() {
124120
allowfullscreen
125121
></iframe>
126122
</div>
127-
`
128-
: `
129-
<a
130-
href="${youtubeUrl}"
131-
target="_blank"
132-
rel="noopener noreferrer"
133-
class="flex items-center gap-2 text-[var(--color-primary)] hover:underline font-medium py-2"
134-
>
135-
<svg class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
136-
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
137-
</svg>
138-
${watchVideo}
139-
</a>
140-
`
141-
}
142123
</div>
143124
144125
<div class="sm:w-1/2 flex flex-col gap-3 text-[var(--color-text)] text-sm leading-relaxed">

website/src/components/onboarding-modal.test.js

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,17 @@ import {
88
} from './onboarding-modal.js'
99

1010
describe('onboarding-modal', () => {
11-
let originalMatchMedia
12-
1311
beforeEach(() => {
1412
localStorage.clear()
1513
i18n.init()
1614
// Note: innerHTML usage here is in test code only, not production.
1715
// The test DOM is reset between tests and contains no user input.
1816
document.body.innerHTML = ''
19-
// Mock matchMedia - default to desktop (min-width: 640px matches)
20-
originalMatchMedia = window.matchMedia
21-
window.matchMedia = (query) => ({
22-
matches: query === '(min-width: 640px)',
23-
media: query,
24-
onchange: null,
25-
addListener: () => {},
26-
removeListener: () => {},
27-
addEventListener: () => {},
28-
removeEventListener: () => {},
29-
dispatchEvent: () => false,
30-
})
3117
})
3218

3319
afterEach(() => {
3420
document.body.innerHTML = ''
3521
document.body.style.overflow = ''
36-
window.matchMedia = originalMatchMedia
3722
})
3823

3924
describe('shouldShowOnboarding', () => {
@@ -83,7 +68,7 @@ describe('onboarding-modal', () => {
8368
expect(modal.textContent).toContain('One word, and the AI gets the rest.')
8469
})
8570

86-
it('contains the YouTube embed for desktop', () => {
71+
it('contains the YouTube embed', () => {
8772
createOnboardingModal()
8873
showOnboarding()
8974

@@ -101,25 +86,13 @@ describe('onboarding-modal', () => {
10186
expect(iframe.src).toContain('youtube.com/embed/cp-qqiHU-MA')
10287
})
10388

104-
it('contains YouTube link on mobile instead of iframe', () => {
105-
window.matchMedia = (query) => ({
106-
matches: false,
107-
media: query,
108-
onchange: null,
109-
addListener: () => {},
110-
removeListener: () => {},
111-
addEventListener: () => {},
112-
removeEventListener: () => {},
113-
dispatchEvent: () => false,
114-
})
89+
it('always embeds video iframe regardless of screen size', () => {
11590
createOnboardingModal()
11691
showOnboarding()
11792

118-
const link = document.querySelector('#onboarding-modal a[href*="youtube.com/shorts"]')
119-
expect(link).toBeTruthy()
120-
expect(link.getAttribute('target')).toBe('_blank')
12193
const iframe = document.querySelector('#onboarding-modal iframe')
122-
expect(iframe).toBeNull()
94+
expect(iframe).toBeTruthy()
95+
expect(iframe.src).toContain('youtube.com/embed/')
12396
})
12497
})
12598

0 commit comments

Comments
 (0)