mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-27 03:14:25 +03:00
Render example code the standard way
This commit is contained in:
parent
04257fb351
commit
f4db361901
@ -29,15 +29,15 @@ type alias State =
|
||||
|
||||
{-| -}
|
||||
type Msg
|
||||
= ShowItWorked String
|
||||
= ShowItWorked
|
||||
| UpdateSettings (Control Settings)
|
||||
|
||||
|
||||
update : Msg -> State -> ( State, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
ShowItWorked message ->
|
||||
( Debug.log "Clicked: " message |> always model, Cmd.none )
|
||||
ShowItWorked ->
|
||||
( Debug.log "Clicked!" |> always model, Cmd.none )
|
||||
|
||||
UpdateSettings settings ->
|
||||
( settings, Cmd.none )
|
||||
@ -101,40 +101,28 @@ example =
|
||||
, version = version
|
||||
, update = UpdateSettings
|
||||
, settings = model
|
||||
, mainType = "RootHtml.Html msg"
|
||||
, mainType = "RootHtml.Html ()"
|
||||
, extraImports = [ "import Http" ]
|
||||
, toExampleCode = \_ -> []
|
||||
, toExampleCode =
|
||||
\{ page, recoveryText } ->
|
||||
[ { sectionName = "Example"
|
||||
, code =
|
||||
Tuple.first page
|
||||
++ "\n\t{ link = ()\n\t, recoveryText = "
|
||||
++ Debug.toString recoveryText
|
||||
++ "\n\t}"
|
||||
}
|
||||
]
|
||||
}
|
||||
, Heading.h2 [ Heading.style Heading.Subhead ] [ Html.text "Example" ]
|
||||
, Tuple.second settings.page
|
||||
{ link = ShowItWorked
|
||||
, recoveryText = settings.recoveryText
|
||||
}
|
||||
, viewExample settings.page settings.recoveryText
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
viewExample :
|
||||
( String, Page.DefaultPage Msg -> Html Msg )
|
||||
-> RecoveryText
|
||||
-> Html Msg
|
||||
viewExample ( viewName, view ) recoveryText =
|
||||
Html.div
|
||||
[ css
|
||||
[ Css.marginTop (Css.px 20)
|
||||
, Css.borderTop3 (Css.px 2) Css.solid Colors.gray96
|
||||
, Css.paddingTop (Css.px 20)
|
||||
, Css.marginBottom (Css.px 20)
|
||||
]
|
||||
]
|
||||
[ Heading.h2 [ Heading.style Heading.Subhead ] [ Html.text viewName ]
|
||||
, Html.code []
|
||||
[ Html.text <|
|
||||
viewName
|
||||
++ " { link = msg, recoveryText = "
|
||||
++ Debug.toString recoveryText
|
||||
++ " }"
|
||||
]
|
||||
, view { link = ShowItWorked viewName, recoveryText = recoveryText }
|
||||
]
|
||||
|
||||
|
||||
type alias Settings =
|
||||
{ page : ( String, DefaultPage Msg -> Html Msg )
|
||||
, recoveryText : RecoveryText
|
||||
@ -157,7 +145,7 @@ controlPageType =
|
||||
[ ( "httpError"
|
||||
, Control.map
|
||||
(\err ->
|
||||
( moduleName ++ ".httpError httpError -- Use Http.error"
|
||||
( moduleName ++ ".httpError httpError"
|
||||
, Page.httpError err
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user