nhance/app/Views/docs/docs_sidebar.php
2026-05-18 12:28:19 +05:30

176 lines
6.0 KiB
PHP

<?php
/**
* Docs Sidebar Partial
* app/Views/docs/partials/docs_sidebar.php
*
* Usage:
* <?= view('docs/partials/docs_sidebar', ['active_page' => 'installation']) ?>
*
* Variables:
* $active_page (string) — slug matching the 'id' on each nav item below
* $nav (array) — optional nav injected by DocsController
*
* To add a page: add an entry to the $nav array below.
* To add a section: add a new group with a 'label' key.
*/
$active_page = $active_page ?? '';
$nav = $nav ?? [
[
'label' => 'Getting Started',
'items' => [
['id' => 'introduction', 'label' => 'Introduction', 'url' => 'docs/introduction'],
['id' => 'installation', 'label' => 'Installation', 'url' => 'docs/installation'],
['id' => 'configuration', 'label' => 'Configuration', 'url' => 'docs/configuration'],
['id' => 'env-setup', 'label' => 'Environment Setup', 'url' => 'docs/env-setup'],
],
],
[
'label' => 'Architecture',
'items' => [
['id' => 'project-structure', 'label' => 'Project Structure', 'url' => 'docs/project-structure'],
['id' => 'routing', 'label' => 'Routing', 'url' => 'docs/routing'],
['id' => 'controllers', 'label' => 'Controllers', 'url' => 'docs/controllers'],
['id' => 'models', 'label' => 'Models', 'url' => 'docs/models'],
['id' => 'services', 'label' => 'Services', 'url' => 'docs/services'],
['id' => 'helpers', 'label' => 'Helpers', 'url' => 'docs/helpers'],
],
],
[
'label' => 'Features',
'items' => [
['id' => 'authentication', 'label' => 'Authentication', 'url' => 'docs/authentication'],
['id' => 'acl', 'label' => 'ACL / Access Control', 'url' => 'docs/acl'],
['id' => 'input-security', 'label' => 'Input Security Guard', 'url' => 'docs/input-security'],
['id' => 'file-uploads', 'label' => 'File Upload Guard', 'url' => 'docs/file-uploads'],
['id' => 'background-jobs', 'label' => 'Background Jobs', 'url' => 'docs/background-jobs'],
['id' => 'visit-onboard', 'label' => 'Visit onboard', 'url' => 'docs/visit-onboard'],
['id' => 'visit-offboard', 'label' => 'Visit offboard', 'url' => 'docs/visit-offboard'],
['id' => 'notifications', 'label' => 'Email / Notifications', 'url' => 'docs/notifications'],
],
],
[
'label' => 'API Reference',
'items' => [
['id' => 'endpoints', 'label' => 'Endpoints', 'url' => 'docs/endpoints'],
['id' => 'request-response','label' => 'Request / Response', 'url' => 'docs/request-response'],
['id' => 'error-codes', 'label' => 'Error Codes', 'url' => 'docs/error-codes'],
],
],
[
'label' => 'DevOps',
'items' => [
['id' => 'deployment', 'label' => 'Deployment', 'url' => 'docs/deployment'],
['id' => 'cicd', 'label' => 'CI/CD Pipeline', 'url' => 'docs/cicd'],
['id' => 's3-cloudfront', 'label' => 'S3 & CloudFront', 'url' => 'docs/s3-cloudfront'],
],
],
[
'label' => 'Reference',
'items' => [
['id' => 'changelog', 'label' => 'Changelog', 'url' => 'docs/changelog'],
['id' => 'contributing', 'label' => 'Contributing', 'url' => 'docs/contributing'],
],
],
];
?>
<!-- ═══════════════════════════════════════════
SIDEBAR
════════════════════════════════════════════ -->
<aside class="docs-sidebar">
<?php foreach ($nav as $section): ?>
<span class="docs-sidebar__label">
<?= esc($section['label']) ?>
</span>
<?php foreach ($section['items'] as $item):
$is_active = ($item['id'] === $active_page);
?>
<a
href="<?= base_url($item['url']) ?>"
class="docs-sidebar__link <?= $is_active ? 'is-active' : '' ?>"
>
<span class="docs-sidebar__dot"></span>
<?= esc($item['label']) ?>
</a>
<?php endforeach; ?>
<?php endforeach; ?>
</aside>
<style>
/* ─── SIDEBAR ────────────────────────────── */
.docs-sidebar {
width : var(--sidebar-w);
min-width : var(--sidebar-w);
border-right: 1px solid var(--border);
padding : 24px 0 48px;
position : sticky;
top : var(--topbar-h);
height : calc(100vh - var(--topbar-h));
overflow-y : auto;
background : var(--bg);
flex-shrink: 0;
}
/* Thin scrollbar */
.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.docs-sidebar__label {
display : block;
font-size : 11px;
font-weight : 600;
letter-spacing: 0.07em;
text-transform: uppercase;
color : var(--muted);
padding : 0 20px 6px;
margin-top : 20px;
}
/* Remove top margin from first label */
.docs-sidebar__label:first-child { margin-top: 0; }
.docs-sidebar__link {
display : flex;
align-items : center;
gap : 8px;
padding : 6px 20px;
font-size : 13.5px;
color : var(--text);
text-decoration: none;
border-left : 2px solid transparent;
transition : background 0.1s, color 0.1s;
}
.docs-sidebar__link:hover {
background: var(--bg2);
color : var(--accent);
}
.docs-sidebar__link.is-active {
background : var(--accent-bg);
color : var(--accent);
font-weight : 500;
border-left-color: var(--accent);
}
.docs-sidebar__dot {
width : 5px;
height : 5px;
border-radius: 50%;
background : var(--border);
flex-shrink : 0;
}
.docs-sidebar__link.is-active .docs-sidebar__dot {
background: var(--accent);
}
</style>