-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from rtCamp/feature/personalization-with-local…
…-storage Personalization demo with local storage
- Loading branch information
Showing
10 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -779,6 +779,10 @@ video { | |
height: 24rem; | ||
} | ||
|
||
.h-screen { | ||
height: 100vh; | ||
} | ||
|
||
.min-h-screen { | ||
min-height: 100vh; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%- include(commonPath + '/header.ejs') %> | ||
<div id="theme-container"> | ||
<%- include(commonPath + '/internal-page/header.ejs') %> | ||
<iframe src="<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/personalization-localstorage/theme-selection" class="border-8 rounded w-full h-96 overflow-hidden"></iframe> | ||
<%- include(commonPath + '/internal-page/footer.ejs') %> | ||
</div> | ||
<%- include(commonPath + '/footer.ejs') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const express = require('express'); | ||
const path = require('path'); | ||
const router = express.Router(); | ||
|
||
router.get('/', (req, res) => { | ||
res.render(path.join(__dirname,'index'), { | ||
title: 'Personalization with localStorage' | ||
}); | ||
}); | ||
|
||
router.get('/theme-selection', (req, res) => { | ||
res.render(path.join(__dirname,'theme-selection'), { | ||
title: 'Personalization' | ||
}); | ||
}); | ||
|
||
module.exports = router; |
41 changes: 41 additions & 0 deletions
41
src/scenarios/personalization-localstorage/theme-selection.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<%- include(commonPath + '/header.ejs') %> | ||
<div id="theme-container" class="h-screen flex items-center justify-center"> | ||
<%- include(commonPath + '/internal-page/header.ejs', {showHeader: false, containerType: 'sm'}) %> | ||
<div class="dark-mode-toggle"> | ||
<input type="checkbox" id="dark-mode-switch" /> | ||
<label for="dark-mode-switch"> | ||
<span class="bullet"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="sun" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58a.996.996 0 0 0-1.41 0 .996.996 0 0 0 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37a.996.996 0 0 0-1.41 0 .996.996 0 0 0 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0a.996.996 0 0 0 0-1.41l-1.06-1.06zm1.06-10.96a.996.996 0 0 0 0-1.41.996.996 0 0 0-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36a.996.996 0 0 0 0-1.41.996.996 0 0 0-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z"/></svg> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="moon" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3a9 9 0 1 0 9 9c0-.46-.04-.92-.1-1.36a5.389 5.389 0 0 1-4.4 2.26 5.403 5.403 0 0 1-3.14-9.8c-.44-.06-.9-.1-1.36-.1z"/></svg> | ||
</span> | ||
</label> | ||
</div> | ||
<%- include(commonPath + '/internal-page/footer.ejs') %> | ||
</div> | ||
|
||
<script> | ||
const themeSwitcher = document.getElementById('dark-mode-switch'); | ||
const themeContainer = document.getElementById('theme-container'); | ||
// Check for saved theme preference in localStorage | ||
const currentTheme = localStorage.getItem('theme'); | ||
console.log(currentTheme) | ||
if (currentTheme === 'dark') { | ||
themeContainer.classList.add(currentTheme); | ||
themeSwitcher.checked = true; | ||
} | ||
// Theme toggle event listener | ||
themeSwitcher.addEventListener('click', () => { | ||
themeContainer.classList.toggle('dark'); | ||
// Update localStorage | ||
if (themeContainer.classList.contains('dark')) { | ||
localStorage.setItem('theme', 'dark'); | ||
} else { | ||
localStorage.setItem('theme', 'light'); | ||
} | ||
}); | ||
</script> | ||
|
||
<%- include(commonPath + '/footer.ejs') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters