Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 88 additions & 30 deletions projects/frontend/beginner/01-todo-list-app/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,92 @@
# To-do List App

## Idea
Build a simple to-do list application where users can add, complete, and delete tasks. Learn fundamentals of DOM manipulation, state management, and local storage.
> 🌐 **English** Β· [PortuguΓͺs](./README.pt-BR.md)

**Domain:** Frontend Β· **Level:** Beginner Β· **Estimated time:** 3–6 hours

## Overview

Build the classic to-do list: a single screen where a user types a task, presses Enter, sees it appear, checks it off when done, and removes it when it no longer matters. It looks trivial, but it is the smallest complete example of the core frontend loop β€” user input changes state, and state re-renders the UI. Everything is driven by an in-memory array of task objects that you persist to `localStorage` so the list survives a page reload. There is no server and no framework requirement; the interesting work is keeping your data model and what the user sees perfectly in sync.

## Prerequisites

- Basic HTML, CSS, and JavaScript (variables, arrays, functions)
- How to read from and write to the DOM, or a component framework of your choice
- Familiarity with array methods (`map`, `filter`, `find`)
- A code editor and a browser with dev tools

## Learning Objectives
- Understand DOM manipulation
- Implement state management basics
- Use local storage for persistence
- Build interactive UI
- Handle user events

## Implementation Tips
- Create task objects with id, title, completed status
- Store tasks in local storage
- Implement add task functionality
- Add complete/uncomplete toggle
- Implement delete task
- Add visual feedback for completed tasks
- Create clear all completed tasks button
- Add task count display
- Implement filter (all/active/completed)
- Add keyboard shortcuts (Enter to add)
- Create animations for task operations
- Add task editing capability
- Implement due dates (optional)
- Create themed styling

## Key Challenges
- Local storage synchronization
- State consistency
- UI responsiveness
- Local storage size limits
- Task ordering and sorting

By the end, you should be able to:

- Model UI as a function of a single source-of-truth state
- Add, toggle, edit, and delete items immutably rather than mutating in place
- Persist and rehydrate state with the `localStorage` API
- Render a filtered view (all / active / completed) without losing the underlying data
- Wire up keyboard and click interactions with accessible, labelled controls

## Functional Requirements

1. The user can type a task and add it by pressing Enter or clicking an Add button.
2. Empty or whitespace-only tasks must be rejected without adding a blank row.
3. Each task can be toggled between active and completed, with a clear visual difference.
4. The user can delete any individual task.
5. A live counter shows how many tasks remain active.
6. The user can filter the list by all, active, or completed.
7. The full list must survive a page refresh via `localStorage`.

## Suggested Milestones

1. **Milestone 1 β€” Add & render:** Capture input, push a task object to state, render the list.
2. **Milestone 2 β€” Toggle & delete:** Mark tasks done and remove them, updating the counter.
3. **Milestone 3 β€” Filter & persist:** Add the filter view and save/load from `localStorage`.

## Data & Interface Sketch

```text
Task
id: string (crypto.randomUUID())
title: string
completed: boolean
createdAt: number (Date.now())

Layout
+------------------------------------------+
| [ new task input............ ] [ Add ] |
+------------------------------------------+
| [x] Buy milk (del) |
| [ ] Call dentist (del) |
+------------------------------------------+
| 1 item left [All] [Active] [Completed] |
+------------------------------------------+
```

## Stretch Goals

- Inline edit: double-click a task title to rename it.
- Add a "Clear completed" button that removes all done tasks at once.
- Allow reordering tasks by drag-and-drop.
- Add a light/dark theme toggle stored alongside the tasks.

## Definition of Done

- [ ] Adding, toggling, and deleting update both the UI and stored state.
- [ ] Blank tasks cannot be added.
- [ ] The remaining-items counter is always accurate after any action.
- [ ] Filters change the visible list without discarding hidden tasks.
- [ ] Reloading the page restores the exact previous list.

## Common Pitfalls

