Skip to content

Commit 3a395be

Browse files
committed
add initial sveltekit-firebase lessons
1 parent 5f5cafe commit 3a395be

9 files changed

Lines changed: 404 additions & 6 deletions

‎apps/codingcatdev/src/content/course/sveltekit-firebase/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
cloudinary_convert: false
3-
cover:
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854060/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebaseCourse.png'
44
excerpt: 'Learn how to use Svelte Kit and Firebase to build high-performance, scalable web applications.'
55
published: draft
66
slug: sveltekit-firebase

apps/codingcatdev/src/content/course/sveltekit-firebase/lesson/intro.md renamed to apps/codingcatdev/src/content/course/sveltekit-firebase/lesson/01-intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
cloudinary_convert: false
3-
cover:
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_01.png'
44
excerpt:
55
published: draft
66
slug: intro
@@ -11,4 +11,4 @@ weight: 1
1111
youtube:
1212
---
1313

14-
Open Lesson
14+
Talk all about this course.

apps/codingcatdev/src/content/course/sveltekit-firebase/lesson/intro-blackcat-tailwind.md renamed to apps/codingcatdev/src/content/course/sveltekit-firebase/lesson/02-intro-blackcat-tailwind.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
cloudinary_convert: false
3-
cover:
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_02.png'
44
excerpt:
5-
locked: true
65
published: draft
76
slug: intro-blackcat-tailwind
87
start: April 17, 2023
@@ -11,4 +10,4 @@ weight: 2
1110
youtube:
1211
---
1312

