Spaces:
Running
// src/Sidebar.js
Browse filesimport React from 'react';
export default function Sidebar({ darkMode, setDarkMode }) {
const sidebarStyle = {
width: '220px',
minHeight: '100vh',
backgroundColor: darkMode ? '#1a1a1a' : '#f0f0f0',
color: darkMode ? '#fff' : '#222',
display: 'flex',
flexDirection: 'column',
padding: '1.5rem',
boxShadow: darkMode
? '2px 0 8px rgba(0,0,0,0.6)'
: '2px 0 8px rgba(0,0,0,0.1)',
transition: 'all 0.3s ease',
position: 'fixed',
top: 0,
left: 0,
zIndex: 1000,
};
const buttonStyle = {
backgroundColor: darkMode ? '#1e88e5' : '#0078d4',
color: '#fff',
border: 'none',
padding: '0.5rem 1rem',
borderRadius: '6px',
cursor: 'pointer',
marginTop: 'auto',
transition: 'background 0.2s ease',
};
const linkStyle = {
padding: '0.5rem 0',
marginBottom: '0.5rem',
cursor: 'pointer',
borderRadius: '4px',
transition: 'background 0.2s ease',
};
return (
<div style={sidebarStyle}>
<h2 style={{ marginBottom: '1.5rem' }}>MLTX Menu</h2>
<div style={linkStyle}>Dashboard</div>
<div style={linkStyle}>Orders</div>
<div style={linkStyle}>Settings</div>
<div style={linkStyle}>Profile</div>
<button style={buttonStyle} onClick={() => setDarkMode(!darkMode)}>
Toggle {darkMode ? 'Light' : 'Dark'} Mode
</button>
</div>
);
}import Sidebar from './Sidebar';
export default function App() {
const [darkMode, setDarkMode] = useState(false);
// ... rest of your state
return (
<div style={{ display: 'flex' }}>
<Sidebar darkMode={darkMode} setDarkMode={setDarkMode} />
<div style={{ marginLeft: '220px', flex: 1, padding: '2rem' }}>
{/* Rest of your App content here */}
</div>
</div>
);
}
import Sidebar from './Sidebar';
export default function App() {
const [darkMode, setDarkMode] = useState(false);
// ... rest of your state
return (
<div style={{ display: 'flex' }}>
<Sidebar darkMode={darkMode} setDarkMode={setDarkMode} />
<div style={{ marginLeft: '220px', flex: 1, padding: '2rem' }}>
{/* Rest of your App content here */}
</div>
</div>
);
}
- components/sidebar.js +51 -39
- orders.html +22 -0
- profile.html +22 -0
- settings.html +22 -0
|
@@ -5,17 +5,27 @@ class CustomSidebar extends HTMLElement {
|
|
| 5 |
}
|
| 6 |
|
| 7 |
connectedCallback() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
this.render();
|
| 9 |
-
this.setupEventListeners();
|
| 10 |
}
|
| 11 |
|
| 12 |
render() {
|
| 13 |
const backgroundColor = this.darkMode ? '#1a1a1a' : '#f0f0f0';
|
| 14 |
const textColor = this.darkMode ? '#fff' : '#222';
|
| 15 |
-
const shadowColor = this.darkMode ? 'rgba(0,0,0,0.6)' : 'rgba(0,0,0,0.1)';
|
| 16 |
const buttonColor = this.darkMode ? '#1e88e5' : '#0078d4';
|
|
|
|
| 17 |
|
| 18 |
-
this.attachShadow({ mode: 'open' });
|
| 19 |
this.shadowRoot.innerHTML = `
|
| 20 |
<style>
|
| 21 |
.sidebar {
|
|
@@ -33,12 +43,14 @@ class CustomSidebar extends HTMLElement {
|
|
| 33 |
left: 0;
|
| 34 |
z-index: 1000;
|
| 35 |
}
|
| 36 |
-
|
|
|
|
| 37 |
margin-bottom: 1.5rem;
|
| 38 |
font-size: 1.5rem;
|
| 39 |
-
font-weight:
|
| 40 |
}
|
| 41 |
-
|
|
|
|
| 42 |
padding: 0.5rem 0;
|
| 43 |
margin-bottom: 0.5rem;
|
| 44 |
cursor: pointer;
|
|
@@ -46,10 +58,12 @@ class CustomSidebar extends HTMLElement {
|
|
| 46 |
transition: background 0.2s ease;
|
| 47 |
padding-left: 0.5rem;
|
| 48 |
}
|
| 49 |
-
|
|
|
|
| 50 |
background-color: ${this.darkMode ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.05)'};
|
| 51 |
}
|
| 52 |
-
|
|
|
|
| 53 |
background-color: ${buttonColor};
|
| 54 |
color: #fff;
|
| 55 |
border: none;
|
|
@@ -58,50 +72,48 @@ class CustomSidebar extends HTMLElement {
|
|
| 58 |
cursor: pointer;
|
| 59 |
margin-top: auto;
|
| 60 |
transition: background 0.2s ease;
|
|
|
|
| 61 |
}
|
| 62 |
-
|
|
|
|
| 63 |
opacity: 0.9;
|
| 64 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</style>
|
|
|
|
| 66 |
<div class="sidebar">
|
| 67 |
<h2>MLTX Menu</h2>
|
| 68 |
|
| 69 |
-
<div class="
|
| 70 |
-
|
| 71 |
-
<
|
| 72 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
<button class="
|
| 75 |
Toggle ${this.darkMode ? 'Light' : 'Dark'} Mode
|
| 76 |
</button>
|
| 77 |
</div>
|
| 78 |
`;
|
| 79 |
}
|
| 80 |
-
|
| 81 |
-
setupEventListeners() {
|
| 82 |
-
this.shadowRoot.getElementById('darkModeToggle').addEventListener('click', () => {
|
| 83 |
-
this.darkMode = !this.darkMode;
|
| 84 |
-
this.render();
|
| 85 |
-
this.setupEventListeners();
|
| 86 |
-
|
| 87 |
-
// Dispatch custom event for other components
|
| 88 |
-
this.dispatchEvent(new CustomEvent('darkModeToggle', {
|
| 89 |
-
detail: { darkMode: this.darkMode },
|
| 90 |
-
bubbles: true
|
| 91 |
-
}));
|
| 92 |
-
});
|
| 93 |
-
|
| 94 |
-
// Add click listeners for menu items
|
| 95 |
-
this.shadowRoot.querySelectorAll('.menu-item').forEach(item => {
|
| 96 |
-
item.addEventListener('click', () => {
|
| 97 |
-
const page = item.getAttribute('data-page');
|
| 98 |
-
this.dispatchEvent(new CustomEvent('menuItemClick', {
|
| 99 |
-
detail: { page },
|
| 100 |
-
bubbles: true
|
| 101 |
-
}));
|
| 102 |
-
});
|
| 103 |
-
});
|
| 104 |
-
}
|
| 105 |
}
|
| 106 |
|
| 107 |
customElements.define('custom-sidebar', CustomSidebar);
|
|
|
|
| 5 |
}
|
| 6 |
|
| 7 |
connectedCallback() {
|
| 8 |
+
this.attachShadow({ mode: 'open' });
|
| 9 |
+
this.render();
|
| 10 |
+
|
| 11 |
+
// Add event listener for theme toggle
|
| 12 |
+
this.shadowRoot.querySelector('#themeToggle').addEventListener('click', () => {
|
| 13 |
+
this.toggleTheme();
|
| 14 |
+
});
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
toggleTheme() {
|
| 18 |
+
this.darkMode = !this.darkMode;
|
| 19 |
+
document.documentElement.setAttribute('data-theme', this.darkMode ? 'dark' : 'light');
|
| 20 |
this.render();
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
render() {
|
| 24 |
const backgroundColor = this.darkMode ? '#1a1a1a' : '#f0f0f0';
|
| 25 |
const textColor = this.darkMode ? '#fff' : '#222';
|
|
|
|
| 26 |
const buttonColor = this.darkMode ? '#1e88e5' : '#0078d4';
|
| 27 |
+
const shadowColor = this.darkMode ? 'rgba(0,0,0,0.6)' : 'rgba(0,0,0,0.1)';
|
| 28 |
|
|
|
|
| 29 |
this.shadowRoot.innerHTML = `
|
| 30 |
<style>
|
| 31 |
.sidebar {
|
|
|
|
| 43 |
left: 0;
|
| 44 |
z-index: 1000;
|
| 45 |
}
|
| 46 |
+
|
| 47 |
+
.sidebar h2 {
|
| 48 |
margin-bottom: 1.5rem;
|
| 49 |
font-size: 1.5rem;
|
| 50 |
+
font-weight: bold;
|
| 51 |
}
|
| 52 |
+
|
| 53 |
+
.sidebar-link {
|
| 54 |
padding: 0.5rem 0;
|
| 55 |
margin-bottom: 0.5rem;
|
| 56 |
cursor: pointer;
|
|
|
|
| 58 |
transition: background 0.2s ease;
|
| 59 |
padding-left: 0.5rem;
|
| 60 |
}
|
| 61 |
+
|
| 62 |
+
.sidebar-link:hover {
|
| 63 |
background-color: ${this.darkMode ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.05)'};
|
| 64 |
}
|
| 65 |
+
|
| 66 |
+
.theme-toggle {
|
| 67 |
background-color: ${buttonColor};
|
| 68 |
color: #fff;
|
| 69 |
border: none;
|
|
|
|
| 72 |
cursor: pointer;
|
| 73 |
margin-top: auto;
|
| 74 |
transition: background 0.2s ease;
|
| 75 |
+
font-size: 0.9rem;
|
| 76 |
}
|
| 77 |
+
|
| 78 |
+
.theme-toggle:hover {
|
| 79 |
opacity: 0.9;
|
| 80 |
}
|
| 81 |
+
|
| 82 |
+
@media (max-width: 768px) {
|
| 83 |
+
.sidebar {
|
| 84 |
+
width: 100%;
|
| 85 |
+
position: relative;
|
| 86 |
+
min-height: auto;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.main-content {
|
| 90 |
+
margin-left: 0 !important;
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
</style>
|
| 94 |
+
|
| 95 |
<div class="sidebar">
|
| 96 |
<h2>MLTX Menu</h2>
|
| 97 |
|
| 98 |
+
<div class="sidebar-link">
|
| 99 |
+
<a href="/" style="color: inherit; text-decoration: none; display: block;">Dashboard</a>
|
| 100 |
+
</div>
|
| 101 |
+
<div class="sidebar-link">
|
| 102 |
+
<a href="/orders.html" style="color: inherit; text-decoration: none; display: block;">Orders</a>
|
| 103 |
+
</div>
|
| 104 |
+
<div class="sidebar-link">
|
| 105 |
+
<a href="/settings.html" style="color: inherit; text-decoration: none; display: block;">Settings</a>
|
| 106 |
+
</div>
|
| 107 |
+
<div class="sidebar-link">
|
| 108 |
+
<a href="/profile.html" style="color: inherit; text-decoration: none; display: block;">Profile</a>
|
| 109 |
+
</div>
|
| 110 |
|
| 111 |
+
<button class="theme-toggle" id="themeToggle">
|
| 112 |
Toggle ${this.darkMode ? 'Light' : 'Dark'} Mode
|
| 113 |
</button>
|
| 114 |
</div>
|
| 115 |
`;
|
| 116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
}
|
| 118 |
|
| 119 |
customElements.define('custom-sidebar', CustomSidebar);
|
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Orders - MLTX Dashboard</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<custom-sidebar></custom-sidebar>
|
| 13 |
+
<div class="main-content" style="margin-left: 220px; padding: 2rem;">
|
| 14 |
+
<h1 class="text-3xl font-bold mb-6">Orders</h1>
|
| 15 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
| 16 |
+
<p class="text-gray-600 dark:text-gray-300">Order management system coming soon...</p>
|
| 17 |
+
</div>
|
| 18 |
+
</div>
|
| 19 |
+
<script src="components/sidebar.js"></script>
|
| 20 |
+
<script src="script.js"></script>
|
| 21 |
+
</body>
|
| 22 |
+
</html>
|
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Profile - MLTX Dashboard</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<custom-sidebar></custom-sidebar>
|
| 13 |
+
<div class="main-content" style="margin-left: 220px; padding: 2rem;">
|
| 14 |
+
<h1 class="text-3xl font-bold mb-6">Profile</h1>
|
| 15 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
| 16 |
+
<p class="text-gray-600 dark:text-gray-300">User profile management coming soon...</p>
|
| 17 |
+
</div>
|
| 18 |
+
</div>
|
| 19 |
+
<script src="components/sidebar.js"></script>
|
| 20 |
+
<script src="script.js"></script>
|
| 21 |
+
</body>
|
| 22 |
+
</html>
|
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Settings - MLTX Dashboard</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<custom-sidebar></custom-sidebar>
|
| 13 |
+
<div class="main-content" style="margin-left: 220px; padding: 2rem;">
|
| 14 |
+
<h1 class="text-3xl font-bold mb-6">Settings</h1>
|
| 15 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
| 16 |
+
<p class="text-gray-600 dark:text-gray-300">Settings panel coming soon...</p>
|
| 17 |
+
</div>
|
| 18 |
+
</div>
|
| 19 |
+
<script src="components/sidebar.js"></script>
|
| 20 |
+
<script src="script.js"></script>
|
| 21 |
+
</body>
|
| 22 |
+
</html>
|