Add secondary mobile menu to Staff dashboard
This commit is contained in:
@@ -30,7 +30,48 @@
|
|||||||
('reports','Reports')
|
('reports','Reports')
|
||||||
] %}
|
] %}
|
||||||
|
|
||||||
<section class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
|
<section class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-soft">
|
||||||
|
<div class="sm:hidden">
|
||||||
|
<details id="employee-dashboard-mobile-menu" class="group">
|
||||||
|
<summary class="flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand-500">
|
||||||
|
<span class="inline-flex items-center gap-2">
|
||||||
|
<svg class="h-5 w-5 group-open:hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||||
|
<path stroke-linecap="round" d="M4 6h16M4 12h16M4 18h16" />
|
||||||
|
</svg>
|
||||||
|
<svg class="hidden h-5 w-5 group-open:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||||
|
<path stroke-linecap="round" d="M6 6l12 12M18 6 6 18" />
|
||||||
|
</svg>
|
||||||
|
<span>Dashboard Menu</span>
|
||||||
|
</span>
|
||||||
|
<span class="text-xs font-medium text-slate-500">Employee workspace sections</span>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
<nav aria-label="Employee workspace sections" class="border-t border-slate-100 bg-slate-50/80 px-4 py-3">
|
||||||
|
<ul class="space-y-1" role="list">
|
||||||
|
{% for code, label in main_tabs %}
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
data-tab="{{ code }}"
|
||||||
|
class="employee-portal-tab employee-portal-main-tab flex w-full items-center justify-between gap-3 rounded-xl px-3 py-2.5 text-left text-sm font-semibold transition {% if active_tab == code %}bg-brand-50 text-brand-700{% else %}bg-white text-slate-800 hover:bg-slate-100{% endif %}"
|
||||||
|
{% if active_tab == code %}aria-current="page"{% endif %}
|
||||||
|
>
|
||||||
|
<span class="inline-flex items-center gap-2">
|
||||||
|
<span>{{ label }}</span>
|
||||||
|
{% if code == 'hr' and unread_alert_count is defined and unread_alert_count > 0 %}
|
||||||
|
<span class="rounded-full bg-brand-100 px-2 py-0.5 text-[10px] font-bold text-brand-700">{{ unread_alert_count }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
{% if active_tab == code %}<span class="h-2 w-2 rounded-full bg-brand-600" data-active-marker aria-hidden="true"></span>{% endif %}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden p-3 sm:block">
|
||||||
<div class="mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-slate-500">Employee Workspace</div>
|
<div class="mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-slate-500">Employee Workspace</div>
|
||||||
<div class="overflow-x-auto pb-1">
|
<div class="overflow-x-auto pb-1">
|
||||||
<div class="flex min-w-max flex-nowrap gap-2" id="employee-portal-tabs">
|
<div class="flex min-w-max flex-nowrap gap-2" id="employee-portal-tabs">
|
||||||
@@ -41,6 +82,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="employee-portal-panel" class="space-y-6">
|
<section id="employee-portal-panel" class="space-y-6">
|
||||||
@@ -52,6 +94,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
const panel = document.getElementById('employee-portal-panel');
|
const panel = document.getElementById('employee-portal-panel');
|
||||||
const mainTabs = Array.from(document.querySelectorAll('.employee-portal-main-tab'));
|
const mainTabs = Array.from(document.querySelectorAll('.employee-portal-main-tab'));
|
||||||
|
const mobileMenu = document.getElementById('employee-dashboard-mobile-menu');
|
||||||
if (!panel || !mainTabs.length) return;
|
if (!panel || !mainTabs.length) return;
|
||||||
|
|
||||||
const groupMap = {
|
const groupMap = {
|
||||||
@@ -80,6 +123,31 @@
|
|||||||
const activeGroup = groupMap[tabName] || tabName || 'overview';
|
const activeGroup = groupMap[tabName] || tabName || 'overview';
|
||||||
mainTabs.forEach(function (button) {
|
mainTabs.forEach(function (button) {
|
||||||
const active = button.dataset.tab === activeGroup;
|
const active = button.dataset.tab === activeGroup;
|
||||||
|
const isMobileButton = button.closest('#employee-dashboard-mobile-menu') !== null;
|
||||||
|
|
||||||
|
if (isMobileButton) {
|
||||||
|
button.classList.toggle('bg-brand-50', active);
|
||||||
|
button.classList.toggle('text-brand-700', active);
|
||||||
|
button.classList.toggle('bg-white', !active);
|
||||||
|
button.classList.toggle('text-slate-800', !active);
|
||||||
|
button.classList.toggle('hover:bg-slate-100', !active);
|
||||||
|
if (active) {
|
||||||
|
button.setAttribute('aria-current', 'page');
|
||||||
|
} else {
|
||||||
|
button.removeAttribute('aria-current');
|
||||||
|
}
|
||||||
|
|
||||||
|
let marker = button.querySelector('[data-active-marker]');
|
||||||
|
if (active && !marker) {
|
||||||
|
marker = document.createElement('span');
|
||||||
|
marker.dataset.activeMarker = 'true';
|
||||||
|
marker.className = 'h-2 w-2 rounded-full bg-brand-600';
|
||||||
|
marker.setAttribute('aria-hidden', 'true');
|
||||||
|
button.appendChild(marker);
|
||||||
|
} else if (!active && marker) {
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
button.classList.toggle('bg-brand-600', active);
|
button.classList.toggle('bg-brand-600', active);
|
||||||
button.classList.toggle('text-white', active);
|
button.classList.toggle('text-white', active);
|
||||||
button.classList.toggle('shadow-soft', active);
|
button.classList.toggle('shadow-soft', active);
|
||||||
@@ -88,12 +156,14 @@
|
|||||||
button.classList.toggle('bg-white', !active);
|
button.classList.toggle('bg-white', !active);
|
||||||
button.classList.toggle('text-slate-700', !active);
|
button.classList.toggle('text-slate-700', !active);
|
||||||
button.classList.toggle('hover:bg-slate-50', !active);
|
button.classList.toggle('hover:bg-slate-50', !active);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTab(tabName, pushState) {
|
async function loadTab(tabName, pushState) {
|
||||||
const safeTab = tabName || 'overview';
|
const safeTab = tabName || 'overview';
|
||||||
setActive(safeTab);
|
setActive(safeTab);
|
||||||
|
if (mobileMenu) mobileMenu.open = false;
|
||||||
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
|
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/employee/dashboard/tab/' + encodeURIComponent(safeTab), {
|
const response = await fetch('/employee/dashboard/tab/' + encodeURIComponent(safeTab), {
|
||||||
|
|||||||
Reference in New Issue
Block a user