Skip to content

Commit de292f5

Browse files
committed
Add Pinia slides
1 parent 3abe690 commit de292f5

File tree

2 files changed

+147
-2
lines changed

2 files changed

+147
-2
lines changed
27.7 KB
Loading

04-frameworks/03-vue/slides/slides.md

Lines changed: 147 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ layout: image
10491049
title: Slots
10501050
image: /slots.png
10511051
backgroundSize: contain
1052-
transition: fade
10531052
---
10541053

10551054
---
@@ -1647,8 +1646,57 @@ layout: quote
16471646

16481647
# Agenda
16491648

1650-
- Composition API
1649+
<v-clicks depth="3">
1650+
1651+
- Repaso de la teoría del día anterior
1652+
- **Teoría**
1653+
- 🧩 _Componentes_ (_SFC_): `template`, `script`, `style`
1654+
- 🔠 _Interpolación_: `{{ }}`
1655+
- 📝 _Directivas_: `v-if`, `v-for`, `v-model`
1656+
- ⚡️ _Composition API_: `defineProps`, `defineEmits`
1657+
- 🎯 _Props_: `:propName="propValue"`
1658+
- 🎬 _Eventos_: `@click`, `@input`, `@my-event`
1659+
- 🎰 _Slots_: `<slot>` y `<template #slotName>`
1660+
- 🔄 _Lifecycle Hooks_: `onMounted`, `onBeforeUnmount`, etc
1661+
- 🎨 _Estilos_: `:class`, `:style`, `scoped`
1662+
- **Práctica**: Crear una ToDo App con Vue 3 y Vite
1663+
1664+
</v-clicks>
1665+
1666+
---
1667+
layout: quote
1668+
---
1669+
1670+
```bash
1671+
pnpm create vue@latest
1672+
# yarn dlx create-vue@latest # Yarn ^v4.11
1673+
# npm create vue@latest
1674+
```
1675+
1676+
<hr />
1677+
1678+
<v-clicks>
1679+
1680+
```bash
1681+
✔ Project name: ToDoApp
1682+
✔ Add TypeScript? Yes
1683+
✔ Add JSX Support? No
1684+
✔ Add Vue Router for Single Page Application development? Yes
1685+
✔ Add Pinia for state management? Yes
1686+
✔ Add Vitest for Unit testing? Yes
1687+
✔ Add an End-to-End Testing Solution? No
1688+
✔ Add ESLint for code quality? Yes
1689+
✔ Add Prettier for code formatting? Yes
1690+
✔ Add Vue DevTools 7 extension for debugging? Yes
1691+
1692+
Scaffolding project in ./todoapp...
1693+
Done.
1694+
```
1695+
1696+
</v-clicks>
16511697

1698+
---
1699+
---
16521700

16531701
---
16541702
layout: hero-image
@@ -1763,6 +1811,103 @@ class: text-center
17631811

17641812
# <logos-vue /> Vamos a seguir!! 🚀
17651813

1814+
---
1815+
layout: section
1816+
---
1817+
1818+
# Gestión de Estado con <logos-pinia /> Pinia
1819+
1820+
---
1821+
layout: quote
1822+
---
1823+
1824+
# ¿Qué es un gestor de estado? 🤔
1825+
1826+
---
1827+
layout: two-cols
1828+
title: Gestor de Estado
1829+
---
1830+
1831+
1832+
<v-clicks depth="2">
1833+
1834+
- 🏪 Almacén centralizado de datos
1835+
- 🔄 Flujo unidireccional de datos
1836+
- `actions` modifican el `state`
1837+
- El `state` actualiza las vistas
1838+
- Las vistas disparan `actions`
1839+
- 🎯 Beneficios:
1840+
- Mantenimiento más sencillo
1841+
- Debugging más fácil
1842+
- 🆕 Sucesor oficial de **Vuex**
1843+
- ⚡️ Más ligero y rápido
1844+
- 🦾 Mejor soporte TypeScript
1845+
- 🔧 API más simple
1846+
- 🧩 Modular por diseño
1847+
- 🛠️ DevTools integradas
1848+
1849+
</v-clicks>
1850+
1851+
::right::
1852+
1853+
<v-clicks>
1854+
1855+
<div class="grid items-center h-full">
1856+
<img src="/pinia.png" class="object-contain max-h-sm" />
1857+
</div>
1858+
1859+
</v-clicks>
1860+
---
1861+
layout: default
1862+
---
1863+
1864+
# <logos-pinia /> Pinia
1865+
````md magic-move
1866+
```ts
1867+
// stores/counter.ts
1868+
import { defineStore } from 'pinia'
1869+
1870+
export const useCounterStore = defineStore('counter', {
1871+
// Estado (reactive)
1872+
state: () => ({
1873+
count: 0
1874+
}),
1875+
// Getters (computed)
1876+
getters: {
1877+
doubleCount: (state) => state.count * 2
1878+
},
1879+
// Actions (methods)
1880+
actions: {
1881+
increment() {
1882+
this.count++
1883+
}
1884+
}
1885+
})
1886+
```
1887+
1888+
```ts
1889+
// stores/counter.ts
1890+
import { defineStore } from 'pinia'
1891+
1892+
export const useCounterStore = defineStore('counter', () => {
1893+
// Estado (reactive)
1894+
const count = ref(0)
1895+
1896+
// Getters (computed)
1897+
const doubleCount = computed(() => count.value * 2)
1898+
1899+
// Actions (methods)
1900+
const increment = () => count.value++
1901+
1902+
return {
1903+
count,
1904+
doubleCount,
1905+
increment
1906+
}
1907+
})
1908+
```
1909+
````
1910+
17661911
---
17671912
layout: custom-cover
17681913
background: vue-sticker.jpg

0 commit comments

Comments
 (0)