Repository: olliethedev/dnd-dashboard
Branch: main
Commit: 9addc26c3f07
Files: 47
Total size: 96.7 KB
Directory structure:
gitextract_4y0fo0n3/
├── .eslintrc.json
├── .gitignore
├── README.md
├── app/
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
├── components/
│ ├── date-range-picker.tsx
│ ├── edit-switch.tsx
│ ├── main-nav.tsx
│ ├── overview-loader.tsx
│ ├── overview.tsx
│ ├── recent-sales-loader.tsx
│ ├── recent-sales.tsx
│ ├── search.tsx
│ ├── stats-loader.tsx
│ ├── stats.tsx
│ ├── swap-layout-loader.tsx
│ ├── swap-layout.tsx
│ ├── team-switcher.tsx
│ ├── transactions-loader.tsx
│ ├── transactions.tsx
│ ├── ui/
│ │ ├── avatar.tsx
│ │ ├── badge.tsx
│ │ ├── button.tsx
│ │ ├── calendar.tsx
│ │ ├── card.tsx
│ │ ├── chart.tsx
│ │ ├── command.tsx
│ │ ├── dialog.tsx
│ │ ├── dropdown-menu.tsx
│ │ ├── input.tsx
│ │ ├── label.tsx
│ │ ├── popover.tsx
│ │ ├── select.tsx
│ │ ├── skeleton.tsx
│ │ ├── switch.tsx
│ │ ├── table.tsx
│ │ ├── tabs.tsx
│ │ └── toggle.tsx
│ └── user-nav.tsx
├── components.json
├── lib/
│ └── utils.ts
├── next.config.mjs
├── package.json
├── postcss.config.mjs
├── tailwind.config.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.json
================================================
{
"extends": "next/core-web-vitals"
}
================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
================================================
FILE: README.md
================================================
# Next.js Drag-and-Drop Dashboard Demo
This is a beautiful, performant dashboard with drop-to-swap layouts built using Next.js, shadcn/ui, and swapy.

## Features
- Drag-and-drop layout customization
- Real-time layout updates
- Responsive design
- Beautiful UI components from shadcn/ui
- Server-side rendering with Next.js
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about the technologies used in this project, check out the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [shadcn/ui](https://ui.shadcn.com/) - beautifully designed components built with Radix UI and Tailwind CSS.
- [swapy](https://swapy.tahazsh.com/) - a lightweight JavaScript library for creating drag and drop interfaces.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
================================================
FILE: app/globals.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
================================================
FILE: app/layout.tsx
================================================
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
{children}
);
}
================================================
FILE: app/page.tsx
================================================
import React, { Suspense } from "react";
import dynamic from "next/dynamic";
// navigation components
import { UserNav } from "@/components/user-nav";
import { MainNav } from "@/components/main-nav";
import { CalendarDateRangePicker } from "@/components/date-range-picker";
// basic components
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
// high level components
import { Search } from "@/components/search";
import { TeamSwitcher } from "@/components/team-switcher";
import { RecentSales } from "@/components/recent-sales";
import { Transactions } from "@/components/transactions";
import { Stats } from "@/components/stats";
import { Overview } from "@/components/overview";
// Skeleton loaders
import { StatsLoader } from "@/components/stats-loader";
import { SwapLayoutLoader } from "@/components/swap-layout-loader";
import { OverviewLoader } from "@/components/overview-loader";
import { RecentSalesLoader } from "@/components/recent-sales-loader";
import { TransactionsLoader } from "@/components/transactions-loader";
// swap layout is a client side component, since it uses local storage for this demo.
// In production you might want to save the layout order on server via api call
const SwapLayout = dynamic(() => import("@/components/swap-layout"), {
ssr: false,
loading: () => ,
});
// This is the main page of the app.
export default function Home() {
return (
Dashboard
);
}
// this is the initial layout of the swap layout.
const initialSwapSections = {
top: (
Stats}>
),
center_left: (
Overview}>
),
center_right: (
Recent SalesYou made 265 sales this month.}>
),
bottom: (
Transactions
Recent transactions from your store.
}>
),
};
// this is the class names for the sections of the swap layout.
const sectionSlotClassNames = {
"1": "col-span-2 row-span-1 h-full w-full flex flex-col",
"2": "col-span-1 row-span-2 h-full w-full flex flex-col",
"3": "col-span-1 row-span-2 h-full w-full flex flex-col",
"4": "col-span-2 row-span-2 h-full w-full flex flex-col",
};
================================================
FILE: components/date-range-picker.tsx
================================================
"use client"
import * as React from "react"
import { CalendarIcon } from "@radix-ui/react-icons"
import { addDays, format } from "date-fns"
import { DateRange } from "react-day-picker"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import { Calendar } from "@/components/ui/calendar"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
export function CalendarDateRangePicker({
className,
}: React.HTMLAttributes) {
const [date, setDate] = React.useState({
from: new Date(2023, 0, 20),
to: addDays(new Date(2023, 0, 20), 20),
})
return (