196 lines
6.5 KiB
PHP
196 lines
6.5 KiB
PHP
@php
|
|
$tabs = [
|
|
['slug' => 'performance', 'title' => '灵珊店铺业绩', 'icon' => 'leaderboard'],
|
|
['slug' => 'shipments', 'title' => '发货明细数据', 'icon' => 'local_shipping'],
|
|
['slug' => 'quotation', 'title' => '顾家报价单', 'icon' => 'request_quote'],
|
|
];
|
|
@endphp
|
|
|
|
<nav
|
|
class="kuka-posting-subnav"
|
|
data-kuka-posting-subnav
|
|
aria-label="顾家过账基础数据子菜单"
|
|
>
|
|
<div class="kuka-posting-subnav__scroll" role="tablist" aria-label="顾家过账基础数据">
|
|
@foreach ($tabs as $tab)
|
|
@php $selected = $activeSubmenu === $tab['slug']; @endphp
|
|
<a
|
|
id="kuka-posting-tab-{{ $tab['slug'] }}"
|
|
href="{{ request()->fullUrlWithQuery(['submenu' => $tab['slug']]) }}"
|
|
class="kuka-posting-subnav__tab {{ $selected ? 'is-active' : '' }}"
|
|
role="tab"
|
|
aria-selected="{{ $selected ? 'true' : 'false' }}"
|
|
aria-controls="kuka-posting-panel-{{ $tab['slug'] }}"
|
|
tabindex="{{ $selected ? '0' : '-1' }}"
|
|
data-kuka-posting-tab="{{ $tab['slug'] }}"
|
|
@if ($selected) aria-current="page" @endif
|
|
>
|
|
<span class="material-icons-outlined" aria-hidden="true">{{ $tab['icon'] }}</span>
|
|
<span>{{ $tab['title'] }}</span>
|
|
</a>
|
|
@endforeach
|
|
</div>
|
|
</nav>
|
|
|
|
<style>
|
|
.kuka-posting-subnav {
|
|
min-width: 0;
|
|
max-width: 100%;
|
|
padding: 2px 4px;
|
|
border: 1px solid var(--vip-border, #d8d2c7);
|
|
border-radius: 8px;
|
|
background: var(--vip-surface, #fff);
|
|
}
|
|
.kuka-posting-subnav__scroll {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 2px;
|
|
min-width: 0;
|
|
overflow-x: auto;
|
|
scrollbar-width: thin;
|
|
}
|
|
.kuka-posting-subnav__tab {
|
|
position: relative;
|
|
display: inline-flex;
|
|
flex: 0 0 auto;
|
|
min-height: 32px;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 0 10px;
|
|
border-radius: 4px;
|
|
color: var(--vip-content-muted, #595959);
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
line-height: 1;
|
|
text-decoration: none;
|
|
white-space: nowrap;
|
|
transition: color 150ms ease, background-color 150ms ease;
|
|
}
|
|
.kuka-posting-subnav__tab .material-icons-outlined {
|
|
font-size: 16px;
|
|
}
|
|
.kuka-posting-subnav__tab:hover,
|
|
.kuka-posting-subnav__tab:focus-visible {
|
|
background: var(--vip-content-accent-soft, #f7f0de);
|
|
color: var(--vip-content-accent-dark, #856632);
|
|
outline: none;
|
|
}
|
|
.kuka-posting-subnav__tab:focus-visible {
|
|
box-shadow: 0 0 0 3px rgba(133, 102, 50, 0.2);
|
|
}
|
|
.kuka-posting-subnav__tab.is-active {
|
|
color: var(--vip-content-accent-dark, #856632);
|
|
font-weight: 600;
|
|
}
|
|
.kuka-posting-subnav__tab.is-active::after {
|
|
position: absolute;
|
|
right: 10px;
|
|
bottom: 0;
|
|
left: 10px;
|
|
height: 3px;
|
|
border-radius: 999px 999px 0 0;
|
|
background: var(--vip-content-accent, #b9954f);
|
|
content: "";
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.kuka-posting-subnav__tab { transition: none; }
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const nav = document.querySelector('[data-kuka-posting-subnav]');
|
|
const workspace = document.querySelector('[data-kuka-posting-content]');
|
|
if (!nav || !workspace) {
|
|
return;
|
|
}
|
|
|
|
const tabs = [...nav.querySelectorAll('[data-kuka-posting-tab]')];
|
|
const panels = [...workspace.querySelectorAll('[data-kuka-posting-panel]')];
|
|
const validSubmenus = new Set(tabs.map((tab) => tab.dataset.kukaPostingTab));
|
|
|
|
const currentSubmenu = () => {
|
|
const value = new URL(window.location.href).searchParams.get('submenu');
|
|
|
|
return validSubmenus.has(value) ? value : 'shipments';
|
|
};
|
|
|
|
const activate = (submenu, pushState = false, url = null) => {
|
|
if (!validSubmenus.has(submenu)) {
|
|
submenu = 'shipments';
|
|
}
|
|
|
|
tabs.forEach((tab) => {
|
|
const selected = tab.dataset.kukaPostingTab === submenu;
|
|
tab.classList.toggle('is-active', selected);
|
|
tab.setAttribute('aria-selected', selected ? 'true' : 'false');
|
|
tab.tabIndex = selected ? 0 : -1;
|
|
if (selected) {
|
|
tab.setAttribute('aria-current', 'page');
|
|
} else {
|
|
tab.removeAttribute('aria-current');
|
|
}
|
|
});
|
|
|
|
panels.forEach((panel) => {
|
|
panel.hidden = panel.dataset.kukaPostingPanel !== submenu;
|
|
});
|
|
|
|
if (pushState && url && window.location.href !== url) {
|
|
window.history.pushState({ kukaPostingSubmenu: submenu }, '', url);
|
|
}
|
|
};
|
|
|
|
nav.addEventListener('click', (event) => {
|
|
const tab = event.target.closest('[data-kuka-posting-tab]');
|
|
if (!tab
|
|
|| event.button !== 0
|
|
|| event.ctrlKey
|
|
|| event.metaKey
|
|
|| event.shiftKey
|
|
|| event.altKey
|
|
) {
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
const submenu = tab.dataset.kukaPostingTab;
|
|
activate(submenu, true, new URL(tab.href, window.location.origin).href);
|
|
tab.focus({ preventScroll: true });
|
|
});
|
|
|
|
nav.addEventListener('keydown', (event) => {
|
|
if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
const currentIndex = Math.max(0, tabs.findIndex((tab) => tab.tabIndex === 0));
|
|
let nextIndex = currentIndex;
|
|
if (event.key === 'ArrowLeft') {
|
|
nextIndex = (currentIndex - 1 + tabs.length) % tabs.length;
|
|
} else if (event.key === 'ArrowRight') {
|
|
nextIndex = (currentIndex + 1) % tabs.length;
|
|
} else if (event.key === 'Home') {
|
|
nextIndex = 0;
|
|
} else if (event.key === 'End') {
|
|
nextIndex = tabs.length - 1;
|
|
}
|
|
|
|
const nextTab = tabs[nextIndex];
|
|
activate(nextTab.dataset.kukaPostingTab, true, new URL(nextTab.href, window.location.origin).href);
|
|
nextTab.focus({ preventScroll: true });
|
|
});
|
|
|
|
window.addEventListener('popstate', () => {
|
|
if (!window.location.pathname.endsWith('/posting-data/kuka-basic-data')) {
|
|
return;
|
|
}
|
|
|
|
activate(currentSubmenu());
|
|
});
|
|
|
|
activate(currentSubmenu());
|
|
});
|
|
</script>
|