14-
Closed Lesson
13+
This is how BlackCatUI will be used.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
cloudinary_convert: false
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_03.png'
4+
excerpt:
5+
published: draft
6+
slug: what-is-svelte
7+
start: April 17, 2023
8+
stackblitz: 'https://stackblitz.com/github/CodingCatDev/svelte-firebase-course/tree/03-starting-to-code?embed=1&file=apps/svelte-site/src/routes/+page.svelte'
9+
title: What is Svelte
10+
weight: 3
11+
youtube:
12+
---
13+
14+
## Svelte Summary
15+
16+
Svelte is a modern JavaScript framework that is quickly gaining popularity among web developers. It is known for its small size, high performance, and easy-to-learn syntax. Svelte is also very flexible and can be used to build a wide variety of web applications.
17+
18+
## Svelte Features
19+
20+
- Small size: Svelte is a very small framework, with a download size of just 4.1 KB. This makes it ideal for use on mobile devices and other low-powered devices.
21+
- High performance: Svelte is very performant, thanks to its use of the compiler to generate efficient JavaScript code. This means that Svelte applications can be loaded and run quickly, even on slow connections.
22+
- Easy-to-learn syntax: Svelte has a very simple and easy-to-learn syntax. This makes it a great choice for beginners, as well as experienced developers who want to build web applications quickly and easily.
23+
- Flexible: Svelte is a very flexible framework that can be used to build a wide variety of web applications. It is suitable for both small and large projects, and can be used to build both simple and complex user interfaces.
24+
25+
If you are looking for a modern, performant, and easy-to-learn JavaScript framework, then Svelte is a great option. It is quickly becoming one of the most popular frameworks in the world, and for good reason.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
cloudinary_convert: false
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_04.png'
4+
excerpt:
5+
published: draft
6+
slug: components-and-props
7+
start: April 17, 2023
8+
stackblitz: 'https://stackblitz.com/github/CodingCatDev/svelte-firebase-course/tree/04-components-and-props?embed=1&file=apps/svelte-site/src/routes/+page.svelte'
9+
title: Components and Props
10+
weight: 4
11+
youtube:
12+
---
13+
14+
## Svelte Components and Props
15+
16+
Svelte is a modern JavaScript framework that is quickly gaining popularity among web developers. One of the things that makes Svelte so powerful is its component-based architecture. Components are reusable pieces of code that can be used to build complex user interfaces.
17+
18+
In this blog post, we will discuss Svelte components and props. We will learn how to create components, how to pass props to components, and how to use props to control the behavior of components.
19+
20+
## What are Svelte Components?
21+
22+
Svelte components are reusable pieces of code that can be used to build complex user interfaces. Components are defined using the `Svelte` tag. For example, the following code defines a component called `Button`:
23+
24+
```svelte
25+
<Svelte name="Button">
26+
<button>Click Me!</button>
27+
</Svelte>
28+
```
29+
30+
The `Svelte` tag takes two arguments: the name of the component and the component's code. In this case, the component's name is `Button` and the component's code is a simple button.
31+
32+
## What are Props?
33+
34+
Props are variables that are passed to components. Props can be used to control the behavior of components. For example, the following code passes a `text` prop to the `Button` component:
35+
36+
```svelte
37+
<Svelte name="Button" text="Click Me!">
38+
<button>{text}</button>
39+
</Svelte>
40+
```
41+
42+
The `text` prop is used to set the text that is displayed on the button.
43+
44+
## How to Use Props
45+
46+
Props can be used to control the behavior of components in a variety of ways. For example, you can use props to:
47+
48+
- Set the value of a component's properties
49+
- Call a component's methods
50+
- Prevent a component from being rendered
51+
52+
## Conclusion
53+
54+
Svelte components and props are a powerful way to build complex user interfaces. Components can be reused to save time and code, and props can be used to control the behavior of components. If you are new to Svelte, I encourage you to learn more about components and props. They are a key part of the Svelte framework and can help you build better web applications.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
cloudinary_convert: false
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_05.png'
4+
excerpt:
5+
published: draft
6+
slug: inputs-bindings-and-reactivity
7+
start: April 17, 2023
8+
stackblitz: 'https://stackblitz.com/github/CodingCatDev/svelte-firebase-course/tree/05-inputs-bindings-and-reactivity?embed=1&file=apps/svelte-site/src/routes/+page.svelte'
9+
title: Inputs Bindings and Reactivity
10+
weight: 5
11+
youtube:
12+
---
13+
14+
## Svelte Inputs Bindings and Reactivity
15+
16+
Svelte is a modern JavaScript framework that is quickly gaining popularity among web developers. One of the things that makes Svelte so powerful is its reactivity system. Reactivity allows Svelte components to automatically update their state when the data they depend on changes. This makes it easy to build complex user interfaces that are always up-to-date.
17+
18+
In this blog post, we will discuss Svelte inputs, bindings, and reactivity. We will learn how to create Svelte inputs, how to bind inputs to data, and how to use reactivity to keep our user interfaces up-to-date.
19+
20+
## What are Svelte Inputs?
21+
22+
Svelte inputs are components that allow users to enter data. Svelte inputs can be used to collect user input for a variety of purposes, such as searching, filtering, and creating new records.
23+
24+
There are two types of Svelte inputs: **text inputs** and **select inputs**. Text inputs allow users to enter free-form text, while select inputs allow users to choose from a list of options.
25+
26+
## How to Create Svelte Inputs
27+
28+
Svelte inputs are created using the `input` tag. The `input` tag takes a number of attributes, including:
29+
30+
- **type:** The type of input, such as `text` or `select`.
31+
- **name:** The name of the input.
32+
- **value:** The initial value of the input.
33+
34+
For example, the following code creates a text input with the name `name` and the initial value `John Doe`:
35+
36+
```svelte
37+
<input type="text" name="name" value="John Doe" />
38+
```
39+
40+
## How to Bind Svelte Inputs to Data
41+
42+
Svelte inputs can be bound to data using the `bind:value` attribute. The `bind:value` attribute takes a variable name as its value. When the value of the input changes, the variable will be updated with the new value.
43+
44+
For example, the following code binds a text input to a variable called `name`:
45+
46+
```svelte
47+
<input type="text" bind:value="name">
48+
```
49+
50+
## How to Use Reactivity to Keep User Interfaces Up-to-Date
51+
52+
Svelte's reactivity system automatically updates Svelte components when the data they depend on changes. This means that we don't have to manually update our components when the data changes.
53+
54+
For example, the following code creates a component that displays the value of a text input:
55+
56+
```svelte
57+
{#if name}
58+
<p>Your name is {{ name }}</p>
59+
{/if}
60+
```
61+
62+
When the user changes the value of the input, the component will automatically update to display the new value.
63+
64+
## Conclusion
65+
66+
Svelte inputs, bindings, and reactivity are powerful tools that can be used to build complex user interfaces. By understanding how to use these tools, we can build web applications that are both efficient and user-friendly.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
cloudinary_convert: false
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_06.png'
4+
excerpt:
5+
published: draft
6+
slug: basic-events
7+
start: April 17, 2023
8+
stackblitz: 'https://stackblitz.com/github/CodingCatDev/svelte-firebase-course/tree/06-basic-events?embed=1&file=apps/svelte-site/src/routes/+page.svelte'
9+
title: Basic Events
10+
weight: 6
11+
youtube:
12+
---
13+
14+
## DOM Events in Svelte
15+
16+
Svelte is a modern JavaScript framework that is quickly gaining popularity among web developers. One of the things that makes Svelte so powerful is its event handling system. Svelte's event handling system is simple, efficient, and easy to learn.
17+
18+
In this blog post, we will discuss DOM events in Svelte. We will learn how to listen for DOM events, how to handle DOM events, and how to prevent default actions.
19+
20+
## What are DOM Events?
21+
22+
DOM events are events that are generated by the DOM. DOM events are triggered by user interaction, such as mouse clicks, key presses, and scroll events. DOM events can also be triggered by changes to the DOM, such as when an element is added or removed from the DOM.
23+
24+
## How to Listen for DOM Events
25+
26+
Svelte provides a number of ways to listen for DOM events. The most common way to listen for DOM events is to use the `on:eventname` directive. The `on:eventname` directive takes a function as its value. The function will be called whenever the event is triggered.
27+
28+
For example, the following code listens for the `click` event on a button:
29+
30+
```svelte
31+
<button
32+
on:click={() => {
33+
// do something when the button is clicked
34+
}}
35+
>
36+
Click Me!
37+
</button>
38+
```
39+
40+
## How to Handle DOM Events
41+
42+
The function that is passed to the `on:eventname` directive can be used to handle the event. The function can be used to change the DOM, update the state of the component, or call a function.
43+
44+
For example, the following code changes the text of a paragraph when the button is clicked:
45+
46+
```svelte
47+
<p>This is a paragraph.</p>
48+
<button
49+
on:click={() => {
50+
// change the text of the paragraph
51+
paragraph.textContent = 'This is a new paragraph.';
52+
}}
53+
>
54+
Click Me!
55+
</button>
56+
```
57+
58+
## How to Prevent Default Actions
59+
60+
The `on:eventname` directive also takes a modifier called `preventDefault`. The `preventDefault` modifier can be used to prevent the default action of the event from being triggered.
61+
62+
For example, the following code prevents the default action of the `click` event from being triggered:
63+
64+
```svelte
65+
<button
66+
on:click={() => {
67+
// do something when the button is clicked
68+
}}
69+
preventDefault
70+
>
71+
Click Me!
72+
</button>
73+
```
74+
75+
## Conclusion
76+
77+
DOM events are a powerful way to interact with the user and respond to changes in the DOM. Svelte's event handling system is simple, efficient, and easy to learn. By understanding how to use DOM events, we can build web applications that are both interactive and responsive.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
cloudinary_convert: false
3+
cover: 'https://media.codingcat.dev/image/upload/v1681854110/main-codingcatdev-photo/courses/sveltekit-firebase/SvelteFirebase_07.png'
4+
excerpt:
5+
published: draft
6+
slug: component-events-forwarding
7+
start: April 17, 2023
8+
stackblitz: 'https://stackblitz.com/github/CodingCatDev/svelte-firebase-course/tree/07-component-events-forwarding?embed=1&file=apps/svelte-site/src/routes/+page.svelte'
9+
title: Component Events and Forwarding
10+
weight: 7
11+
youtube:
12+
---
13+
14+
## Svelte Component Events and Forwarding Events
15+
16+
Svelte is a modern JavaScript framework that is quickly gaining popularity among web developers. One of the things that makes Svelte so powerful is its component-based architecture. Components are reusable pieces of code that can be used to build complex user interfaces.
17+
18+
In this blog post, we will discuss Svelte component events and forwarding events. We will learn how to create component events, how to forward component events, and how to use component events to communicate between components.
19+
20+
## What are Svelte Component Events?
21+
22+
Svelte component events are custom events that can be emitted by components. Component events can be used to communicate between components and to trigger other events.
23+
24+
To create a component event, we use the `on:eventname` directive. The `on:eventname` directive takes a function as its value. The function will be called whenever the event is emitted.
25+
26+
For example, the following code creates a component event called `click`:
27+
28+
```svelte
29+
<button
30+
on:click={() => {
31+
// do something when the button is clicked
32+
}}
33+
>
34+
Click Me!
35+
</button>
36+
```
37+
38+
## How to Forward Component Events
39+
40+
Svelte components can forward component events to their parent components. To forward a component event, we use the `emit:eventname` directive. The `emit:eventname` directive takes a value as its value. The value will be passed to the event handler when the event is emitted.
41+
42+
For example, the following code forwards the `click` event to the parent component:
43+
44+
```svelte
45+
<button
46+
on:click={() => {
47+
// do something when the button is clicked
48+
this.$emit('click');
49+
}}
50+
>
51+
Click Me!
52+
</button>
53+
```
54+
55+
## How to Use Component Events to Communicate Between Components
56+
57+
Svelte component events can be used to communicate between components. To use component events to communicate between components, we need to create a component event in one component and forward the event to the other component.
58+
59+
For example, the following code creates a component event called `click` in the `Button` component and forwards the event to the `App` component:
60+
61+
```svelte
62+
<script>
63+
import App from './App.svelte';
64+
65+
export default {
66+
name: 'Button',
67+
on:click={() => {
68+
// do something when the button is clicked
69+
this.$emit('click');
70+
}}
71+
};
72+
</script>
73+
```
74+
75+
```svelte
76+
<script>
77+
import Button from './Button.svelte';
78+
79+
export default {
80+
name: 'App',
81+
on:click={() => {
82+
// do something when the button is clicked
83+
}}
84+
};
85+
</script>
86+
```
87+
88+
In this example, the `Button` component emits the `click` event when the button is clicked. The `App` component listens for the `click` event and calls a function when the event is emitted.
89+
90+
## Conclusion
91+
92+
Svelte component events are a powerful way to communicate between components. By understanding how to use component events, we can build web applications that are both interactive and responsive.

0 commit comments

Comments
 (0)