- Mutating the state array directly instead of producing a new one, causing stale renders.
- Storing rendered HTML strings instead of a clean data model, making filters and edits painful.
- Forgetting to `JSON.parse` / `JSON.stringify` around `localStorage`, which only stores strings.
- Using array index as a key/id, which breaks after deletion and reordering.
- Skipping labels on the checkbox and buttons, leaving the app unusable with a screen reader.

## Resources

- [MDN: Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) β€” how `localStorage` works and its limits.
- [MDN: Introduction to the DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction) β€” reading and updating the page.
- [web.dev: Learn Accessibility β€” Forms](https://web.dev/learn/accessibility/forms) β€” labelling inputs and controls.
- [roadmap.sh: Frontend](https://roadmap.sh/frontend) β€” where these fundamentals sit in the bigger picture.
92 changes: 92 additions & 0 deletions projects/frontend/beginner/01-todo-list-app/README.pt-BR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Aplicativo de Lista de Tarefas

> 🌐 [English](./README.md) Β· **PortuguΓͺs**

**DomΓ­nio:** Frontend Β· **NΓ­vel:** Iniciante Β· **Tempo estimado:** 3–6 horas

## VisΓ£o Geral

Construa a clΓ‘ssica lista de tarefas: uma ΓΊnica tela onde o usuΓ‘rio digita uma tarefa, pressiona Enter, a vΓͺ aparecer, marca como concluΓ­da e a remove quando nΓ£o importa mais. Parece trivial, mas Γ© o menor exemplo completo do laΓ§o central do frontend β€” a entrada do usuΓ‘rio muda o estado, e o estado re-renderiza a UI. Tudo Γ© conduzido por um array de objetos de tarefa em memΓ³ria que vocΓͺ persiste no `localStorage` para que a lista sobreviva a um recarregamento. NΓ£o hΓ‘ servidor nem exigΓͺncia de framework; o trabalho interessante Γ© manter seu modelo de dados e o que o usuΓ‘rio vΓͺ perfeitamente sincronizados.

## PrΓ©-requisitos

- HTML, CSS e JavaScript bΓ‘sicos (variΓ‘veis, arrays, funΓ§Γ΅es)
- Como ler e escrever no DOM, ou um framework de componentes Γ  sua escolha
- Familiaridade com mΓ©todos de array (`map`, `filter`, `find`)
- Um editor de cΓ³digo e um navegador com ferramentas de desenvolvedor

## Objetivos de Aprendizado

Ao final, vocΓͺ deve ser capaz de:

- Modelar a UI como uma funΓ§Γ£o de um ΓΊnico estado como fonte da verdade
- Adicionar, alternar, editar e excluir itens de forma imutΓ‘vel em vez de mutar no lugar
- Persistir e reidratar o estado com a API `localStorage`
- Renderizar uma visΓ£o filtrada (todas / ativas / concluΓ­das) sem perder os dados subjacentes
- Conectar interaΓ§Γ΅es de teclado e clique com controles acessΓ­veis e rotulados

## Requisitos Funcionais

1. O usuΓ‘rio pode digitar uma tarefa e adicionΓ‘-la pressionando Enter ou clicando em um botΓ£o Adicionar.
2. Tarefas vazias ou sΓ³ com espaΓ§os devem ser rejeitadas sem adicionar uma linha em branco.
3. Cada tarefa pode ser alternada entre ativa e concluΓ­da, com uma diferenΓ§a visual clara.
4. O usuΓ‘rio pode excluir qualquer tarefa individual.
5. Um contador ao vivo mostra quantas tarefas permanecem ativas.
6. O usuΓ‘rio pode filtrar a lista por todas, ativas ou concluΓ­das.
7. A lista completa deve sobreviver a um recarregamento da pΓ‘gina via `localStorage`.

## Marcos Sugeridos

1. **Marco 1 β€” Adicionar e renderizar:** Capture a entrada, adicione um objeto de tarefa ao estado, renderize a lista.
2. **Marco 2 β€” Alternar e excluir:** Marque tarefas como feitas e remova-as, atualizando o contador.
3. **Marco 3 β€” Filtrar e persistir:** Adicione a visΓ£o de filtro e salve/carregue do `localStorage`.

## EsboΓ§o de Dados e Interface

```text
Tarefa
id: string (crypto.randomUUID())
title: string
completed: boolean
createdAt: number (Date.now())

Layout
+------------------------------------------+
| [ nova tarefa............... ] [Adicionar]|
+------------------------------------------+
| [x] Comprar leite (del) |
| [ ] Ligar para o dentista (del) |
+------------------------------------------+
| 1 item restante [Todas][Ativas][Feitas] |
+------------------------------------------+
```

## Desafios Extras

- EdiΓ§Γ£o em linha: dΓͺ um duplo clique no tΓ­tulo de uma tarefa para renomeΓ‘-la.
- Adicione um botΓ£o "Limpar concluΓ­das" que remove todas as tarefas feitas de uma vez.
- Permita reordenar tarefas com arrastar e soltar.
- Adicione um alternador de tema claro/escuro armazenado junto com as tarefas.

## DefiniΓ§Γ£o de Pronto

- [ ] Adicionar, alternar e excluir atualizam tanto a UI quanto o estado armazenado.
- [ ] Tarefas em branco nΓ£o podem ser adicionadas.
- [ ] O contador de itens restantes estΓ‘ sempre correto apΓ³s qualquer aΓ§Γ£o.
- [ ] Os filtros mudam a lista visΓ­vel sem descartar tarefas ocultas.
- [ ] Recarregar a pΓ‘gina restaura exatamente a lista anterior.

## Armadilhas Comuns

- Mutar o array de estado diretamente em vez de produzir um novo, causando renderizaΓ§Γ΅es desatualizadas.
- Armazenar strings de HTML renderizado em vez de um modelo de dados limpo, tornando filtros e ediΓ§Γ΅es penosos.
- Esquecer o `JSON.parse` / `JSON.stringify` em torno do `localStorage`, que sΓ³ armazena strings.
- Usar o Γ­ndice do array como chave/id, o que quebra apΓ³s exclusΓ£o e reordenaΓ§Γ£o.
- Pular rΓ³tulos nas caixas de seleΓ§Γ£o e botΓ΅es, deixando o app inutilizΓ‘vel com um leitor de tela.

## Recursos

- [MDN: Web Storage API](https://developer.mozilla.org/pt-BR/docs/Web/API/Web_Storage_API) β€” como o `localStorage` funciona e seus limites.
- [MDN: IntroduΓ§Γ£o ao DOM](https://developer.mozilla.org/pt-BR/docs/Web/API/Document_Object_Model/Introduction) β€” ler e atualizar a pΓ‘gina.
- [web.dev: Learn Accessibility β€” Forms](https://web.dev/learn/accessibility/forms) β€” rotular entradas e controles.
- [roadmap.sh: Frontend](https://roadmap.sh/frontend) β€” onde esses fundamentos se encaixam no quadro maior.
119 changes: 89 additions & 30 deletions projects/frontend/beginner/02-calculator-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,93 @@
# Calculator UI

## Idea
Create a functional calculator UI with basic arithmetic operations. Learn about event handling, string manipulation, and UI state management.
> 🌐 **English** Β· [PortuguΓͺs](./README.pt-BR.md)

**Domain:** Frontend Β· **Level:** Beginner Β· **Estimated time:** 3–6 hours

## Overview

Build a working calculator with a keypad, a display, and the four basic operations. The visual layout is the easy half; the real lesson is modelling calculator behaviour as a small state machine. A user taps `7`, `+`, `3`, `=` β€” each key means something different depending on what came before. You will track the current entry, the pending operator, and the accumulated value, and decide what every button does in every state. Get that model right and edge cases like chaining operations or pressing `=` twice stop being surprises.

## Prerequisites

- Basic HTML, CSS, and JavaScript
- CSS Grid or Flexbox for laying out a button pad
- Comfort with `switch`/conditional logic and number parsing
- A code editor and a browser with dev tools

## Learning Objectives
- Handle button click events
- Manage calculator state
- Implement operation logic
- Format number display
- Handle edge cases

## Implementation Tips
- Design calculator layout with buttons
- Implement number input handling
- Add arithmetic operations (+, -, *, /)
- Implement equals functionality
- Add clear/reset button
- Display current calculation
- Handle decimal numbers
- Implement backspace functionality
- Add operation chaining
- Implement percentage calculation
- Add keyboard support
- Create responsive design
- Add operation history (optional)
- Implement memory functions (optional)

## Key Challenges
- Floating point precision
- Operation chaining logic
- State management during calculations
- Keyboard vs mouse input
- Error handling (division by zero)

By the end, you should be able to:

- Represent interactive behaviour as explicit state rather than reading the display back as data
- Handle operator precedence for a simple left-to-right calculator and chained operations
- Format numeric output and avoid raw floating-point artefacts
- Support both mouse/touch and physical keyboard input for the same actions
- Guard against invalid states like multiple decimals or division by zero

## Functional Requirements

1. The calculator performs addition, subtraction, multiplication, and division.
2. The display shows the number being entered and the result after `=`.
3. Pressing an operator after a result uses that result as the new left operand (chaining).
4. A clear button resets all state; a backspace removes the last entered digit.
5. Only one decimal point is allowed per number.
6. Division by zero shows a clear error state rather than `Infinity` or `NaN`.
7. Number and operator keys on the physical keyboard mirror the on-screen buttons.

## Suggested Milestones

1. **Milestone 1 β€” Entry & display:** Build the keypad and show digits, decimals, and backspace.
2. **Milestone 2 β€” Single operation:** Store an operator and left operand, compute on `=`.
3. **Milestone 3 β€” Chaining & guards:** Chain operations, handle clear, decimals, and divide-by-zero.

## Data & Interface Sketch

```text
State
current: string (digits being typed, e.g. "12.5")
operator: "+"|"-"|"*"|"/"|null
accumulator: number|null
justEvaluated: boolean

Layout (4-column grid)
+-------------------------------+
| 123.45 | <- display
+-------------------------------+
| C | +/- | % | / |
| 7 | 8 | 9 | * |
| 4 | 5 | 6 | - |
| 1 | 2 | 3 | + |
| 0 | . | = |
+-------------------------------+
```

## Stretch Goals

- Add a running history/tape of previous calculations.
- Add memory keys (M+, M-, MR, MC).
- Support percentage relative to the current accumulator.
- Add a keyboard-only mode with visible focus indicators on each key.

## Definition of Done

- [ ] All four operations produce correct results, including chained sequences.
- [ ] The display never shows `NaN`, `Infinity`, or `undefined`.
- [ ] Clear fully resets state; backspace edits the current entry only.
- [ ] Keyboard and on-screen buttons behave identically.
- [ ] Only one decimal point can be entered per number.

## Common Pitfalls

- Using the display text as your source of truth instead of a separate state model.
- Concatenating strings for math and getting `"1" + "2" = "12"` instead of `3`.
- Ignoring floating-point rounding, so `0.1 + 0.2` shows `0.30000000000000004`.
- Forgetting the "just evaluated" flag, so the next digit appends to the result instead of starting fresh.
- Leaving buttons as non-focusable `<div>`s, breaking keyboard access.

## Resources

- [MDN: Number.prototype.toFixed()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) β€” controlling decimal display.
- [MDN: CSS Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout) β€” laying out the keypad.
- [0.30000000000000004.com](https://0.30000000000000004.com/) β€” why floating-point math misbehaves.
- [MDN: KeyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) β€” mapping physical keys to actions.
Loading
Loading