css refactor

This commit is contained in:
2026-02-19 18:24:36 +03:00
parent 4de5b22d57
commit fdcbe32dfa
45 changed files with 1798 additions and 1857 deletions

View File

@@ -30,7 +30,7 @@
{
id: "dashboards",
label: $t.nav?.dashboards || "DASHBOARDS",
icon: "M3 3h18v18H3V3zm16 16V5H5v14h14z", // Grid icon
icon: "M3 3h18v18H3V3zm16 16V5H5v14h14z",
path: "/dashboards",
subItems: [
{ label: $t.nav?.overview || "Overview", path: "/dashboards" },
@@ -39,7 +39,7 @@
{
id: "datasets",
label: $t.nav?.datasets || "DATASETS",
icon: "M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h6v2H7v-2z", // List icon
icon: "M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h6v2H7v-2z",
path: "/datasets",
subItems: [
{ label: $t.nav?.all_datasets || "All Datasets", path: "/datasets" },
@@ -48,7 +48,7 @@
{
id: "storage",
label: $t.nav?.storage || "STORAGE",
icon: "M4 4h16v16H4V4zm2 2v12h12V6H6zm2 2h8v2H8V8zm0 4h8v2H8v-2zm0 4h5v2H8v-2z", // Folder icon
icon: "M4 4h16v16H4V4zm2 2v12h12V6H6zm2 2h8v2H8V8zm0 4h8v2H8v-2zm0 4h5v2H8v-2z",
path: "/storage",
subItems: [
{ label: $t.nav?.backups || "Backups", path: "/storage/backups" },
@@ -61,7 +61,7 @@
{
id: "admin",
label: $t.nav?.admin || "ADMIN",
icon: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z", // User icon
icon: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z",
path: "/admin",
subItems: [
{ label: $t.nav?.admin_users || "Users", path: "/admin/users" },
@@ -75,7 +75,7 @@
let activeCategory = "dashboards";
let activeItem = "/dashboards";
let isMobileOpen = false;
let expandedCategories = new Set(["dashboards"]); // Track expanded categories
let expandedCategories = new Set(["dashboards"]);
// Subscribe to sidebar store
$: if ($sidebarStore) {
@@ -90,7 +90,7 @@
{
id: "dashboards",
label: $t.nav?.dashboards || "DASHBOARDS",
icon: "M3 3h18v18H3V3zm16 16V5H5v14h14z", // Grid icon
icon: "M3 3h18v18H3V3zm16 16V5H5v14h14z",
path: "/dashboards",
subItems: [
{ label: $t.nav?.overview || "Overview", path: "/dashboards" },
@@ -99,7 +99,7 @@
{
id: "datasets",
label: $t.nav?.datasets || "DATASETS",
icon: "M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h6v2H7v-2z", // List icon
icon: "M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h6v2H7v-2z",
path: "/datasets",
subItems: [
{ label: $t.nav?.all_datasets || "All Datasets", path: "/datasets" },
@@ -108,7 +108,7 @@
{
id: "storage",
label: $t.nav?.storage || "STORAGE",
icon: "M4 4h16v16H4V4zm2 2v12h12V6H6zm2 2h8v2H8V8zm0 4h8v2H8v-2zm0 4h5v2H8v-2z", // Folder icon
icon: "M4 4h16v16H4V4zm2 2v12h12V6H6zm2 2h8v2H8V8zm0 4h8v2H8v-2zm0 4h5v2H8v-2z",
path: "/storage",
subItems: [
{ label: $t.nav?.backups || "Backups", path: "/storage/backups" },
@@ -121,7 +121,7 @@
{
id: "admin",
label: $t.nav?.admin || "ADMIN",
icon: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z", // User icon
icon: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z",
path: "/admin",
subItems: [
{ label: $t.nav?.admin_users || "Users", path: "/admin/users" },
@@ -133,7 +133,6 @@
// Update active item when page changes
$: if ($page && $page.url.pathname !== activeItem) {
// Find matching category
const matched = categories.find((cat) =>
$page.url.pathname.startsWith(cat.path),
);
@@ -143,7 +142,6 @@
}
}
// Handle click on sidebar item
function handleItemClick(category) {
console.log(`[Sidebar][Action] Clicked category ${category.id}`);
setActiveItem(category.id, category.path);
@@ -153,7 +151,6 @@
}
}
// Handle click on category header to toggle expansion
function handleCategoryToggle(categoryId, event) {
event.stopPropagation();
@@ -173,28 +170,24 @@
} else {
expandedCategories.add(categoryId);
}
expandedCategories = expandedCategories; // Trigger reactivity
expandedCategories = expandedCategories;
}
// Handle click on sub-item
function handleSubItemClick(categoryId, path) {
console.log(`[Sidebar][Action] Clicked sub-item ${path}`);
setActiveItem(categoryId, path);
closeMobile();
// Force navigation if it's a link
if (browser) {
window.location.href = path;
}
}
// Handle toggle button click
function handleToggleClick(event) {
event.stopPropagation();
console.log("[Sidebar][Action] Toggle sidebar");
toggleSidebar();
}
// Handle mobile overlay click
function handleOverlayClick() {
console.log("[Sidebar][Action] Close mobile overlay");
closeMobile();
@@ -209,7 +202,7 @@
<!-- Mobile overlay (only on mobile) -->
{#if isMobileOpen}
<div
class="mobile-overlay"
class="fixed inset-0 bg-black/50 z-20 md:hidden"
on:click={handleOverlayClick}
on:keydown={(e) => e.key === "Escape" && handleOverlayClick()}
role="presentation"
@@ -218,12 +211,18 @@
<!-- Sidebar -->
<div
class="sidebar {isExpanded ? 'expanded' : 'collapsed'} {isMobileOpen
? 'mobile'
: 'mobile-hidden'}"
class="bg-white border-r border-gray-200 flex flex-col h-screen fixed left-0 top-0 z-30 transition-[width] duration-200 ease-in-out
{isExpanded ? 'w-sidebar' : 'w-sidebar-collapsed'}
{isMobileOpen
? 'translate-x-0 w-sidebar'
: '-translate-x-full md:translate-x-0'}"
>
<!-- Header (simplified, toggle moved to footer) -->
<div class="sidebar-header {isExpanded ? '' : 'collapsed'}">
<!-- Header -->
<div
class="flex items-center p-4 border-b border-gray-200 {isExpanded
? 'justify-between'
: 'justify-center'}"
>
{#if isExpanded}
<span class="font-semibold text-gray-800">Menu</span>
{:else}
@@ -232,13 +231,14 @@
</div>
<!-- Navigation items -->
<nav class="nav-section">
<nav class="flex-1 overflow-y-auto py-2">
{#each categories as category}
<div class="category">
<div>
<!-- Category Header -->
<div
class="category-header {activeCategory === category.id
? 'active'
class="flex items-center justify-between px-4 py-3 cursor-pointer transition-colors hover:bg-gray-100
{activeCategory === category.id
? 'bg-primary-light text-primary md:border-r-2 md:border-primary'
: ''}"
on:click={(e) => handleCategoryToggle(category.id, e)}
on:keydown={(e) =>
@@ -251,7 +251,7 @@
>
<div class="flex items-center">
<svg
class="nav-icon"
class="w-5 h-5 shrink-0"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
@@ -261,13 +261,17 @@
<path d={category.icon} />
</svg>
{#if isExpanded}
<span class="nav-label">{category.label}</span>
<span class="ml-3 text-sm font-medium truncate"
>{category.label}</span
>
{/if}
</div>
{#if isExpanded}
<svg
class="category-toggle {expandedCategories.has(category.id)
? 'expanded'
class="text-gray-400 transition-transform duration-200 {expandedCategories.has(
category.id,
)
? 'rotate-180'
: ''}"
xmlns="http://www.w3.org/2000/svg"
width="16"
@@ -284,10 +288,13 @@
<!-- Sub Items (only when expanded) -->
{#if isExpanded && expandedCategories.has(category.id)}
<div class="sub-items">
<div class="bg-gray-50 overflow-hidden transition-all duration-200">
{#each category.subItems as subItem}
<div
class="sub-item {activeItem === subItem.path ? 'active' : ''}"
class="flex items-center px-4 py-2 pl-12 cursor-pointer transition-colors text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900
{activeItem === subItem.path
? 'bg-primary-light text-primary'
: ''}"
on:click={() => handleSubItemClick(category.id, subItem.path)}
on:keydown={(e) =>
(e.key === "Enter" || e.key === " ") &&
@@ -306,8 +313,11 @@
<!-- Footer with Collapse button -->
{#if isExpanded}
<div class="sidebar-footer">
<button class="collapse-btn" on:click={handleToggleClick}>
<div class="border-t border-gray-200 p-4">
<button
class="flex items-center justify-center w-full px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
on:click={handleToggleClick}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
@@ -324,8 +334,12 @@
</button>
</div>
{:else}
<div class="sidebar-footer">
<button class="collapse-btn" on:click={handleToggleClick} aria-label="Expand sidebar">
<div class="border-t border-gray-200 p-4">
<button
class="flex items-center justify-center w-full px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
on:click={handleToggleClick}
aria-label="Expand sidebar"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
@@ -337,101 +351,10 @@
>
<path d="M9 18l6-6-6-6" />
</svg>
<span class="collapse-btn-text">Expand</span>
<span class="ml-2">Expand</span>
</button>
</div>
{/if}
</div>
<!-- [/DEF:Sidebar:Component] -->
<style>
.sidebar {
@apply bg-white border-r border-gray-200 flex flex-col h-screen fixed left-0 top-0 z-30;
transition: width 0.2s ease-in-out;
}
.sidebar.expanded {
width: 240px;
}
.sidebar.collapsed {
width: 64px;
}
.sidebar.mobile {
@apply translate-x-0;
width: 240px;
}
.sidebar.mobile-hidden {
@apply -translate-x-full md:translate-x-0;
}
.sidebar-header {
@apply flex items-center justify-between p-4 border-b border-gray-200;
}
.sidebar-header.collapsed {
@apply justify-center;
}
.nav-icon {
@apply w-5 h-5 flex-shrink-0;
}
.nav-label {
@apply ml-3 text-sm font-medium truncate;
}
.category-header {
@apply flex items-center justify-between px-4 py-3 cursor-pointer transition-colors hover:bg-gray-100;
}
.category-header.active {
@apply bg-blue-50 text-blue-600 md:border-r-2 md:border-blue-600;
}
.category-toggle {
@apply text-gray-400 transition-transform duration-200;
}
.category-toggle.expanded {
@apply rotate-180;
}
.sub-items {
@apply bg-gray-50 overflow-hidden transition-all duration-200;
}
.sub-item {
@apply flex items-center px-4 py-2 pl-12 cursor-pointer transition-colors text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900;
}
.sub-item.active {
@apply bg-blue-50 text-blue-600;
}
.sidebar-footer {
@apply border-t border-gray-200 p-4;
}
.collapse-btn {
@apply flex items-center justify-center w-full px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors;
}
.collapse-btn-text {
@apply ml-2;
}
/* Mobile overlay */
.mobile-overlay {
@apply fixed inset-0 bg-black bg-opacity-50 z-20;
}
@media (min-width: 768px) {
.mobile-overlay {
@apply hidden;
}
}
</style>