Skip to content

Commit

Permalink
add notification for web support
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdaniculae committed Oct 21, 2024
1 parent 094188f commit aa9e057
Show file tree
Hide file tree
Showing 18 changed files with 276 additions and 71 deletions.
80 changes: 38 additions & 42 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,50 +336,46 @@ <h1 class="w-[40ch] text-bke-orange"></h1>
id="app-version"
class="absolute bottom-1 right-1 hidden text-xs opacity-30 group-data-[view='age-category']/app:block"
></div>
<div
id="notification"
class="notification pointer-events-none fixed inset-0 z-50 hidden overflow-hidden"
>
<div class="flex h-full w-full p-4">
<div class="notification-frame self-end">
<div class="notification-content flex h-full flex-col justify-between">
<svg class="icon h-8 w-8 text-bke-orange">
<use href="#circle-exclamation-solid" fill="currentColor"></use>
</svg>
<p id="message" class="mt-4"></p>
<button
id="restart-button"
class="button-grid pointer-events-auto mt-4 hidden"
>
<div class="corner top-left"></div>
<div class="edge top"></div>
<div class="corner top-right"></div>
<div class="edge left"></div>
<div class="content"></div>
<div class="edge right"></div>
<div class="corner bottom-left"></div>
<div class="edge bottom"></div>
<div class="corner bottom-right"></div>
</button>
</div>

<button id="close-button" class="button-grid pointer-events-auto">
<div class="corner top-left"></div>
<div class="edge top"></div>
<div class="corner top-right"></div>
<div class="edge left"></div>
<div class="content">
<svg class="icon">
<use href="#xmark-large-solid" fill="currentColor"></use>
</svg>
</div>
<div class="edge right"></div>
<div class="corner bottom-left"></div>
<div class="edge bottom"></div>
<div class="corner bottom-right"></div>
</button>
<div id="notification" class="notification z-50 hidden">
<div class="corner top-left"></div>
<div class="edge top"></div>
<div class="corner top-right"></div>
<div class="edge left"></div>
<div class="content">
<div class="notification-header">
<svg class="icon text-bke-orange"><use href="#circle-exclamation-solid" fill="currentColor"></use></svg>
<h3 class="notification-title"></h3>
</div>
<p class="notification-message"></p>
<button id="restart-button" class="button-grid">
<div class="corner top-left"></div>
<div class="edge top"></div>
<div class="corner top-right"></div>
<div class="edge left"></div>
<div class="content"></div>
<div class="edge right"></div>
<div class="corner bottom-left"></div>
<div class="edge bottom"></div>
<div class="corner bottom-right"></div>
</button>
<button id="close-button" class="button-grid">
<div class="corner top-left"></div>
<div class="edge top"></div>
<div class="corner top-right"></div>
<div class="edge left"></div>
<div class="content">
<svg><use href="#xmark-large-solid" fill="currentColor"></use></svg>
</div>
<div class="edge right"></div>
<div class="corner bottom-left"></div>
<div class="edge bottom"></div>
<div class="corner bottom-right"></div>
</button>
</div>
<div class="edge right"></div>
<div class="corner bottom-left"></div>
<div class="edge bottom"></div>
<div class="corner bottom-right"></div>
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions src/locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Skriv dit navn her",
"submit": "Tilføj"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,11 @@
"waitingScreen": {
"inputPlaceholder": "Gebe hier deinen Namen ein",
"submit": "Hinzufügen"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Write your name here",
"submit": "Add"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Write your name",
"submit": "Add"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Kirjoita nimesi tähän",
"submit": "Lisää"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Write your name here",
"submit": "Add"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Írd ide a neved",
"submit": "Hozzáadás"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Inserisci il tuo nome qui",
"submit": "Aggiungere"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Schrijf hier je naam",
"submit": "Bevestig"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"quiz": "quizer"
},
"activityDescLabel": "Mentor veiledning"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Wpisz tutaj swoje imię",
"submit": "Dodaj"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/pt-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Write your name",
"submit": "Add"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Introdu numele aici",
"submit": "Adaugă"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Введите свое имя здесь",
"submit": "Добавить в"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
6 changes: 6 additions & 0 deletions src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@
"waitingScreen": {
"inputPlaceholder": "Adınızı buraya girin ",
"submit": "İsminizi ekleyin"
},
"notifications": {
"webSupport": {
"title": "Oops!",
"text": "It looks like you're accessing Explorers on a device that is not supported, which could affect some features and functionality.\n For the best experience, we recommend visiting this site on a PC using Chrome or Safari. Thank you for your understanding!"
}
}
}
51 changes: 35 additions & 16 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ _appInsights.trackPageView({ name: 'Home' })
const experience = new Experience()


const notification = document.getElementById('notification')
const message = document.getElementById('message')
const closeButton = document.getElementById('close-button')
const notification = document.querySelector('.notification')
const message = document.querySelector('.notification-message')
const title = document.querySelector('.notification-title')
const closeButton = document.querySelector('#close-button')
const restartButton = document.querySelector('#restart-button')

// New app version notification
// New app version notification
function showNotification() {
gsap.fromTo(
notification,
Expand All @@ -56,6 +57,17 @@ function showNotification() {
)
}

closeButton.addEventListener('click', () => {
gsap.to(notification, {
duration: 1,
x: '-100%',
ease: 'power3.in',
onComplete: () => {
notification.classList.add('hidden')
},
})
})

if (isElectron()) {
document.body.classList.add('electron')

Expand All @@ -74,22 +86,10 @@ if (isElectron()) {
showNotification()
})

closeButton.addEventListener('click', () => {
gsap.to(notification, {
duration: 1,
x: '-100%',
ease: 'power3.in',
onComplete: () => {
notification.classList.add('hidden')
},
})
})

restartButton.addEventListener('click', () => {
window.electronAPI.restartApp()
})
} else {

// Register Service Worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
Expand Down Expand Up @@ -180,10 +180,29 @@ window.onload = async () => {
await configureClient()
await handleRedirectCallback()
}

window.addEventListener(_e.ACTIONS.ROUTE_CHANGED, async ({ detail }) => {
window.location.search = detail.replace('/?', '')
await configureClient()
await handleRedirectCallback()
})

// Detecting unsupported browsers
function isSupportedBrowser() {
const userAgent = navigator.userAgent;
return /Chrome|Safari/.test(userAgent) && !/Edge|OPR|Firefox/.test(userAgent);
}

// Detecting mobile devices (optional, if you want to show it based on devices)
function isMobileDevice() {
return /Mobi|Android/i.test(navigator.userAgent);
}

// Showing notification if unsupported browser or device is detected
if (!isSupportedBrowser() || isMobileDevice()) {

title.innerHTML = _s.notifications.webSupport.title
message.innerHTML = _s.notifications.webSupport.text
restartButton.classList.add('hidden')
showNotification()
}
Loading

0 comments on commit aa9e057

Please sign in to comment.