@@ -62,6 +62,23 @@ by opening a question you help _everyone_ learn more effectively!
62
62
63
63
## _ How?_
64
64
65
+ ### Testing?
66
+
67
+ _ Before_ diving into _ building_ the Todo List App,
68
+ we need to consider how we are going to _ test_ it.
69
+ By ensuring that we follow ** TDD** from the _ start_ of an App,
70
+ we won't need to "correct" any "** bad habits** ".
71
+
72
+ We will be using ** Tape** and ** JSDOM** for testing
73
+ both our functions and the final application.
74
+ If you are ` new ` to either of these tools,
75
+ please see:
76
+ [ https://github.com/dwyl/**learn-tape ** ] ( https://github.com/dwyl/learn-tape )
77
+ and
78
+ [ front-end-with-tape.md] ( https://github.com/dwyl/learn-tape/blob/master/front-end-with-tape.md )
79
+
80
+ ### _ Analyse_
81
+
65
82
Our _ first_ step is to _ analyse_ the required functionality of a Todo List.
66
83
67
84
### Todo List _ Basic_ Functionality
@@ -157,6 +174,9 @@ each `case` is functionality that is _specific_ to the Todo List App. <br />
157
174
The ` view ` function _ invokes_ several "helper" functions
158
175
which create HTML elements e.g: ` div ` & ` <button> ` ; these _ can_ be generalised.
159
176
177
+
178
+ ### HTML Elements (Functions)
179
+
160
180
The _ requirements_ for the HTML elements we _ need_ for a Todo List
161
181
can be _ gathered_ by viewing the source code of the VanillaJS TodoMVC
162
182
in a web browser:
@@ -210,17 +230,54 @@ This is a "copy-paste" of the _generated_ code including the Todo items:
210
230
</section >
211
231
```
212
232
233
+ Let's split each one of these elements into it's own ` function `
234
+ (_ with any necessary "helpers"_ ) in the order they appear.
213
235
236
+ #### ` <section> `
214
237
238
+ The _ first_ HTML we encounter in the TodoMVC app is
239
+ ` <section> ` .
240
+ ` <section> ` represents a standalone section — which doesn't have
241
+ a more specific semantic element to represent it —
242
+ it's an alternative way to group elements to a ` <div> ` .
243
+
244
+ > info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section <br />
245
+ > difference:
246
+ https://stackoverflow.com/questions/6939864/what-is-the-difference-between-section-and-div
247
+
248
+ As with other "grouping" or "container" HTML elements,
249
+ our ` section ` function (_ which will create the_ ` <section> ` _ DOM node_ )
250
+ will be a function with _ two_ arguments:
251
+ + ` attributes ` - a list (Array) of HTML attributes/properties
252
+ e.g: ` id ` or ` class ` .
253
+ + ` children ` - a list (Array) of child HTML elements
254
+ (_ nested within the_ ` <section> ` )
255
+
256
+ Each of these function arguments will be "_ applied_ " to the HTML element.
257
+ We therefore need a pair of "helper" functions (_ one for each argument_ ).
215
258
216
- ### ` mount `
217
259
218
- ### ``
219
260
220
261
221
262
222
263
223
264
265
+ Section in Elm: http://package.elm-lang.org/packages/elm-lang/html/2.0.0/Html
266
+ <br />
267
+ Demo: https://ellie-app.com/LTtNVQjfWVa1
268
+ ![ ellie-elm-section] ( https://user-images.githubusercontent.com/194400/42708957-bbcc1020-86d6-11e8-97bf-f2f3a1c6fdea.png )
269
+
270
+
271
+
272
+
273
+ ### ` mount `
274
+
275
+ The ` mount ` function is the "glue" or "wiring" function that
276
+ connects the ` model ` , ` update ` and ` view ` ; we _ can_ ` generalise ` it.
277
+
278
+
279
+
280
+
224
281
225
282
226
283
0 commit comments