- shared-bottom-nav.js: 네비 HTML 동적 생성 + 현재 경로 active 자동 판별 - tbm-mobile.html: 기존 네비 HTML 제거 → 스크립트 로드 - report-create-mobile, my-vacation-info, dashboard-new: 네비 추가 - 홈 → dashboard-new.html, 작업보고 → report-create-mobile.html Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.8 KiB
JavaScript
40 lines
1.8 KiB
JavaScript
/**
|
|
* shared-bottom-nav.js — 하단 네비게이션 공유 컴포넌트
|
|
* 각 페이지에서 <script src="/static/js/shared-bottom-nav.js"></script> 로드하면 자동 생성
|
|
*/
|
|
(function() {
|
|
var SVG_ATTR = 'viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';
|
|
var NAV_ITEMS = [
|
|
{
|
|
href: '/pages/dashboard-new.html',
|
|
label: '홈',
|
|
icon: '<svg ' + SVG_ATTR + '><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>'
|
|
},
|
|
{
|
|
href: '/pages/work/tbm-mobile.html',
|
|
label: 'TBM',
|
|
icon: '<svg ' + SVG_ATTR + '><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>'
|
|
},
|
|
{
|
|
href: '/pages/work/report-create-mobile.html',
|
|
label: '작업보고',
|
|
icon: '<svg ' + SVG_ATTR + '><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>'
|
|
},
|
|
{
|
|
href: '/pages/attendance/my-vacation-info.html',
|
|
label: '연차관리',
|
|
icon: '<svg ' + SVG_ATTR + '><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/><path d="M9 16l2 2 4-4"/></svg>'
|
|
}
|
|
];
|
|
|
|
var currentPath = location.pathname;
|
|
var nav = document.createElement('nav');
|
|
nav.className = 'm-bottom-nav';
|
|
nav.innerHTML = NAV_ITEMS.map(function(item) {
|
|
var active = currentPath === item.href ? ' active' : '';
|
|
return '<a href="' + item.href + '" class="m-nav-item' + active + '">'
|
|
+ item.icon + '<span class="m-nav-label">' + item.label + '</span></a>';
|
|
}).join('');
|
|
document.body.appendChild(nav);
|
|
})();
|