Skip to content

Commit

Permalink
Add highlighted explore buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
galeaspablo committed Nov 14, 2024
1 parent bc2e62f commit 7cec0c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
6 changes: 3 additions & 3 deletions application/frontend-javascript/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,15 @@ app.get('/event-bus-with-ambar-iframe', (req, res) => {
});

app.get('/event-bus-with-ambar', (req, res) => {
res.render('event-bus-with-ambar', { layout: layouts.explore, locals: {title: 'Explore Event Bus'} });
res.render('event-bus-with-ambar', { layout: layouts.explore, locals: {title: 'Explore Event Bus', activeEventBus: true} });
});

app.get('/event-store-with-postgres', (req, res) => {
res.render('event-store-with-postgres', { layout: layouts.explore, locals: {title: 'Explore Event Store'} });
res.render('event-store-with-postgres', { layout: layouts.explore, locals: {title: 'Explore Event Store', activeEventStore: true} });
});

app.get('/projections-with-mongo', (req, res) => {
res.render('projections-with-mongo', { layout: layouts.explore, locals: {title: 'Explore Projections'} });
res.render('projections-with-mongo', { layout: layouts.explore, locals: {title: 'Explore Projections', activeProjection: true} });
});

app.get("*", authenticated, render("404", { title: "Not Found" }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</head>
<body>
<div class="theme-switcher">
<button onclick="cycleTheme()" id="theme-toggle">🌓 Theme</button>
<button onclick="toggleTheme()" id="theme-toggle">🌓 Theme</button>
</div>
<div class="container">
<div class="description">
Expand Down Expand Up @@ -302,7 +302,7 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>


<script>
<script>
function toggleConfig() {
const content = document.querySelector('.config-content');
const chevron = document.querySelector('.chevron');
Expand Down Expand Up @@ -392,47 +392,57 @@
// Refresh every 5 seconds
setInterval(refreshData, 5000);
</script>
<script>
<script>
// Theme switching functionality
function cycleTheme() {
function toggleTheme() {
const html = document.documentElement;
const currentTheme = html.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
const themes = ['system', 'light', 'dark'];
const currentIndex = themes.indexOf(currentTheme);
const nextIndex = (currentIndex + 1) % themes.length;
const newTheme = themes[nextIndex];
html.setAttribute('data-theme', newTheme);
// Save preference
localStorage.setItem('preferred-theme', newTheme);
// Update button text
updateThemeButton(newTheme);
}
function updateThemeButton(theme) {
const button = document.getElementById('theme-toggle');
const icons = {
'system': '🌓',
'light': '☀️',
'dark': '🌙'
};
button.textContent = `${icons[theme]} Theme`;
}
// Initialize theme
// Initialize theme based on system preference
function initializeTheme() {
const savedTheme = localStorage.getItem('preferred-theme') || 'system';
document.documentElement.setAttribute('data-theme', savedTheme);
updateThemeButton(savedTheme);
// Check if user has a saved preference
const savedTheme = localStorage.getItem('preferred-theme');
if (savedTheme) {
// Use saved preference if it exists
document.documentElement.setAttribute('data-theme', savedTheme);
updateThemeButton(savedTheme);
} else {
// Otherwise use system preference
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const initialTheme = prefersDark ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', initialTheme);
updateThemeButton(initialTheme);
}
}
// Call initialize on page load
initializeTheme();
// Your existing JavaScript remains the same
// Listen for system theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
// Only update if user hasn't set a preference
if (!localStorage.getItem('preferred-theme')) {
const newTheme = e.matches ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', newTheme);
updateThemeButton(newTheme);
}
});
</script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@

<!-- Middle Navigation -->
<div class="flex flex-wrap items-center justify-center gap-4">
<a href="/event-store-with-postgres" class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-white/20 hover:bg-white/30 transition-colors rounded-md px-4 py-2">
<a href="/event-store-with-postgres" class="w-full sm:w-auto flex items-center justify-center space-x-2 {{#if locals.activeEventStore}}bg-white/60 hover:bg-white/70{{else}}bg-white/20 hover:bg-white/30{{/if}} transition-colors rounded-md px-4 py-2">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M1 5h8M5 17v4M1 19h8M5 10v4M1 12h8M19 3v4M15 5h8M19 17v4M15 19h8M19 10v4M15 12h8"></path>
</svg>
<span>Explore Event Store</span>
</a>

<a href="/projections-with-mongo" class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-white/20 hover:bg-white/30 transition-colors rounded-md px-4 py-2">
<a href="/projections-with-mongo" class="w-full sm:w-auto flex items-center justify-center space-x-2 {{#if locals.activeProjection}}bg-white/60 hover:bg-white/70{{else}}bg-white/20 hover:bg-white/30{{/if}} transition-colors rounded-md px-4 py-2">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
</svg>
<span>Explore Projections</span>
</a>

<a href="/event-bus-with-ambar" class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-white/20 hover:bg-white/30 transition-colors rounded-md px-4 py-2">
<a href="/event-bus-with-ambar" class="w-full sm:w-auto flex items-center justify-center space-x-2 {{#if locals.activeEventBus}}bg-white/60 hover:bg-white/70{{else}}bg-white/20 hover:bg-white/30{{/if}} transition-colors rounded-md px-4 py-2">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path>
</svg>
Expand Down

0 comments on commit 7cec0c8

Please sign in to comment.