Skip to content

Commit 36be271

Browse files
Use consistent naming
1 parent fff7fe8 commit 36be271

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

examples/Example/Page/Todos/Todo.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ data AllTodos = AllTodos
4141
instance (Todos :> es) => HyperView AllTodos es where
4242
type Require AllTodos = '[TodoView]
4343

44-
newtype Action AllTodos = MkAction Shared.TodosAction
44+
newtype Action AllTodos = MkTodosAction Shared.TodosAction
4545
deriving newtype (Generic, ViewAction)
4646

47-
update (MkAction action) = do
47+
update (MkTodosAction action) = do
4848
case action of
4949
Shared.ClearCompleted ->
5050
todosView FilterAll <$> Shared.updateTodos Shared.ClearCompleted
@@ -72,8 +72,8 @@ todoForm filt = do
7272
let f :: TodoForm FieldName = fieldNames
7373
row ~ border 1 $ do
7474
el ~ pad 8 $ do
75-
button (MkAction $ Shared.ToggleAll filt) Icon.chevronDown ~ width 32 . hover (color Primary)
76-
form (MkAction Shared.SubmitTodo) ~ grow $ do
75+
button (MkTodosAction $ Shared.ToggleAll filt) Icon.chevronDown ~ width 32 . hover (color Primary)
76+
form (MkTodosAction Shared.SubmitTodo) ~ grow $ do
7777
field f.task $ do
7878
input TextInput ~ pad 12 @ placeholder "What needs to be done?" . value ""
7979

@@ -90,10 +90,10 @@ statusBar filt todos = do
9090
filterButton Active "Active"
9191
filterButton Completed "Completed"
9292
space
93-
button (MkAction Shared.ClearCompleted) ~ hover (color Primary) $ "Clear completed"
93+
button (MkTodosAction Shared.ClearCompleted) ~ hover (color Primary) $ "Clear completed"
9494
where
9595
filterButton f =
96-
button (MkAction $ Shared.Filter f) ~ selectedFilter f . pad (XY 4 0) . rounded 2
96+
button (MkTodosAction $ Shared.Filter f) ~ selectedFilter f . pad (XY 4 0) . rounded 2
9797
selectedFilter f =
9898
if f == filt then border 1 else id
9999

@@ -107,22 +107,22 @@ instance (Todos :> es) => HyperView TodoView es where
107107

108108
data Action TodoView
109109
= Edit FilterTodo Todo
110-
| MkTodoViewAction FilterTodo Shared.TodoAction
110+
| MkTodoAction FilterTodo Shared.TodoAction
111111
deriving (Generic, ViewAction)
112112

113113
update (Edit filt todo) = do
114114
pure $ todoEditView filt todo
115-
update (MkTodoViewAction filt action) =
115+
update (MkTodoAction filt action) =
116116
todoView filt <$> Shared.updateTodo action
117117

118118
todoView :: FilterTodo -> Todo -> View TodoView ()
119119
todoView filt todo = do
120120
row ~ border (TRBL 0 0 1 0) . pad 10 . showDestroyOnHover $ do
121121
target AllTodos $ do
122-
toggleCheckbox (MkAction . Shared.SetCompleted filt todo) todo.completed
122+
toggleCheckbox (MkTodosAction . Shared.SetCompleted filt todo) todo.completed
123123
el (text todo.task) @ onDblClick (Edit filt todo) ~ completed . pad (XY 18 4) . grow
124124
target AllTodos $ do
125-
button (MkAction $ Shared.Destroy filt todo) "" ~ cls "destroy-btn" . opacity 0 . hover (color Primary) . pad 4
125+
button (MkTodosAction $ Shared.Destroy filt todo) "" ~ cls "destroy-btn" . opacity 0 . hover (color Primary) . pad 4
126126
where
127127
completed = if todo.completed then Style.strikethrough else id
128128
showDestroyOnHover =
@@ -135,7 +135,7 @@ todoEditView :: FilterTodo -> Todo -> View TodoView ()
135135
todoEditView filt todo = do
136136
let f = fieldNames @TodoForm
137137
row ~ border (TRBL 0 0 1 0) . pad 10 $ do
138-
form (MkTodoViewAction filt $ Shared.SubmitEdit todo) ~ pad (TRBL 0 0 0 46) $ do
138+
form (MkTodoAction filt $ Shared.SubmitEdit todo) ~ pad (TRBL 0 0 0 46) $ do
139139
field f.task $ do
140140
input TextInput @ value todo.task . autofocus ~ pad 4
141141

