Sandbox app for Cookies, Charts, Maps, Carousel and TailwindCSSV4
Your task is to build a sandbox environment that integrates various frontend features, including cookie management, dynamic charts, interactive maps, and an image carousel, all styled with Tailwind CSS v4. Implement client-side storage using js-cookie for managing cookies, allowing users to store and retrieve small data efficiently. Use a charting library to visualize data interactively and integrate Leaflet with OpenStreetMap for an engaging mapping experience. Develop a customizable image carousel for seamless browsing of image collections. Ensure the UI is responsive and modern by leveraging Tailwind CSS v4, and structure your components for easy navigation and scalability.
1 Cookie Management in TypeScript
Install dependencies: npm i js-cookie
and npm i -D @types/js-cookie
for TypeScript support
Must use client-side components in Next.js when working with cookies
Follow documentation from current version v3.0.5
2 Top 5 Cookie Use Cases
3 Chart.js Integration
Useful resources:
4 Tailwind CSS v4 Global Styling
Global stylesheet is teh new approach replacing tailwind.config.ts
Use @layer base { }
for default styling:@layer base {
* {
margin: 0;
padding: 0;
box-sizing: border-box;
scroll-behavior: smooth;
}
}
Use @theme inline {}
to extend Tailwind for custom colors and fonts
5 Tailwind CSS Animationanimate-pulse
utility applies a subtle pulsing animation
Commonly used for loading skeletons or to indicate background processes
Example: <div class="w-32 h-32 bg-gray-300 animate-pulse"></div>
Best for skeleton loaders, button feedback, and loading indicators
6 UI Enhancement Tools
BProgress: A successor to Next NProgress Bar for page loading indicators
7 Next.js Advanced Features
Implemented nested layouts for complex page structures
First experience with dynamic imports using next/dynamic
8 Next.js Authentication Middleware
Checks for "user" cookie to manage authentication-based redirects
Redirects unauthorized users from protected routes to /login
Prevents authenticated users from accessing /login or /register
Uses NextResponse from "next/server" for handling redirects at the Edge
9 Map Integration
Leaflet + react-leaflet + OpenStreetMap (OSM) provides a free alternative to Mapbox
Similar functionality with more setup required
Added type definitions with npm install -D @types/leaflet
10 State Management Debugging
Redux DevTools Chrome extension works with any state management solution
Supports custom implementations when integrated with its API
11 Zustand Middlewarepersist(...)
: Saves store state to localStorage for persistence across page reloadsdevtools(...)
: Enables Redux DevTools support for debugging store changes
12 VS Code Productivity Tips
On Windows, hover over undefined terms and press Ctrl + Space for autocomplete
Press Enter to auto-import the module
Alternative: Ctrl + . to open Quick Fix and select "Add Import"
Ensure auto-imports are enabled in settings
Stackoverflow
YouTube
Google
ChatGPT
-Jehovah that keeps breath in my lungs