Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en" x-data="{ darkMode: false }" :class="{ 'dark': darkMode }">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Dashboard</title>
- <script src="https://cdn.tailwindcss.com"></script>
- <script src="https://unpkg.com/[email protected]/dist/cdn.min.js" defer></script>
- <style>
- .transition-all {
- transition: all 0.1s ease;
- }
- .rotate-180 {
- transform: rotate(180deg);
- }
- .sidebar-tooltip {
- position: absolute;
- left: 100%;
- top: 50%;
- transform: translateY(-50%);
- background-color: #1f2937;
- color: #fff;
- padding: 0.25rem 0.5rem;
- border-radius: 0.25rem;
- white-space: nowrap;
- font-size: 0.875rem;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.15s ease;
- }
- .group:hover .sidebar-tooltip {
- opacity: 1;
- }
- .dropdown-bubble {
- position: absolute;
- left: 100%;
- top: 0;
- background-color: #1f2937;
- color: #fff;
- border-radius: 0.25rem;
- padding: 0.5rem;
- white-space: nowrap;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.15s ease;
- }
- .group:hover .dropdown-bubble {
- opacity: 1;
- pointer-events: auto;
- }
- </style>
- <script>
- function dropdown(id) {
- return {
- isOpen: false,
- init() {
- this.$watch('activeDropdown', (value) => {
- this.isOpen = (value === id);
- });
- },
- toggle() {
- this.activeDropdown = (this.isOpen ? null : id);
- }
- }
- }
- </script>
- </head>
- <body class="bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 transition-colors relative" x-data="{
- sidebarOpen: window.innerWidth >= 768,
- activeDropdown: null,
- menu: [
- { name: 'Analytics', href: '/analytics' },
- { name: 'Products', dropdown: [
- { name: 'Sub Product 1', href: '/sub-product1' },
- { name: 'Sub Product 2', href: '/sub-product2' },
- { name: 'Sub Product 3', href: '/sub-product3' }
- ]
- },
- { name: 'Settings', dropdown: [
- { name: 'Profile', href: '/profile' },
- { name: 'Account', href: '/account' }
- ]
- },
- { name: 'Messages', href: '/messages' }
- ],
- signOut: { name: 'Sign Out', href: '/signout' }
- }">
- <div class="flex h-screen">
- <!-- Sidebar -->
- <aside class="bg-gray-100 dark:bg-gray-800 flex flex-col justify-between py-7 px-2 absolute inset-y-0 left-0 transform transition-all duration-100 ease-in-out z-50 md:relative"
- :class="sidebarOpen ? 'translate-x-0 w-64' : '-translate-x-full md:w-16 md:translate-x-0'">
- <div>
- <div class="flex justify-between items-center px-2">
- <div class="text-xl font-bold text-indigo-600 dark:text-indigo-400" x-show="sidebarOpen" x-transition>Business</div>
- <button @click="sidebarOpen = !sidebarOpen"
- class="focus:outline-none transform transition-transform duration-100"
- :class="{ 'rotate-180': !sidebarOpen }">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700 dark:text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
- </svg>
- </button>
- </div>
- <nav class="mt-10 space-y-2">
- <template x-for="(item, index) in menu" :key="index">
- <div>
- <!-- Regular Link -->
- <template x-if="!item.dropdown">
- <a :href="item.href" class="group relative flex items-center py-2 px-3 rounded hover:bg-gray-300 dark:hover:bg-gray-700 w-full transition-all duration-100"
- :class="!sidebarOpen ? 'md:justify-center' : ''">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 flex-shrink-0 md:mx-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
- </svg>
- <span x-show="sidebarOpen" x-transition class="ml-2 whitespace-nowrap" x-text="item.name"></span>
- <span class="sidebar-tooltip hidden md:block" x-show="!sidebarOpen" x-text="item.name"></span>
- </a>
- </template>
- <!-- Dropdown -->
- <template x-if="item.dropdown">
- <div x-data="dropdown(item.name)" x-init="init()" class="relative group">
- <button @click="toggle"
- class="flex items-center justify-between w-full py-2 px-3 rounded hover:bg-gray-300 dark:hover:bg-gray-700 transition-all duration-100"
- :class="!sidebarOpen ? 'md:justify-center' : ''">
- <div class="flex items-center">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 flex-shrink-0 md:mx-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7h18M3 12h18M3 17h18" />
- </svg>
- <span x-show="sidebarOpen" x-transition class="ml-2 whitespace-nowrap" x-text="item.name"></span>
- </div>
- <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 transform transition-transform duration-100"
- fill="none" viewBox="0 0 24 24" stroke="currentColor"
- :class="isOpen ? 'rotate-180' : ''" x-show="sidebarOpen">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
- </svg>
- </button>
- <div x-show="isOpen" x-collapse class="ml-6 border-l border-gray-300 dark:border-gray-600 pl-2 mt-1 space-y-1"
- x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0"
- x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-75"
- x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0">
- <template x-for="(subItem, subIndex) in item.dropdown" :key="subIndex">
- <a :href="subItem.href"
- class="block py-1 px-2 rounded hover:bg-gray-300 dark:hover:bg-gray-700 transition-all duration-100"
- x-text="subItem.name"></a>
- </template>
- </div>
- <div class="dropdown-bubble hidden md:block" x-show="!sidebarOpen">
- <template x-for="(subItem, subIndex) in item.dropdown" :key="subIndex">
- <a :href="subItem.href"
- class="block py-1 px-2 rounded hover:bg-gray-600"
- x-text="subItem.name"></a>
- </template>
- </div>
- </div>
- </template>
- </div>
- </template>
- </nav>
- </div>
- <div class="border-t border-gray-300 dark:border-gray-700 pt-4 px-2">
- <div class="flex items-center mb-2" x-show="sidebarOpen" x-transition>
- <div class="w-8 h-8 rounded-full bg-gray-400 dark:bg-gray-600"></div>
- <span class="ml-2 text-sm whitespace-nowrap">John Doe</span>
- </div>
- <a :href="signOut.href" class="group relative flex items-center py-2 px-3 rounded hover:bg-gray-300 dark:hover:bg-gray-700 w-full transition-all duration-100"
- :class="!sidebarOpen ? 'md:justify-center' : ''">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 flex-shrink-0 md:mx-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7" />
- </svg>
- <span x-show="sidebarOpen" x-transition class="ml-2 whitespace-nowrap" x-text="signOut.name"></span>
- <span class="sidebar-tooltip hidden md:block" x-show="!sidebarOpen" x-text="signOut.name"></span>
- </a>
- </div>
- </aside>
- <!-- Backdrop overlay on mobile -->
- <div x-show="sidebarOpen && window.innerWidth < 768" @click="sidebarOpen = false"
- class="fixed inset-0 bg-black bg-opacity-40 z-40 md:hidden" x-transition.opacity></div>
- <!-- Main Content -->
- <div class="flex-1 flex flex-col">
- <!-- Header -->
- <header class="flex justify-between items-center bg-gray-100 dark:bg-gray-800 px-4 py-3 shadow-md">
- <div class="flex items-center">
- <!-- Mobile sidebar toggle button -->
- <button @click="sidebarOpen = true" class="md:hidden mr-2 focus:outline-none">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700 dark:text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
- </svg>
- </button>
- <h1 class="text-2xl font-bold w-full text-center md:text-left">Analytics</h1>
- </div>
- <div class="flex items-center space-x-4">
- <button @click="darkMode = !darkMode" class="focus:outline-none">
- <svg x-show="!darkMode" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m8.66-8.66h-1M4.34 12H3m16.07 4.93l-.7-.7M5.64 5.64l-.7-.7m12.02 12.02l.7-.7M5.64 18.36l-.7-.7M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
- </svg>
- <svg x-show="darkMode" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
- <path d="M17.293 13.293A8 8 0 016.707 2.707a8 8 0 1010.586 10.586z" />
- </svg>
- </button>
- </div>
- </header>
- <!-- Content -->
- <main class="flex-1 p-4 overflow-y-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-50 dark:bg-gray-800 rounded shadow p-4 h-32"></div>
- <div class="bg-gray-200 dark:bg-gray-700 rounded h-48 md:col-span-2"></div>
- <div class="bg-gray-200 dark:bg-gray-700 rounded h-48"></div>
- </main>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment