Skip to content

Commit

Permalink
Elm docs (#770)
Browse files Browse the repository at this point in the history
* Elm docs

* Update elm.md
  • Loading branch information
mischnic authored Dec 8, 2020
1 parent 0875227 commit 93b92af
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
79 changes: 79 additions & 0 deletions src/languages/elm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
layout: layout.njk
eleventyNavigation:
key: languages-elm
title: <img src="/assets/lang-icons/elm.svg" alt=""/> Elm
order: 9
---

You can import [Elm](https://elm-lang.org/) files like any another Javascript files.

The npm package `elm` needs to be manually installed beforehand. You'll also need a `elm.json` configuration file (run `yarn elm init -y` to get started and modify it if neccessary).

{% sample null, "column" %}
{% samplefile "index.html" %}

```html
<!DOCTYPE html>
<div id="root"></div>
<script src="index.js"></script>
```

{% endsamplefile %}

{% samplefile "index.js" %}

```js
import { Elm } from "./Main.elm";

Elm.Main.init({ node: document.getElementById("root") });
```

{% endsamplefile %}

{% samplefile "Main.elm" %}

```elm
module Main exposing (..)

import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)

main =
Browser.sandbox { init = init, update = update, view = view }

type alias Model = Int

init : Model
init =
0

type Msg = Increment | Decrement

update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
model + 1

Decrement ->
model - 1


view : Model -> Html Msg
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (String.fromInt model) ]
, button [ onClick Increment ] [ text "+" ]
]
```

{% endsamplefile %}

{% endsample %}

## Time-travelling debuggger

Elm's debug mode is automatically enabled when not building for production (it is disabled automatically with `parcel build`). You can set the environment variable `PARCEL_ELM_NO_DEBUG=1` to disable it even in development mode.
2 changes: 1 addition & 1 deletion src/languages/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ eleventyNavigation:
summary: Explains the different ways TypeScript can be transpiled
---

Typescript works out of the box with Parcel, but there ...
Typescript works out of the box with Parcel, but you have multiple options:

## Babel

Expand Down

1 comment on commit 93b92af

@vercel
Copy link

@vercel vercel bot commented on 93b92af Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.