Last active
May 9, 2022 06:17
-
-
Save danneu/77d9000d390098064cc30f66353a5562 to your computer and use it in GitHub Desktop.
Revisions
-
danneu revised this gist
May 9, 2022 . No changes.There are no files selected for viewing
-
danneu revised this gist
May 9, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -79,3 +79,5 @@ parcel build index.html # Creates ./dist folder with html, js, css files ``` Parcel docs: https://parceljs.org/getting-started/webapp/ -
danneu revised this gist
May 9, 2022 . 2 changed files with 56 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Project structure so far: └── Main.elm ``` Save Elm boilerplate to `src/Main.elm`: (See attached `1-Main.elm` file) Save this to index.html: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ module Main exposing (main) import Browser import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) type alias Model = { draft : String } type alias Flags = { initDraft : String } init : Flags -> ( Model, Cmd Msg ) init flags = ( { draft = flags.initDraft } , Cmd.none ) type Msg = DraftChanged String update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of DraftChanged value -> ( { model | draft = value } , Cmd.none ) view : Model -> Html Msg view model = div [] [ textarea [ onInput DraftChanged ] [ text model.draft ] ] main : Program Flags Model Msg main = Browser.element { init = init , view = view , update = update , subscriptions = \_ -> Sub.none } -
danneu revised this gist
May 9, 2022 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,3 +72,10 @@ parcel index.html (Or use `npx parcel index.html` if you installed parcel locally with `npm install --save-dev parcel`. `npx` uses the parcel binary found in your project's `./node_modules/.bin` since it otherwise isn't in your $PATH.) When you're ready for a production build: ```shell parcel build index.html # Creates ./dist folder with html, js, css files ``` -
danneu revised this gist
May 9, 2022 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,21 @@ # Elm quickstart with Parcel Create project boilerplate: ```shell mkdir my-elm-project cd my-elm-project elm init touch src/Main.elm # This is where we put our Elm app echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel # Or install project-locally with `npm install --save-dev parcel` touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html touch index.js npm install uuid # Let's use an NPM library for demonstration ``` -
danneu revised this gist
May 9, 2022 . 1 changed file with 36 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,32 +4,59 @@ mkdir my-elm-project cd my-elm-project elm init touch src/Main.elm # This is where we put our Elm app echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel # Or install project-locally with `npm install --save-dev parcel` touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html touch index.js npm install uuid # Let's use an NPM library for demonstration ``` Project structure so far: ``` . ├── elm.json ├── example.scss ├── index.html ├── index.js ├── package.json └── src └── Main.elm ``` Save Elm boilerplate to `src/Main.elm`: https://ellie-app.com/hphB4mjXYBpa1 Save this to index.html: ```html <!DOCTYPE html> <head> <link rel="stylesheet" href="./example.scss" /> </head> <body> <main></main> <script type="module" src="index.js"></script> </body> ``` Inside `index.js` we mount our Elm app to `<main>` and can import NPM libraries and use them: ```javascript // index.js import { Elm } from './src/Main.elm' import * as uuid from 'uuid' const app = Elm.Main.init({ node: document.querySelector('main'), flags: { // Example of using npm library to pass value into Elm via flag initDraft: uuid.v4() } }) ``` Use `parcel` to run dev server: ```shell @@ -39,5 +66,3 @@ parcel index.html (Or use `npx parcel index.html` if you installed parcel locally with `npm install --save-dev parcel`. `npx` uses the parcel binary found in your project's `./node_modules/.bin` since it otherwise isn't in your $PATH.) -
danneu revised this gist
May 9, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ parcel index.html # Navigate browser to http://localhost:1234 ``` (Or use `npx parcel index.html` if you installed parcel locally with `npm install --save-dev parcel`. `npx` uses the parcel binary found in your project's `./node_modules/.bin` since it otherwise isn't in your $PATH.) Read more about parcel: https://parceljs.org/getting-started/webapp/ -
danneu revised this gist
May 9, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ mkdir my-elm-project cd my-elm-project elm init echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel # Or install project-locally with `npm install --save-dev parcel` touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html ``` @@ -37,5 +37,7 @@ parcel index.html # Navigate browser to http://localhost:1234 ``` (Or use `npx parcel index.html` if you installed parcel locally with `npm install --save-dev parcel`. `npx` uses the parcel binary found in your project's `./node_modules/.bin`) Read more about parcel: https://parceljs.org/getting-started/webapp/ -
danneu revised this gist
May 9, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ mkdir my-elm-project cd my-elm-project elm init echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html ``` @@ -37,3 +37,5 @@ parcel index.html # Navigate browser to http://localhost:1234 ``` Read more about parcel: https://parceljs.org/getting-started/webapp/ -
danneu revised this gist
May 9, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ mkdir my-elm-project cd my-elm-project elm init echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel # OR npm install --save-dev parcel touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html ``` -
danneu revised this gist
May 9, 2022 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ mkdir my-elm-project cd my-elm-project elm init echo '{}' > package.json # Empty package.json to install NPM libs npm install -g parcel touch example.scss # Just to show that Parcel automatically handles things like .scss touch index.html ``` @@ -17,7 +17,7 @@ Save this to index.html: ```html <!doctype html> <head> <link rel="stylesheet" href="./example.scss" /> <script src="./src/Main.elm"></script> </head> <body> -
danneu revised this gist
May 9, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Save this to index.html: <!doctype html> <head> <link rel="stylesheet" href="./example.css" /> <script src="./src/Main.elm"></script> </head> <body> <main/> -
danneu revised this gist
May 9, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Elm quickstart with Parcel ```shell mkdir my-elm-project cd my-elm-project -
danneu created this gist
May 9, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ ```shell mkdir my-elm-project cd my-elm-project elm init echo '{}' > package.json npm install -g parcel touch example.css touch index.html ``` Save Elm boilerplate to `src/Main.elm`: https://ellie-app.com/hphB4mjXYBpa1 Save this to index.html: ```html <!doctype html> <head> <link rel="stylesheet" href="./example.css" /> <script src="./src/Main.elm" /> </head> <body> <main/> <script> const app = Elm.Main.init({ node: document.querySelector('main') }) </script> </body> ``` Use `parcel` to run dev server: ```shell parcel index.html # Navigate browser to http://localhost:1234 ```