THE SUMMARYAI-generated
Key Concepts
- React.js: A JavaScript library for building user interfaces.
- Tailwind CSS: A utility-first CSS framework for rapidly styling web applications.
- Vit: A build tool that aims to provide a faster and leaner development experience for modern web projects.
- Lucid React: An icon library for React applications.
- React Router DOM: A library for handling routing in React applications.
- Tailwind Merge: A utility for merging Tailwind CSS class names.
- Radix UI: A set of unstyled, accessible UI primitives.
- Toaster: A UI component for displaying notifications.
- CSS Variables (HSL): Custom properties in CSS that store values like colors, defined using HSL (Hue, Saturation, Lightness).
- Keyframes: CSS rules that define the stages of an animation.
- Utility Classes: CSS classes that apply a specific style or set of styles, often used in CSS frameworks like Tailwind CSS.
- Media Queries: CSS rules that apply styles based on the characteristics of the device, such as screen size.
- Local Storage: A web storage API that allows websites to store key-value pairs in a web browser, providing persistent data storage.
- Event Listener: A mechanism in JavaScript that allows you to listen for specific events on an element and execute a function when that event occurs.
- CSS Grid: A CSS layout module that allows you to create complex grid-based layouts.
- CSS Flexbox: A CSS layout module that provides a flexible way to align and distribute space among items in a container.
- Toaster (Radix UI): A UI component for displaying notifications.
- Vercel: A platform for deploying and hosting web applications.
- GitHub: A web-based platform for version control and collaboration using Git.
Building a Personal Portfolio Website with React.js and Tailwind CSS
Project Setup
-
Create a React Project with Vit:
- Run
npx create vitein the terminal. - Select React as the framework and JavaScript as the variant.
- Run
npm installto install dependencies. - Run
npm run devto start the development server.
- Run
-
Install Tailwind CSS and Plugins:
- Run
npm install -D tailwindcss postcss autoprefixer. - Run
npx tailwindcss init -pto generatetailwind.config.jsandpostcss.config.js. - Install the Tailwind CSS Vit plugin:
npm install -D @tailwindcss/vite. - Import the plugin in
vite.config.js:
import tailwindcss from '@tailwindcss/vite' import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react(), tailwindcss()], })- Add Tailwind directives to
index.css:
@tailwind base; @tailwind components; @tailwind utilities; - Run
-
Set Up Path Aliases:
- Import
pathinvite.config.js:import path from 'path'. - Configure the alias in
vite.config.js:
resolve: { alias: { '@': path.resolve(__dirname, './src'), }, },This allows importing modules from the
srcdirectory using the@symbol (e.g.,import Component from '@/components/Component'). - Import
-
Install Additional Packages:
npm install lucid-react react-router-dom tailwind-merge @radix-ui/react-toast clsx- Lucid React: For icons.
- React Router DOM: For routing.
- Tailwind Merge: For merging Tailwind CSS class names.
- Radix UI React Toast: For displaying notifications.
- clsx: A utility for constructing class name strings conditionally.
-
Clean Up:
- Delete
App.css.
- Delete
Defining Routes
-
Set up React Router:
- Import
BrowserRouter,Routes, andRoutefromreact-router-dom. - Define routes in
App.jsx:
import { BrowserRouter, Routes, Route } from 'react-router-dom'; import Home from './pages/Home'; import NotFound from './pages/NotFound'; function App() { return ( <BrowserRouter> <Routes> <Route index element={<Home />} /> <Route path="*" element={<NotFound />} /> </Routes> </BrowserRouter> ); } export default App;- Create
Home.jsxandNotFound.jsxin thepagesdirectory. - The
*path in theRoutecomponent is a wildcard that matches any path that hasn't been defined, and it's used to render theNotFoundcomponent.
- Import
Styling with Tailwind CSS and Customization
- Define Custom Theme in
index.css:- Define CSS variables for colors (border, background, foreground, primary, secondary, card) using HSL.
- Define keyframes for animations (fade-in, float, pulse-subtle, meteor).
- Define Base Layer:
- Use the
@layer basedirective to define the root and dark themes, assigning HSL values to the CSS variables.
- Use the
- Create Utility Classes:
- Use the
@layer utilitiesdirective to define custom utility classes:.container: Setsmargin-inline: autoandpadding-inline: 2rem, and defines responsivemax-widthusing media queries..text-glow: Adds a text shadow for a glowing effect..card-hover: Adds a transform transition and hover effect to scale cards up..gradient-border: Creates a gradient border for cards..cosmic-button: Styles buttons with padding, rounded corners, background color, text color, and hover effects..star: Styles the star elements with absolute positioning, rounded corners, white color, and box shadow..meteor: Styles the meteor elements with absolute positioning, a linear gradient background, rounded corners, and a box shadow.
- Use the
- Apply Base Styles:
- Apply styles to all elements (
*) to set the border color. - Apply
scroll-smoothto thehtmlelement for smooth scrolling. - Apply background color, foreground color, and transition colors to the
bodyelement.
- Apply styles to all elements (
- Apply Styles to Root Element:
- Set
max-width: 100%,margin: 0 auto,padding: 0, andtext-align: centerto the root element.
- Set
Theme Toggle Component
- Create
ThemeToggle.jsxin thecomponentsdirectory. - Implement Theme Switching Logic:
- Use
useStateto manage theisDarkModestate. - Use
useEffectto read the theme from local storage on component mount. - Implement the
toggleThemefunction to switch between dark and light modes:- Add or remove the
darkclass from thedocument.documentElement.classList. - Store the theme preference in local storage.
- Add or remove the
- Use
- Render the Toggle Button:
- Display a sun icon in dark mode and a moon icon in light mode.
- Apply styles to the icons using Tailwind CSS classes.
- Position the Toggle Button:
- Use the
cn(class name) utility to combine Tailwind CSS classes for positioning and styling the button.
- Use the
Star Background Component
- Create
StarBackground.jsxin thecomponentsdirectory. - Generate Stars:
- Use
useStateto manage thestarsarray. - Implement the
generateStarsfunction to create an array of star objects with random sizes, positions, opacities, and animation durations. - Calculate the number of stars based on the window size.
- Use
- Render Stars:
- Map through the
starsarray and renderdivelements for each star. - Apply the
starutility class and inline styles for positioning, size, opacity, and animation duration.
- Map through the
- Generate Meteors:
- Use
useStateto manage themeteorsarray. - Implement the
generateMeteorsfunction to create an array of meteor objects with random sizes, positions, delays, and animation durations.
- Use
- Render Meteors:
- Map through the
meteorsarray and renderdivelements for each meteor. - Apply the
meteorandanimate-meteorutility classes and inline styles for positioning, size, and animation delay.
- Map through the
- Handle Window Resize:
- Use
useEffectto add aresizeevent listener to the window. - Implement the
handleResizefunction to regenerate the stars and meteors when the window is resized. - Clean up the event listener on component unmount.
- Use
Navbar Component
- Create
Navbar.jsxin thecomponentsdirectory. - Define Navigation Items:
- Create an array of objects representing the navigation links, including the name and
href(ID of the target section).
- Create an array of objects representing the navigation links, including the name and
- Implement Scroll Detection:
- Use
useStateto manage theisScrolledstate. - Use
useEffectto add ascrollevent listener to the window. - Implement the
handleScrollfunction to update theisScrolledstate based on the scroll position.
- Use
- Render the Navbar:
- Use a
navelement with acontainerdiv to center the content. - Render the logo with a glowing effect.
- Render the desktop navigation links by mapping through the
navItemsarray. - Render the mobile navigation menu by mapping through the
navItemsarray. - Render the menu button to toggle the mobile menu.
- Use a
- Style the Navbar:
- Use Tailwind CSS classes to style the navbar with fixed positioning, full width, transition effects, and conditional styling based on the
isScrolledstate. - Style the logo with text size, font weight, and color.
- Style the navigation links with color, hover effects, and transition effects.
- Style the mobile menu with fixed positioning, background color, blur effect, and conditional styling based on the
isMenuOpenstate. - Style the menu button with padding, color, and z-index.
- Use Tailwind CSS classes to style the navbar with fixed positioning, full width, transition effects, and conditional styling based on the
Hero Section Component
- Create
HeroSection.jsxin thecomponentsdirectory. - Render the Hero Section:
- Use a
sectionelement with an ID ofhero. - Render the title with a glowing effect and different colors for each part.
- Render the description with a muted foreground color and a fade-in animation.
- Render the "View My Work" button with the
cosmic-buttonstyle. - Render the scroll indicator with a bouncing animation.
- Use a
- Style the Hero Section:
- Use Tailwind CSS classes to style the section with relative positioning, minimum height, flex layout, and padding.
- Style the title with text size, font weight, and tracking.
- Style the description with text size, muted foreground color, and max width.
- Style the "View My Work" button with the
cosmic-buttonstyle and a fade-in animation. - Style the scroll indicator with absolute positioning, bottom alignment, and a bouncing animation.
About Section Component
- Create
AboutSection.jsxin thecomponentsdirectory. - Render the About Section:
- Use a
sectionelement with an ID ofabout. - Render the title with a span for the "me" part to apply a different color.
- Render the description with a paragraph and a list of skills.
- Render the "Get in Touch" and "Download CV" buttons.
- Use a
- Style the About Section:
- Use Tailwind CSS classes to style the section with padding, relative positioning, and a container.
- Style the title with text size, font weight, and color.
- Style the description with text size, muted foreground color, and max width.
- Style the "Get in Touch" and "Download CV" buttons with the
cosmic-buttonstyle and custom styles.
Skills Section Component
- Create
SkillsSection.jsxin thecomponentsdirectory. - Define Skills Data:
- Create an array of objects representing the skills, including the name, level, and category.
- Implement Category Filtering:
- Use
useStateto manage theactiveCategorystate. - Create a
categoriesarray with the available categories. - Filter the
skillsarray based on theactiveCategorystate.
- Use
- Render the Skills Section:
- Use a
sectionelement with an ID ofskills. - Render the title with a span for the "skills" part to apply a different color.
- Render the category filter buttons by mapping through the
categoriesarray. - Render the skills by mapping through the filtered
skillsarray.
- Use a
- Style the Skills Section:
- Use Tailwind CSS classes to style the section with padding, relative positioning, and a container.
- Style the title with text size, font weight, and color.
- Style the category filter buttons with padding, rounded corners, transition effects, and conditional styling based on the
activeCategorystate. - Style the skills with padding, rounded corners, shadow, and hover effects.
Projects Section Component
- Create
ProjectsSection.jsxin thecomponentsdirectory. - Define Projects Data:
- Create an array of objects representing the projects, including the ID, title, description, image, tags, GitHub URL, and demo URL.
- Render the Projects Section:
- Use a
sectionelement with an ID ofprojects. - Render the title with a span for the "projects" part to apply a different color.
- Render the projects by mapping through the
projectsarray.
- Use a
- Style the Projects Section:
- Use Tailwind CSS classes to style the section with padding, relative positioning, and a container.
- Style the title with text size, font weight, and color.
- Style the projects with padding, rounded corners, shadow, and hover effects.
Contact Section Component
- Create
ContactSection.jsxin thecomponentsdirectory. - Render the Contact Section:
- Use a
sectionelement with an ID ofcontact. - Render the title with a span for the "touch" part to apply a different color.
- Render the contact information (email, phone, location).
- Render the social media links.
- Render the contact form.
- Use a
- Style the Contact Section:
- Use Tailwind CSS classes to style the section with padding, relative positioning, and a container.
- Style the title with text size, font weight, and color.
- Style the contact information with muted foreground color and hover effects.
- Style the social media links with muted foreground color and hover effects.
- Style the contact form with padding, rounded corners, and shadow.
Footer Component
- Create
Footer.jsxin thecomponentsdirectory. - Render the Footer:
- Use a
footerelement. - Render the copyright information.
- Render the "Scroll to Top" button.
- Use a
- Style the Footer:
- Use Tailwind CSS classes to style the footer with padding, background color, border top, and flex layout.
- Style the copyright information with text size and muted foreground color.
- Style the "Scroll to Top" button with padding, rounded corners, background color, hover effects, and color.
Deployment to Vercel
- Push the code to a GitHub repository.
- Create an account on Vercel.
- Connect Vercel to your GitHub account.
- Import the GitHub repository into Vercel.
- Deploy the project.
AI summaries can miss context or contain errors. Check important details against the original video.





