Building a Beginner-Friendly Landing Page with SvelteKit and Tailwind CSS

Jun 24, 2024

Lecture Notes: Building a Beginner-Friendly Landing Page with SvelteKit and Tailwind CSS

Introduction

  • Presenter: James MacArthur
  • Goal: To learn SvelteKit and Tailwind CSS by building a responsive landing page.

What You'll Learn

  • SvelteKit basics (components, state, stores, routes)
  • Global stores in SvelteKit
  • Tailwind CSS for styling
  • Responsive web design
  • Handling props, styling, and more

Project Overview

  • A home landing page with call-to-actions, reviews, features, FAQs, and a footer.
  • Mobile responsiveness with a neat menu system.

Initial Setup

Tailwind Installation

  1. Initialize SvelteKit Project:
    • Use command: npm create svelte@latest.
    • Name: gy-app-landing-page.
    • Skeleton project, no type check, use ESLint.
  2. Configure Tailwind:
    • Follow Tailwind CSS documentation for configuration.
    • Paste configuration commands into the VSCode terminal.
    • Create app.css in the src directory with Tailwind directives.

Font Setup

  • Google Fonts: Add Open Sans and Poppins (all weights).
  • Font Awesome: Use CDN for icons.
  • Update app.html with the link tags for fonts and Font Awesome.
  • Add body styles for base text and relative positioning.
  • Define a background grid pattern in CSS for styling.

Project Structure

  • src Directory: Contains main project files like lib, routes, components, and configurations.
  • Component Structure: Create various components such as header, footer, hero, product, reviews, FAQs, conversion, and sectionWrapper for modular design.
  • Run Project: Use command npm run dev to start the project and open it in a browser.

Building Components

Header Component

  • Contains site title and menu button.
  • Uses Font Awesome for menu icons.
  • Conditional rendering for responsiveness.
  • Button and link styling for boundary breakpoints.

Hero Component

  • Includes header and main hero section with call-to-action buttons and introductory text.
  • Uses dynamic classes and spans for styled text elements.
  • Integrates reviews display inline with stars.

Product Section

  • Dynamic product feature cards showcased in a grid layout.
  • Configurable via JSON objects passed as props to sub-components.
  • Featured images and text descriptions for each product feature.

Reviews Section

  • Displays user reviews with collapsible/expandable interactive views.
  • Global state management via Svelte Store for review limit toggle.

FAQs Section

  • List of frequently asked questions with expanding segments for answers.
  • Simple JSON object configuration for FAQs.

CSS Customizations

  • Buttons: Custom classes like specialButton, hover effects, and media query adaptations.
  • Background Patterns: Custom grid and button styles defined in CSS.
  • Typography: Font settings for headers and body text incorporating Google Fonts.

Creating a Responsive Menu

  • Menu Toggle: Uses Svelte store for global state to show/hide the menu.
  • Beginner friendly with examples of opening/closing a modal menu based on screen size.

Deployment

  • Deploying SvelteKit web app via Netlify using GitHub repository for project tracking.
  • Steps for logging into Netlify, connecting GitHub repo, and setting custom domain names.

Final Touches and Testing

  • Complete end-to-end walkthrough for responsiveness and interactivity tests.
  • Ensure nav links correctly route to sections using IDs in section wrappers.
  • Validate all features work across different devices and screen sizes.

Wrap Up

  • Encouragement to customize and share own versions in the community Discord.
  • Reminder to check additional resources like the James Web Development Roadmap.

Thank You Notes

  • Thank you message for the viewers with reminders to like and subscribe.