Add component: Sidebar Menu
#4
by
elismasilva - opened
- components/sidebar-menu.json +141 -0
- manifest.json +12 -0
components/sidebar-menu.json
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "sidebar-menu",
|
| 3 |
+
"name": "Sidebar Menu",
|
| 4 |
+
"description": "An elegant sidebar menu for complex Gradio apps like dashboards and AI tools, offering dynamic routing, collapsible groups, and full theme support built entirely with gr.HTML",
|
| 5 |
+
"author": "elismasilva",
|
| 6 |
+
"tags": [
|
| 7 |
+
"menu",
|
| 8 |
+
"sidebar",
|
| 9 |
+
"dashboard"
|
| 10 |
+
],
|
| 11 |
+
"html_template": "\n <div class=\"sidebar ${position} ${open ? 'open' : ''}\" style=\"width: ${width}px; ${position}: -${width}px;\">\n <button class=\"toggle-button\" aria-label=\"Toggle Sidebar\">\n <i data-lucide=\"chevron-right\" class=\"toggle-icon\"></i>\n </button>\n \n <div class=\"sidebar-content\">\n <div class=\"sidebar-wrapper\">\n ${menu_data.map(item => {\n if (item.type === 'group') {\n return `\n <div class=\"menu-group\">\n <div class=\"group-header\">\n <div class=\"header-left\">\n <i data-lucide=\"${item.icon}\" class=\"icon\" style=\"color: ${item.color || '#a9b1d6'};\"></i> \n <span class=\"label\">${item.label}</span>\n </div>\n <i data-lucide=\"chevron-down\" class=\"arrow icon\"></i>\n </div>\n <div class=\"group-children\">\n ${item.children.map(child => `\n <div class=\"menu-item ${value === child.id ? 'active' : ''}\" data-id=\"${child.id}\">\n <i data-lucide=\"${child.icon}\" class=\"icon\" style=\"color: ${child.color || '#a9b1d6'};\"></i>\n <span class=\"label\">${child.label}</span>\n </div>\n `).join('')}\n </div>\n </div>`;\n } else {\n return `\n <div class=\"menu-item ${value === item.id ? 'active' : ''}\" data-id=\"${item.id}\">\n <i data-lucide=\"${item.icon}\" class=\"icon\" style=\"color: ${item.color || '#a9b1d6'};\"></i>\n <span class=\"label\">${item.label}</span>\n </div>`;\n }\n }).join('')}\n </div>\n </div>\n </div>\n ",
|
| 12 |
+
"css_template": "\n .sidebar {\n display: flex;\n flex-direction: column;\n position: fixed;\n top: 0;\n height: 100%;\n background-color: var(--background-fill-secondary);\n transform: translateX(0%);\n z-index: 1000;\n transition: transform 0.3s ease-in-out;\n border-right: 1px solid var(--border-color-primary); \n color: var(--body-text-color);\n font-family: var(--font-sans-serif); \n }\n\n .sidebar.open.left {\n transform: translateX(100%);\n }\n\n .sidebar.open.right {\n transform: translateX(-100%);\n }\n\n .toggle-button {\n position: absolute;\n top: 20px;\n background: var(--background-fill-secondary); \n border: 1px solid var(--border-color-primary); \n cursor: pointer;\n padding: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 32px;\n z-index: 1001;\n transition: all 0.3s ease;\n border-radius: 0; \n }\n .toggle-button * {\n pointer-events: none;\n }\n .toggle-button:hover {\n background: var(--background-fill-primary); \n border-color: var(--color-accent); \n }\n\n .toggle-icon {\n width: 20px;\n height: 20px;\n color: var(--body-text-color-subdued);\n transition: transform 0.3s ease-in-out;\n stroke-width: 2.5; \n }\n\n .sidebar.open .toggle-icon {\n transform: rotate(180deg);\n }\n\n .sidebar.left .toggle-button {\n left: 100%;\n border-radius: 0 8px 8px 0;\n }\n\n .sidebar.right .toggle-button {\n right: 100%;\n border-radius: 8px 0 0 8px;\n }\n\n .sidebar-content {\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n }\n\n .sidebar-content::-webkit-scrollbar {\n width: 6px;\n }\n\n .sidebar-content::-webkit-scrollbar-thumb {\n background: var(--border-color-primary);\n border-radius: 10px;\n }\n\n .sidebar-wrapper {\n font-family: 'Inter', sans-serif;\n padding: 20px 15px;\n }\n\n .menu-item {\n display: flex;\n align-items: center;\n padding: 12px 15px;\n margin-bottom: 4px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n }\n\n .menu-item:hover {\n background-color: var(--background-fill-primary);\n color: var(--body-text-color)\n }\n\n .menu-item.active {\n background-color: var(--color-accent) !important;\n color: white !important;\n }\n\n .group-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 15px;\n margin-bottom: 4px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n color: var(--body-text-color);\n ;\n transition: background-color 0.2s;\n }\n\n .group-header:hover {\n background-color: var(--background-fill-primary);\n }\n\n .header-left {\n display: flex;\n align-items: center;\n }\n\n .group-children {\n display: none;\n padding-left: 15px;\n margin-top: 4px;\n }\n\n .icon {\n margin-right: 12px;\n width: 18px;\n height: 18px;\n stroke: currentColor;\n stroke-width: 2.2;\n color: inherit;\n }\n\n .toggle-icon {\n width: 20px;\n height: 20px;\n color: var(--body-text-color-subdued);\n transition: transform 0.3s ease-in-out;\n stroke-width: 2.5;\n }\n\n .arrow {\n width: 14px;\n height: 14px;\n transition: transform 0.3s ease;\n color: var(--body-text-color-subdued);\n margin-right: 0;\n }\n\n @media (max-width: 768px) {\n .sidebar {\n width: 100vw !important;\n }\n\n .sidebar.left {\n left: -100vw !important;\n }\n\n .sidebar.right {\n right: -100vw !important;\n }\n }\n ",
|
| 13 |
+
"js_on_load": "\n let openFolders = new Set();\n\n function initLucide(retries = 8, delay = 200) {\n if (window.lucide) {\n window.lucide.createIcons();\n element.querySelectorAll('i[data-lucide]').forEach(i => {\n const svg = i.querySelector('svg');\n if (svg) {\n let desiredColor = i.style.color || getComputedStyle(i).color;\n if (desiredColor && \n desiredColor !== 'rgb(0,0,0)' && desiredColor !== '#000000' &&\n desiredColor !== 'rgb(255,255,255)' && desiredColor !== '#ffffff') {\n svg.style.color = desiredColor;\n const shapes = svg.querySelectorAll('path, line, polyline, circle, rect, polygon');\n shapes.forEach(shape => {\n shape.setAttribute('stroke', desiredColor);\n shape.style.stroke = desiredColor + ' !important';\n });\n if (svg.hasAttribute('fill') && svg.getAttribute('fill') === 'currentColor') {\n svg.setAttribute('fill', desiredColor);\n }\n svg.querySelectorAll('[fill=\"currentColor\"]').forEach(el => {\n el.setAttribute('fill', desiredColor);\n });\n }\n }\n });\n } else if (retries > 0) {\n setTimeout(() => initLucide(retries - 1, delay), delay);\n }\n }\n\n function applyFolderStates() {\n element.querySelectorAll('.group-header').forEach(header => {\n const label = header.querySelector('.label')?.innerText.trim();\n if (!label) return;\n const children = header.nextElementSibling;\n const arrow = header.querySelector('.arrow');\n if (children && arrow) {\n const isOpen = openFolders.has(label);\n children.style.display = isOpen ? 'block' : 'none';\n arrow.style.transform = isOpen ? 'rotate(180deg)' : 'rotate(0deg)';\n }\n });\n }\n \n initLucide();\n applyFolderStates();\n\n const observer = new MutationObserver(() => {\n setTimeout(() => {\n applyFolderStates();\n initLucide();\n }, 50);\n });\n\n observer.observe(element, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true\n });\n\n element.addEventListener('click', (e) => {\n if (e.target.closest('.toggle-button')) {\n const sidebar = element.querySelector('.sidebar');\n sidebar.classList.toggle('open');\n trigger(sidebar.classList.contains('open') ? 'expand' : 'collapse');\n return;\n }\n\n const header = e.target.closest('.group-header');\n if (header) {\n const label = header.querySelector('.label')?.innerText.trim();\n if (label) {\n if (openFolders.has(label)) openFolders.delete(label);\n else openFolders.add(label);\n }\n applyFolderStates();\n return;\n }\n\n const item = e.target.closest('.menu-item');\n if (item) {\n props.value = item.dataset.id;\n trigger('change');\n\n if (window.innerWidth <= 768) {\n element.querySelector('.sidebar')?.classList.remove('open');\n }\n\n setTimeout(() => {\n applyFolderStates();\n initLucide();\n }, 0);\n }\n });\n ",
|
| 14 |
+
"default_props": {
|
| 15 |
+
"value": "dash",
|
| 16 |
+
"menu_data": [
|
| 17 |
+
{
|
| 18 |
+
"type": "item",
|
| 19 |
+
"id": "dash",
|
| 20 |
+
"label": "Dashboard",
|
| 21 |
+
"icon": "layout-dashboard",
|
| 22 |
+
"color": "#10b981"
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"type": "item",
|
| 26 |
+
"id": "gallery",
|
| 27 |
+
"label": "Community Gallery",
|
| 28 |
+
"icon": "image",
|
| 29 |
+
"color": "#8b5cf6"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"type": "item",
|
| 33 |
+
"id": "my_images",
|
| 34 |
+
"label": "My Images",
|
| 35 |
+
"icon": "images",
|
| 36 |
+
"color": "#f59e0b"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"type": "item",
|
| 40 |
+
"id": "my_models",
|
| 41 |
+
"label": "My Custom Models",
|
| 42 |
+
"icon": "palette",
|
| 43 |
+
"color": "#10b981"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"type": "group",
|
| 47 |
+
"label": "Create",
|
| 48 |
+
"icon": "folder",
|
| 49 |
+
"color": "#f43f5e",
|
| 50 |
+
"children": [
|
| 51 |
+
{
|
| 52 |
+
"id": "create_new",
|
| 53 |
+
"label": "New Project",
|
| 54 |
+
"icon": "plus-circle",
|
| 55 |
+
"color": "#8f95b2"
|
| 56 |
+
}
|
| 57 |
+
]
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"type": "group",
|
| 61 |
+
"label": "Enhance",
|
| 62 |
+
"icon": "folder",
|
| 63 |
+
"color": "#f43f5e",
|
| 64 |
+
"children": [
|
| 65 |
+
{
|
| 66 |
+
"id": "upscale",
|
| 67 |
+
"label": "Upscale Image",
|
| 68 |
+
"icon": "zoom-in",
|
| 69 |
+
"color": "#8f95b2"
|
| 70 |
+
}
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"type": "group",
|
| 75 |
+
"label": "Analyze",
|
| 76 |
+
"icon": "folder",
|
| 77 |
+
"color": "#f43f5e",
|
| 78 |
+
"children": [
|
| 79 |
+
{
|
| 80 |
+
"id": "data_analysis",
|
| 81 |
+
"label": "Data Analysis",
|
| 82 |
+
"icon": "bar-chart",
|
| 83 |
+
"color": "#8f95b2"
|
| 84 |
+
}
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"type": "group",
|
| 89 |
+
"label": "Train",
|
| 90 |
+
"icon": "folder",
|
| 91 |
+
"color": "#f43f5e",
|
| 92 |
+
"children": [
|
| 93 |
+
{
|
| 94 |
+
"id": "flux_train",
|
| 95 |
+
"label": "FLUX Model Trainer",
|
| 96 |
+
"icon": "dumbbell",
|
| 97 |
+
"color": "#3b82f6"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"id": "flux_creator",
|
| 101 |
+
"label": "Flux Image Creator",
|
| 102 |
+
"icon": "pen-tool",
|
| 103 |
+
"color": "#10b981"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"id": "sdxl_train",
|
| 107 |
+
"label": "SDXL Model Trainer",
|
| 108 |
+
"icon": "dumbbell",
|
| 109 |
+
"color": "#6366f1"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"id": "sdxl_creator",
|
| 113 |
+
"label": "SDXL Image Creator",
|
| 114 |
+
"icon": "brush",
|
| 115 |
+
"color": "#a855f7"
|
| 116 |
+
}
|
| 117 |
+
]
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"type": "group",
|
| 121 |
+
"label": "Experiment",
|
| 122 |
+
"icon": "folder",
|
| 123 |
+
"color": "#f43f5e",
|
| 124 |
+
"children": [
|
| 125 |
+
{
|
| 126 |
+
"id": "labs",
|
| 127 |
+
"label": "Labs",
|
| 128 |
+
"icon": "flask-conical",
|
| 129 |
+
"color": "#8f95b2"
|
| 130 |
+
}
|
| 131 |
+
]
|
| 132 |
+
}
|
| 133 |
+
],
|
| 134 |
+
"open": true,
|
| 135 |
+
"position": "left",
|
| 136 |
+
"width": 300
|
| 137 |
+
},
|
| 138 |
+
"python_code": "class SidebarMenu(gr.HTML): \n def __init__(\n self, menu_data, value=None, open=True, position=\"right\", width=300, **kwargs\n ):\n\n html_template = \"\"\"\n <div class=\"sidebar ${position} ${open ? 'open' : ''}\" style=\"width: ${width}px; ${position}: -${width}px;\">\n <button class=\"toggle-button\" aria-label=\"Toggle Sidebar\">\n <i data-lucide=\"chevron-right\" class=\"toggle-icon\"></i>\n </button>\n\n <div class=\"sidebar-content\">\n <div class=\"sidebar-wrapper\">\n ${menu_data.map(item => {\n if (item.type === 'group') {\n return `\n <div class=\"menu-group\">\n <div class=\"group-header\">\n <div class=\"header-left\">\n <i data-lucide=\"${item.icon}\" class=\"icon\" style=\"color: ${item.color || '#a9b1d6'};\"></i> \n <span class=\"label\">${item.label}</span>\n </div>\n <i data-lucide=\"chevron-down\" class=\"arrow icon\"></i>\n </div>\n <div class=\"group-children\">\n ${item.children.map(child => `\n <div class=\"menu-item ${value === child.id ? 'active' : ''}\" data-id=\"${child.id}\">\n <i data-lucide=\"${child.icon}\" class=\"icon\" style=\"color: ${child.color || '#a9b1d6'};\"></i>\n <span class=\"label\">${child.label}</span>\n </div>\n `).join('')}\n </div>\n </div>`;\n } else {\n return `\n <div class=\"menu-item ${value === item.id ? 'active' : ''}\" data-id=\"${item.id}\">\n <i data-lucide=\"${item.icon}\" class=\"icon\" style=\"color: ${item.color || '#a9b1d6'};\"></i>\n <span class=\"label\">${item.label}</span>\n </div>`;\n }\n }).join('')}\n </div>\n </div>\n </div>\n \"\"\"\n\n css_template = \"\"\"\n .sidebar {\n display: flex;\n flex-direction: column;\n position: fixed;\n top: 0;\n height: 100%;\n background-color: var(--background-fill-secondary);\n transform: translateX(0%);\n z-index: 1000;\n transition: transform 0.3s ease-in-out;\n border-right: 1px solid var(--border-color-primary); \n color: var(--body-text-color);\n font-family: var(--font-sans-serif); \n }\n\n .sidebar.open.left {\n transform: translateX(100%);\n }\n\n .sidebar.open.right {\n transform: translateX(-100%);\n }\n\n .toggle-button {\n position: absolute;\n top: 20px;\n background: var(--background-fill-secondary); \n border: 1px solid var(--border-color-primary); \n cursor: pointer;\n padding: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 32px;\n z-index: 1001;\n transition: all 0.3s ease;\n border-radius: 0; \n }\n .toggle-button * {\n pointer-events: none;\n }\n .toggle-button:hover {\n background: var(--background-fill-primary); \n border-color: var(--color-accent); \n }\n\n .toggle-icon {\n width: 20px;\n height: 20px;\n color: var(--body-text-color-subdued);\n transition: transform 0.3s ease-in-out;\n stroke-width: 2.5; \n }\n\n .sidebar.open .toggle-icon {\n transform: rotate(180deg);\n }\n\n .sidebar.left .toggle-button {\n left: 100%;\n border-radius: 0 8px 8px 0;\n }\n\n .sidebar.right .toggle-button {\n right: 100%;\n border-radius: 8px 0 0 8px;\n }\n\n .sidebar-content {\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n }\n\n .sidebar-content::-webkit-scrollbar {\n width: 6px;\n }\n\n .sidebar-content::-webkit-scrollbar-thumb {\n background: var(--border-color-primary);\n border-radius: 10px;\n }\n\n .sidebar-wrapper {\n font-family: 'Inter', sans-serif;\n padding: 20px 15px;\n }\n\n .menu-item {\n display: flex;\n align-items: center;\n padding: 12px 15px;\n margin-bottom: 4px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n }\n\n .menu-item:hover {\n background-color: var(--background-fill-primary);\n color: var(--body-text-color)\n }\n\n .menu-item.active {\n background-color: var(--color-accent) !important;\n color: white !important;\n }\n\n .group-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 15px;\n margin-bottom: 4px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n color: var(--body-text-color);\n ;\n transition: background-color 0.2s;\n }\n\n .group-header:hover {\n background-color: var(--background-fill-primary);\n }\n\n .header-left {\n display: flex;\n align-items: center;\n }\n\n .group-children {\n display: none;\n padding-left: 15px;\n margin-top: 4px;\n }\n\n .icon {\n margin-right: 12px;\n width: 18px;\n height: 18px;\n stroke: currentColor;\n stroke-width: 2.2;\n color: inherit;\n }\n\n .toggle-icon {\n width: 20px;\n height: 20px;\n color: var(--body-text-color-subdued);\n transition: transform 0.3s ease-in-out;\n stroke-width: 2.5;\n }\n\n .arrow {\n width: 14px;\n height: 14px;\n transition: transform 0.3s ease;\n color: var(--body-text-color-subdued);\n margin-right: 0;\n }\n\n @media (max-width: 768px) {\n .sidebar {\n width: 100vw !important;\n }\n\n .sidebar.left {\n left: -100vw !important;\n }\n\n .sidebar.right {\n right: -100vw !important;\n }\n }\n \"\"\"\n\n js_on_load = \"\"\"\n let openFolders = new Set();\n\n function initLucide(retries = 8, delay = 200) {\n if (window.lucide) {\n window.lucide.createIcons();\n element.querySelectorAll('i[data-lucide]').forEach(i => {\n const svg = i.querySelector('svg');\n if (svg) {\n let desiredColor = i.style.color || getComputedStyle(i).color;\n if (desiredColor && \n desiredColor !== 'rgb(0,0,0)' && desiredColor !== '#000000' &&\n desiredColor !== 'rgb(255,255,255)' && desiredColor !== '#ffffff') {\n svg.style.color = desiredColor;\n const shapes = svg.querySelectorAll('path, line, polyline, circle, rect, polygon');\n shapes.forEach(shape => {\n shape.setAttribute('stroke', desiredColor);\n shape.style.stroke = desiredColor + ' !important';\n });\n if (svg.hasAttribute('fill') && svg.getAttribute('fill') === 'currentColor') {\n svg.setAttribute('fill', desiredColor);\n }\n svg.querySelectorAll('[fill=\"currentColor\"]').forEach(el => {\n el.setAttribute('fill', desiredColor);\n });\n }\n }\n });\n } else if (retries > 0) {\n setTimeout(() => initLucide(retries - 1, delay), delay);\n }\n }\n\n function applyFolderStates() {\n element.querySelectorAll('.group-header').forEach(header => {\n const label = header.querySelector('.label')?.innerText.trim();\n if (!label) return;\n const children = header.nextElementSibling;\n const arrow = header.querySelector('.arrow');\n if (children && arrow) {\n const isOpen = openFolders.has(label);\n children.style.display = isOpen ? 'block' : 'none';\n arrow.style.transform = isOpen ? 'rotate(180deg)' : 'rotate(0deg)';\n }\n });\n }\n\n initLucide();\n applyFolderStates();\n\n const observer = new MutationObserver(() => {\n setTimeout(() => {\n applyFolderStates();\n initLucide();\n }, 50);\n });\n\n observer.observe(element, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true\n });\n\n element.addEventListener('click', (e) => {\n if (e.target.closest('.toggle-button')) {\n const sidebar = element.querySelector('.sidebar');\n sidebar.classList.toggle('open');\n trigger(sidebar.classList.contains('open') ? 'expand' : 'collapse');\n return;\n }\n\n const header = e.target.closest('.group-header');\n if (header) {\n const label = header.querySelector('.label')?.innerText.trim();\n if (label) {\n if (openFolders.has(label)) openFolders.delete(label);\n else openFolders.add(label);\n }\n applyFolderStates();\n return;\n }\n\n const item = e.target.closest('.menu-item');\n if (item) {\n props.value = item.dataset.id;\n trigger('change');\n\n if (window.innerWidth <= 768) {\n element.querySelector('.sidebar')?.classList.remove('open');\n }\n\n setTimeout(() => {\n applyFolderStates();\n initLucide();\n }, 0);\n }\n });\n \"\"\"\n\n super().__init__(\n value=value,\n menu_data=menu_data,\n open=open,\n position=position,\n width=width,\n html_template=html_template,\n css_template=css_template,\n apply_default_css=False,\n js_on_load=js_on_load,\n **kwargs\n )\n\n def api_info(self):\n return {\"type\": \"string\"}\n",
|
| 139 |
+
"head": "<script src=\"https://unpkg.com/lucide@latest\"></script>",
|
| 140 |
+
"repo_url": "https://huggingface.co/spaces/elismasilva/gradio_sidebar_menu"
|
| 141 |
+
}
|
manifest.json
CHANGED
|
@@ -157,5 +157,17 @@
|
|
| 157 |
"description": "",
|
| 158 |
"author": "abidlabs",
|
| 159 |
"tags": []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
}
|
| 161 |
]
|
|
|
|
| 157 |
"description": "",
|
| 158 |
"author": "abidlabs",
|
| 159 |
"tags": []
|
| 160 |
+
},
|
| 161 |
+
{
|
| 162 |
+
"id": "sidebar-menu",
|
| 163 |
+
"name": "Sidebar Menu",
|
| 164 |
+
"description": "An elegant sidebar menu for complex Gradio apps like dashboards and AI tools, offering dynamic routing, collapsible groups, and full theme support built entirely with gr.HTML",
|
| 165 |
+
"author": "elismasilva",
|
| 166 |
+
"tags": [
|
| 167 |
+
"menu",
|
| 168 |
+
"sidebar",
|
| 169 |
+
"dashboard"
|
| 170 |
+
],
|
| 171 |
+
"repo_url": "https://huggingface.co/spaces/elismasilva/gradio_sidebar_menu"
|
| 172 |
}
|
| 173 |
]
|