diff --git a/src/Pages/Software/elm/en/main.md b/src/Pages/Software/elm/en/main.md index 474c9fb..2c76eba 100644 --- a/src/Pages/Software/elm/en/main.md +++ b/src/Pages/Software/elm/en/main.md @@ -1,3 +1,4 @@ ### Elm -* [Formatting](./formatting) \ No newline at end of file +* [Formatting](./formatting) +* [Maybe.map](./maybemap) \ No newline at end of file diff --git a/src/Pages/Software/elm/en/maybemap.md b/src/Pages/Software/elm/en/maybemap.md new file mode 100644 index 0000000..5621eff --- /dev/null +++ b/src/Pages/Software/elm/en/maybemap.md @@ -0,0 +1,44 @@ +Elm - Maybe Map +=============== + +Here, a tooltip title attribute needs to be added if it is **Just**. + +```elm +let + divAttributes = + [ HA.classList + [ ( "my-div", True ) ] + ] + + combinedAttributes = + case settings.tooltip of + Just tooltip -> + divAttributes ++ [ HA.title tooltip ] + + Nothing -> + divAttributes +in +H.div + combinedAttributes + [ content ] + +``` + +This can be easier written with the [Maybe.map](https://package.elm-lang.org/packages/elm/core/latest/Maybe#map) and [Maybe.withDefault](https://package.elm-lang.org/packages/elm/core/latest/Maybe#withDefault) functions. + +```elm + +let + divAttributes = + [ HA.classList + [ ( "my-div", True ) ] + ] + + tooltipAttribute = + Maybe.map (\tooltip -> [ HA.title tooltip ]) settings.tooltip |> Maybe.withDefault [] + +in +H.div + (divAttributes ++ tooltipAttribute) + [ content ] +``` \ No newline at end of file diff --git a/src/Pages/Software/elm/nl/main.md b/src/Pages/Software/elm/nl/main.md index 474c9fb..2c76eba 100644 --- a/src/Pages/Software/elm/nl/main.md +++ b/src/Pages/Software/elm/nl/main.md @@ -1,3 +1,4 @@ ### Elm -* [Formatting](./formatting) \ No newline at end of file +* [Formatting](./formatting) +* [Maybe.map](./maybemap) \ No newline at end of file diff --git a/src/Pages/Software/elm/nl/maybemap.md b/src/Pages/Software/elm/nl/maybemap.md new file mode 100644 index 0000000..c3f653c --- /dev/null +++ b/src/Pages/Software/elm/nl/maybemap.md @@ -0,0 +1,44 @@ +Elm - Maybe Map +=============== + +hier moet een tooltip als title attribuut worden toegevoegd als deze **Just** is. + +```elm +let + divAttributes = + [ HA.classList + [ ( "my-div", True ) ] + ] + + combinedAttributes = + case settings.tooltip of + Just tooltip -> + divAttributes ++ [ HA.title tooltip ] + + Nothing -> + divAttributes +in +H.div + combinedAttributes + [ content ] + +``` + +Dit kan makkelijker met de [Maybe.map](https://package.elm-lang.org/packages/elm/core/latest/Maybe#map) en [Maybe.withDefault](https://package.elm-lang.org/packages/elm/core/latest/Maybe#withDefault) functies. + +```elm + +let + divAttributes = + [ HA.classList + [ ( "my-div", True ) ] + ] + + tooltipAttribute = + Maybe.map (\tooltip -> [ HA.title tooltip ]) settings.tooltip |> Maybe.withDefault [] + +in +H.div + (divAttributes ++ tooltipAttribute) + [ content ] +``` \ No newline at end of file diff --git a/src/Routers.js b/src/Routers.js index e3d51db..7f3431f 100644 --- a/src/Routers.js +++ b/src/Routers.js @@ -8,7 +8,7 @@ export const elmRoutes = languages.map(lang => { const main = } /> // Pages within Elm. - const md = ['formatting']; + const md = ['formatting', 'maybemap']; const entries = md.map(entry => { const path = `/${lang}/software/elm/${entry}`; const mdPath = `Software/elm/${lang}/${entry}.md`;