11<template >
2- <div class =" filter-container" >
3- <button
4- v-for =" option in filterOptions"
5- :key =" option.value"
6- @click =" store.setFilter(option.value)"
7- :class =" { active: store.filter === option.value }"
8- class =" filter-button"
9- >
10- {{ option.label }}
11- </button >
12- </div >
13- </template >
14-
15- <script setup lang="ts">
16- import { useTodoStore } from ' ~/stores/todo-store'
17- import type { FilterType } from ' ~/stores/todo-store'
18-
19- const store = useTodoStore ()
20-
21- const filterOptions = [
22- { value: ' all' as FilterType , label: ' All' },
23- { value: ' active' as FilterType , label: ' Active' },
24- { value: ' completed' as FilterType , label: ' Completed' }
25- ]
26- </script >
27-
28- <style scoped>
29- .filter-container {
30- display : flex ;
31- justify-content : center ;
32- gap : 1rem ;
33- margin : 1rem 0 ;
34- }
35-
36- .filter-button {
37- padding : 0.5rem 1rem ;
38- border : 1px solid #ddd ;
39- border-radius : 4px ;
40- background : white ;
41- cursor : pointer ;
42- transition : all 0.2s ;
43- }
44-
45- .filter-button :hover {
46- background : #f5f5f5 ;
47- }
48-
49- .filter-button.active {
50- background : #4CAF50 ;
51- color : white ;
52- border-color : #4CAF50 ;
53- }
54- </style >
2+ <div class =" filter-container" >
3+ <button v-for =" option in filterOptions" :key =" option.value" @click =" store.setFilter(option.value)"
4+ :class =" { active: store.filter === option.value }" class =" filter-button" >
5+ {{ option.label }}
6+ </button >
7+ </div >
8+ </template >
9+
10+ <script setup lang="ts">
11+ import { useTodoStore } from ' ~/stores/todo-store'
12+ import type { FilterType } from ' ~/types/index'
13+
14+ const store = useTodoStore ()
15+
16+ const filterOptions = [
17+ { value: ' all' as FilterType , label: ' All' },
18+ { value: ' active' as FilterType , label: ' Active' },
19+ { value: ' completed' as FilterType , label: ' Completed' }
20+ ]
21+ </script >
22+
23+ <style scoped>
24+ .filter-container {
25+ display : flex ;
26+ justify-content : center ;
27+ gap : 1rem ;
28+ margin : 1rem 0 ;
29+ }
30+
31+ .filter-button {
32+ padding : 0.5rem 1rem ;
33+ border : 1px solid #ddd ;
34+ border-radius : 4px ;
35+ background : white ;
36+ cursor : pointer ;
37+ transition : all 0.2s ;
38+ }
39+
40+ .filter-button :hover {
41+ background : #f5f5f5 ;
42+ }
43+
44+ .filter-button.active {
45+ background : #4CAF50 ;
46+ color : white ;
47+ border-color : #4CAF50 ;
48+ }
49+ </style >
0 commit comments