about summary refs log tree commit diff
path: root/client/src/State.elm
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T13·23+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T13·23+0100
commit803db7a5b2f1b8fadda45efce56d6c31a74a1e08 (patch)
tree9bd7f6b14686f9b30d2f59d992dd0bcb7b114f42 /client/src/State.elm
parent699892883ceaffb64e0d9b9aaab67313a60a5428 (diff)
Support printing user's itinerary
- Define print.css with media=print type (note: could've been handled with
  @media queries)
- Define printPage port to interop with window.print() JS function
- Support UI.wrapNoPrint to wrap components with a the no-print CSS
Diffstat (limited to 'client/src/State.elm')
-rw-r--r--client/src/State.elm11
1 files changed, 9 insertions, 2 deletions
diff --git a/client/src/State.elm b/client/src/State.elm
index d3db7ddf2967..a8970df24d03 100644
--- a/client/src/State.elm
+++ b/client/src/State.elm
@@ -1,4 +1,4 @@
-module State exposing (..)
+port module State exposing (..)
 
 import Array exposing (Array)
 import Browser
@@ -39,6 +39,7 @@ type Msg
     | UpdateTripComment String
     | ClearErrors
     | ToggleLoginForm
+    | PrintPage
       -- SPA
     | LinkClicked Browser.UrlRequest
     | UrlChanged Url.Url
@@ -476,11 +477,14 @@ userHome flags url key =
     )
 
 
+port printPage : () -> Cmd msg
+
+
 {-| The initial state for the application.
 -}
 init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
 init flags url key =
-    prod flags url key
+    userHome flags url key
 
 
 {-| Now that we have state, we need a function to change the state.
@@ -591,6 +595,9 @@ update msg model =
             , Cmd.none
             )
 
+        PrintPage ->
+            ( model, printPage () )
+
         LinkClicked urlRequest ->
             case urlRequest of
                 Browser.Internal url ->