-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6008868
commit 85a18c5
Showing
5 changed files
with
164 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
module ElmBook.UI.Docs.DarkModeComponents exposing (..) | ||
|
||
import ElmBook.Chapter exposing (Chapter, chapter, render, renderStatefulComponent, renderWithComponentList, withStatefulComponent) | ||
import Html exposing (..) | ||
import Html.Attributes exposing (..) | ||
|
||
|
||
type alias SharedState x = | ||
{ x | darkMode : Bool } | ||
|
||
|
||
docs : Chapter (SharedState x) | ||
docs = | ||
chapter "Dark Components" | ||
|> withStatefulComponent | ||
(\{ darkMode } -> | ||
div [ class "elm-book elm-book-serif" ] | ||
[ if darkMode then | ||
div [] | ||
[ p | ||
[ style "color" "#fff" ] | ||
[ text "You found me!" ] | ||
] | ||
|
||
else | ||
p | ||
[ style "color" "#999" ] | ||
[ text "There is something hidden in the dark…" ] | ||
] | ||
) | ||
|> render """ | ||
If want to showcase your UI components and their dark mode variants in all their glory, take a look at the `onDarkModeChange` helper. Try changing the dark/light mode and look at the component below: | ||
<component /> | ||
Here is how it works: | ||
```elm | ||
type alias SharedState = | ||
{ darkMode : Bool | ||
} | ||
initialState : SharedState | ||
initialState = | ||
{ darkMode = False | ||
} | ||
book : Book SharedState | ||
book "MyApp" | ||
|> withStatefulOptions | ||
[ ElmBook.StatefulOptions.initialState | ||
initialState | ||
, ElmBook.StatefulOptions.onDarkModeChange | ||
(\\darkMode state -> | ||
{ state | darkMode = darkMode } | ||
) | ||
] | ||
|> withChapters [] | ||
darkModeChapter : Chapter SharedState | ||
darkModeChapter = | ||
chapter "Dark Mode" | ||
|> renderStatefulComponent ( | ||
\\{ darkMode } -> | ||
if darkMode then | ||
text "You found me!" | ||
else | ||
text "There is something hidden in the dark…" | ||
) | ||
``` | ||
""" |
This file contains 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 characters