examples/Example/Page/Todos/TodoCSS.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ data AllTodos = AllTodos
5555
instance (Todos :> es) => HyperView AllTodos es where
5656
type Require AllTodos = '[TodoView]
5757

58-
newtype Action AllTodos = MkAction Shared.TodosAction
58+
newtype Action AllTodos = MkTodosAction Shared.TodosAction
5959
deriving newtype (Generic, ViewAction)
6060

61-
update (MkAction action) = do
61+
update (MkTodosAction action) = do
6262
case action of
6363
Shared.ClearCompleted ->
6464
todosView FilterAll <$> Shared.updateTodos Shared.ClearCompleted
@@ -88,7 +88,7 @@ todosView filt todos = do
8888
label'
8989
@ class_ "toggle-all-label"
9090
. att "for" "toggle-all"
91-
. onClick (MkAction $ Shared.ToggleAll filt)
91+
. onClick (MkTodosAction $ Shared.ToggleAll filt)
9292
$ text "Mark all as complete"
9393

9494
ul' @ class_ "todo-list" $ do
@@ -100,7 +100,7 @@ todosView filt todos = do
100100
todoForm :: View AllTodos ()
101101
todoForm = do
102102
let f :: TodoForm FieldName = fieldNames
103-
form (MkAction Shared.SubmitTodo) $ do
103+
form (MkTodosAction Shared.SubmitTodo) $ do
104104
field f.task $ do
105105
Input (FieldName nm) <- context
106106
input' -- we use a custom input field, because the Hyperbole one overrides autocomplete
@@ -136,12 +136,12 @@ statusBar filt todos = do
136136
filterLi Active "Active"
137137
filterLi Completed "Completed"
138138
space
139-
button (MkAction Shared.ClearCompleted) @ class_ "clear-completed" $ "Clear completed"
139+
button (MkTodosAction Shared.ClearCompleted) @ class_ "clear-completed" $ "Clear completed"
140140
where
141141
filterLi f str =
142142
li' @ class_ "filter" . selectedFilter f $ do
143143
a
144-
@ onClick (MkAction $ Shared.Filter f)
144+
@ onClick (MkTodosAction $ Shared.Filter f)
145145
. att "href" "" -- harmless empty href is for the CSS
146146
$ text str
147147
selectedFilter f =
@@ -157,12 +157,12 @@ instance (Todos :> es) => HyperView TodoView es where
157157

158158
data Action TodoView
159159
= Edit FilterTodo Todo
160-
| MkTodoViewAction FilterTodo Shared.TodoAction
160+
| MkTodoAction FilterTodo Shared.TodoAction
161161
deriving (Generic, ViewAction)
162162

163163
update (Edit filt todo) = do
164164
pure $ todoEditView filt todo
165-
update (MkTodoViewAction filt action) = do
165+
update (MkTodoAction filt action) = do
166166
todoView filt <$> Shared.updateTodo action
167167

168168
todoView :: FilterTodo -> Todo -> View TodoView ()
@@ -176,20 +176,20 @@ todoView filt todo = do
176176
input'
177177
@ class_ "toggle"
178178
. att "type" "checkbox"
179-
. onClick (MkAction $ Shared.SetCompleted filt todo $ not todo.completed)
179+
. onClick (MkTodosAction $ Shared.SetCompleted filt todo $ not todo.completed)
180180
. checked todo.completed
181181

182182
label' @ class_ "label" . onDblClick (Edit filt todo) $ do
183183
text todo.task
184184

185185
target AllTodos $ do
186-
button (MkAction $ Shared.Destroy filt todo) @ class_ "destroy" $ ""
186+
button (MkTodosAction $ Shared.Destroy filt todo) @ class_ "destroy" $ ""
187187

188188
todoEditView :: FilterTodo -> Todo -> View TodoView ()
189189
todoEditView filt todo = do
190190
let f = fieldNames @TodoForm
191191
li' @ class_ "editing" $ do
192-
form (MkTodoViewAction filt $ Shared.SubmitEdit todo) $ do
192+
form (MkTodoAction filt $ Shared.SubmitEdit todo) $ do
193193
let taskField = Input f.task
194194
-- Instead of using the `field` FormField wrapper, we add the context manually
195195
-- and use a custom input field for maximum control over the generated HTML

0 commit comments

Comments
 (0)