Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elm-land/elm-land into fix/bug-layo…
Browse files Browse the repository at this point in the history
…ut-using-type-variables
  • Loading branch information
ryan-haskell committed Aug 29, 2023
2 parents 4644ffe + e8ef725 commit e8f0fc3
Show file tree
Hide file tree
Showing 32 changed files with 391 additions and 48 deletions.
4 changes: 2 additions & 2 deletions README.md
@@ -1,7 +1,7 @@
# Elm Land


[![Npm package version](https://badgen.net/npm/v/elm-land)](https://npmjs.com/package/elm-land) [![elm-land](https://github.com/elm-land/elm-land/actions/workflows/node.js.yml/badge.svg?)](https://github.com/elm-land/elm-land/actions/workflows/node.js.yml) [![BSD-3 Clause](https://img.shields.io/github/license/elm-land/elm-land)](https://github.com/elm-land/elm-land/blob/main/LICENSE)
[![Npm package version](https://badgen.net/npm/v/elm-land/latest)](https://npmjs.com/package/elm-land) [![elm-land](https://github.com/elm-land/elm-land/actions/workflows/node.js.yml/badge.svg?)](https://github.com/elm-land/elm-land/actions/workflows/node.js.yml) [![BSD-3 Clause](https://img.shields.io/github/license/elm-land/elm-land)](https://github.com/elm-land/elm-land/blob/main/LICENSE)

[![Discord](https://badgen.net/discord/members/vnmYFfySbH?icon=discord&label)](https://join.elm.land) [![Twitter](https://badgen.net/badge/icon/twitter?icon=twitter&label&color=00acee)](https://twitter.com/elmland_) [![GitHub](https://badgen.net/badge/icon/github?icon=github&label&color=4078c0)](https://www.github.com/elm-land/elm-land)

Expand All @@ -13,7 +13,7 @@
The code for this GitHub project is broken down into smaller projects:

- __[elm-land](./projects/cli/)__ - The CLI tool, available at [npmjs.org/elm-land](https://npmjs.org/elm-land)
- __[@elm-land/www](./docs/)__ - The official website, available at [elm.land](https://elm.land)
- __[@elm-land/docs](./docs/)__ - The official website, available at [elm.land](https://elm.land)


### Tooling
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/config.js
@@ -1,4 +1,4 @@
const version = '0.19.1'
const version = '0.19.2'

const sidebar = [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/cli.md
Expand Up @@ -172,7 +172,7 @@ Here's example output of what you'd see if you ran this command in the ["Pages a

```txt
🌈 Elm Land (v0.19.1) found 5 pages in your application
🌈 Elm Land (v0.19.2) found 5 pages in your application
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
src/Pages/Home_.elm ............... http://localhost:1234/
src/Pages/SignIn.elm .............. http://localhost:1234/sign-in
Expand Down
25 changes: 25 additions & 0 deletions docs/examples/index.md
Expand Up @@ -32,3 +32,28 @@ __Created by:__ [Ryan](https://github.com/ryannhg)

![Screenshot](https://github.com/elm-land/2048/raw/main/static/screenshot.png)


### Realworld App


On a Twitch stream ([@ryan_the_rhg](https://twitch.tv/ryan_the_rhg)), we upgraded the Conduit RealWorld app from elm-spa to Elm Land. This app is a Medium-like clone, and features REST API calls, user login, and more:

__Created by:__ [Ryan](https://github.com/ryannhg)

[Live demo](https://realworld.elm.land/)[Source code](https://github.com/elm-land/realworld-app)

![Screenshot](https://realworld.elm.land/screenshot.png)


### Movies

On another Twitch stream ([@ryan_the_rhg](https://twitch.tv/ryan_the_rhg)), we created an implementation for the [Taste.js Movies App](https://tastejs.com/movies/index.html) for Elm Land. This features environment variables, REST API calls, JSON decoding, and more:

__Created by:__ [Ryan](https://github.com/ryannhg)

[Live demo](https://movies.elm.land/)[Source code](https://github.com/elm-land/movies)

![Screenshot](https://movies.elm.land/screenshot.png)



2 changes: 1 addition & 1 deletion docs/guide/deploying.md
Expand Up @@ -16,7 +16,7 @@ elm-land build

```txt
🌈 Elm Land (v0.19.1) build was successful.
🌈 Elm Land (v0.19.2) build was successful.
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/pages-and-routes.md
Expand Up @@ -326,7 +326,7 @@ elm-land routes

```txt
🌈 Elm Land (v0.19.1) found 6 pages in your application
🌈 Elm Land (v0.19.2) found 6 pages in your application
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
src/Pages/Home_.elm ........................... /
src/Pages/SignIn.elm .......................... /sign-in
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/rest-apis.md
Expand Up @@ -31,7 +31,7 @@ Running those 3 commands will run our new Elm Land project at `http://localhost:

## Commands and subscriptions

In previous guides, we used the `elm add` command to create new pages. Let's use that command again to replace our initial homepage, but this time with `page:element`.
In previous guides, we used the `elm-land add` command to create new pages. Let's use that command again to replace our initial homepage, but this time with `page:element`.

This new "element" page will allow us to return HTTP requests from our `init` and `update` functions via `Cmd Msg`.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/user-auth.md
Expand Up @@ -2343,4 +2343,4 @@ viewSignOutButton user =
### That's it!

We just added user authentication to an app, introduced
The complete source code for this example is [available here on GitHub]().
The complete source code for this example is [available here on GitHub](https://github.com/elm-land/elm-land/tree/main/examples/05-user-auth).
7 changes: 7 additions & 0 deletions examples/17-shared-subscriptions/.gitignore
@@ -0,0 +1,7 @@
/dist
/.elm-land
/.env
/elm-stuff
/node_modules
.DS_Store
*.pem
26 changes: 26 additions & 0 deletions examples/17-shared-subscriptions/elm-land.json
@@ -0,0 +1,26 @@
{
"app": {
"elm": {
"development": { "debugger": true },
"production": { "debugger": false }
},
"env": [],
"html": {
"attributes": {
"html": { "lang": "en" },
"head": {}
},
"title": "Elm Land",
"meta": [
{ "charset": "UTF-8" },
{ "http-equiv": "X-UA-Compatible", "content": "IE=edge" },
{ "name": "viewport", "content": "width=device-width, initial-scale=1.0" }
],
"link": [],
"script": []
},
"router": {
"useHashRouting": false
}
}
}
25 changes: 25 additions & 0 deletions examples/17-shared-subscriptions/elm.json
@@ -0,0 +1,25 @@
{
"type": "application",
"source-directories": [
"src",
".elm-land/src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm/url": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
80 changes: 80 additions & 0 deletions examples/17-shared-subscriptions/src/Pages/Home_.elm
@@ -0,0 +1,80 @@
module Pages.Home_ exposing (Model, Msg, page)

import Effect exposing (Effect)
import Html
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)


page : Shared.Model -> Route () -> Page Model Msg
page shared route =
Page.new
{ init = init
, update = update
, subscriptions = subscriptions
, view = view shared
}



-- INIT


type alias Model =
{}


init : () -> ( Model, Effect Msg )
init () =
( {}
, Effect.none
)



-- UPDATE


type Msg
= ExampleMsgReplaceMe


update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
ExampleMsgReplaceMe ->
( model
, Effect.none
)



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none



-- VIEW


view : Shared.Model -> Model -> View Msg
view shared model =
let
toStr field =
field shared |> String.fromInt
in
{ title = "Pages.Home_"
, body =
[ "Window Size: "
++ toStr .windowWidth
++ " × "
++ toStr .windowHeight
|> Html.text
]
}
85 changes: 85 additions & 0 deletions examples/17-shared-subscriptions/src/Shared.elm
@@ -0,0 +1,85 @@
module Shared exposing
( Flags, decoder
, Model, Msg
, init, update, subscriptions
)

{-|
@docs Flags, decoder
@docs Model, Msg
@docs init, update, subscriptions
-}

import Browser.Events
import Effect exposing (Effect)
import Json.Decode
import Route exposing (Route)
import Route.Path
import Shared.Model
import Shared.Msg exposing (Msg(..))



-- FLAGS


type alias Flags =
Model


decoder : Json.Decode.Decoder Flags
decoder =
Json.Decode.map2 Shared.Model.Model
(Json.Decode.field "width" Json.Decode.int)
(Json.Decode.field "height" Json.Decode.int)



-- INIT


type alias Model =
Shared.Model.Model


init : Result Json.Decode.Error Flags -> Route () -> ( Model, Effect Msg )
init flagsResult route =
let
flags : Flags
flags =
case flagsResult of
Ok size ->
size

Err _ ->
{ windowWidth = 0, windowHeight = 0 }
in
( flags, Effect.none )



-- UPDATE


type alias Msg =
Shared.Msg.Msg


update : Route () -> Msg -> Model -> ( Model, Effect Msg )
update route msg model =
case msg of
WindowResized w h ->
( Shared.Model.Model w h
, Effect.none
)



-- SUBSCRIPTIONS


subscriptions : Route () -> Model -> Sub Msg
subscriptions route model =
Browser.Events.onResize WindowResized
14 changes: 14 additions & 0 deletions examples/17-shared-subscriptions/src/Shared/Model.elm
@@ -0,0 +1,14 @@
module Shared.Model exposing (Model)

{-| -}


{-| Normally, this value would live in "Shared.elm"
but that would lead to a circular dependency import cycle.
For that reason, both `Shared.Model` and `Shared.Msg` are in their
own file, so they can be imported by `Effect.elm`
-}
type alias Model =
{ windowWidth : Int, windowHeight : Int }
14 changes: 14 additions & 0 deletions examples/17-shared-subscriptions/src/Shared/Msg.elm
@@ -0,0 +1,14 @@
module Shared.Msg exposing (Msg(..))

{-| -}


{-| Normally, this value would live in "Shared.elm"
but that would lead to a circular dependency import cycle.
For that reason, both `Shared.Model` and `Shared.Msg` are in their
own file, so they can be imported by `Effect.elm`
-}
type Msg
= WindowResized Int Int
3 changes: 3 additions & 0 deletions examples/17-shared-subscriptions/src/interop.ts
@@ -0,0 +1,3 @@
export const flags = () => { // env to be included as an argument
return { width: window.innerWidth, height: window.innerHeight }
}
1 change: 1 addition & 0 deletions examples/README.md
Expand Up @@ -20,6 +20,7 @@
- [SCSS and assets](./14-scss-and-assets/)
- [Custom 404 pages](./15-custom-404-pages/)
- [Hash-bashed routing](./16-hash-based-routing/)
- [Shared subscriptions](./17-shared-subscriptions/)

## 1. Hello world!

Expand Down
2 changes: 1 addition & 1 deletion projects/cli/README.md
Expand Up @@ -17,7 +17,7 @@ The `elm-land` CLI comes with everything you need to create your next web applic
```
$ elm-land
🌈 Welcome to Elm Land! (v0.19.1)
🌈 Welcome to Elm Land! (v0.19.2)
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
Here are the available commands:
Expand Down
4 changes: 2 additions & 2 deletions projects/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "elm-land",
"version": "0.19.1",
"version": "0.19.2",
"description": "Reliable web apps for everyone",
"main": "index.js",
"types": "./index.d.ts",
Expand Down

0 comments on commit e8f0fc3

Please sign in to comment.