Student starter code (30% baseline)
index.html
- Main HTML pagescript.js
- JavaScript logicstyles.css
- Styling and layoutpackage.json
- Dependenciessetup.sh
- Setup scriptREADME.md
- Instructions (below)๐ก Download the ZIP, extract it, and follow the instructions below to get started!
W3 Server-Side Development & Authentication - Lesson 5
Build a personal biography webpage using Svelte components, props, and the spread operator. This project introduces you to component-based architecture, where you'll create reusable building blocks to display your personal information in an organized, professional way.
By completing this project, you will:
โ Basic SvelteKit project structure โ Development environment configuration โ Empty component files (Header, Section, Footer) โ Starter page with TODO comments โ Bootstrap CSS for styling
Header Component
title
prop<h1>
tagSection Component
title
, item1
, item2
, item3
<h3>
, <p>
tags)Footer Component
copyright
prop<footer>
tagMain Page Implementation
Navigate to this template folder:
cd "Paid Courses/W3 Server-Side Development & Authentication/Templates/project-01-biography"
Install dependencies:
npm install
Start development server:
npm run dev
Open in browser:
Visit http://localhost:5173
project-01-biography/
โโโ src/
โ โโโ lib/
โ โ โโโ Header.svelte # TODO: Accept title prop
โ โ โโโ Section.svelte # TODO: Accept 4 props
โ โ โโโ Footer.svelte # TODO: Accept copyright prop
โ โโโ routes/
โ โโโ +page.svelte # TODO: Compose components
โโโ package.json # Dependencies
โโโ svelte.config.js # Svelte configuration
โโโ vite.config.js # Build configuration
Before implementing, research and answer:
Component Props: How do you pass data to Svelte components?
Spread Operator: What is {...object}
in Svelte?
Component Import: How do you use components in Svelte?
$lib
?Data Organization: How should you structure biography data?
File: src/lib/Header.svelte
<script>
// TODO: Export a prop called 'title'
// Hint: export let title;
</script>
<!-- TODO: Display title in <h1> tag -->
<!-- Hint: Use {title} to display the prop value -->
What to learn:
export let
File: src/lib/Section.svelte
<script>
// TODO: Export 4 props: title, item1, item2, item3
</script>
<div>
<!-- TODO: Display title in <h3> -->
<!-- TODO: Display each item in separate <p> tags -->
</div>
What to learn:
File: src/lib/Footer.svelte
<script>
// TODO: Export copyright prop
</script>
<!-- TODO: Use <footer> tag with copyright text -->
What to learn:
File: src/routes/+page.svelte
<script>
// TODO: Import all three components from $lib
// import Header from '$lib/Header.svelte';
// import Section from '$lib/Section.svelte';
// import Footer from '$lib/Footer.svelte';
// TODO: Create data objects
let myInfo = {
title: "About Me",
item1: "Your Name",
item2: "Your Age",
item3: "Your School"
};
let hobbiesInfo = {
title: "My Hobbies",
item1: "Hobby 1",
item2: "Hobby 2",
item3: "Hobby 3"
};
let skillsInfo = {
title: "My Skills",
item1: "Skill 1",
item2: "Skill 2",
item3: "Skill 3"
};
</script>
<div class="container mt-5">
<!-- TODO: Use Header component -->
<!-- <Header title="My Biography" /> -->
<!-- TODO: Use Section 3 times with spread operator -->
<!-- <Section {...myInfo} /> -->
<!-- <Section {...hobbiesInfo} /> -->
<!-- <Section {...skillsInfo} /> -->
<!-- TODO: Use Footer component -->
<!-- <Footer copyright="ยฉ 2024 Your Name" /> -->
</div>
What to learn:
{...object}
passes all object properties as propsYour project is complete when:
$lib
Test these scenarios:
Component Props:
Spread Operator:
Component Reusability:
Data Structure:
Criteria | Points | Description |
---|---|---|
Components | 40 | All 3 components work with proper props |
Props & Spread Operator | 30 | Correct use of props and {...spread} |
Code Quality | 20 | Clean code, proper imports, organization |
UI/UX | 10 | Professional appearance, good data |
Total | 100 |
Issue: Props not displaying in component
Solution: Check that you used export let propName
in the component's <script>
tag
Issue: Spread operator not working Solution: Ensure object properties match component prop names exactly
Issue: Components not found
Solution: Verify import path uses $lib/
and file extension .svelte
Issue: Styling not applied
Solution: Check Bootstrap CDN is imported in the <style>
section
When ready to deploy:
npm run build
npm run preview # Test production build locally
../../Project/Project 01- My Biography.mdx
Remember: This project teaches you the foundation of component-based development. Components are the building blocks of modern web applications - master them here, use them everywhere!
๐ก Pro Tip: Think about how these components could be reused in other projects. Good components are flexible, well-named, and do one thing well.