Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
chore: README.mdに新しく実装するAPIについての説明を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
pxfnc committed Feb 11, 2024
1 parent c22c092 commit 7b68049
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,47 @@ emaki = [
$ npx elm-emaki
```

## Chapter API

よりユーザの入力負荷を減らすための Chapter API を開発中です。
一つのチャプターを表示するには、次のようなコードを書くことでチャプターを表示するアプリケーション
が作成できます。

```elm
import Emaki exposing (runChapter)
import Emaki.Chapter exposing (chapter)
import Emaki.Chapter.Control as Control


-- elm-emakiで表示したいviewをimport
import YourProject.UserProfileCard (view)


-- viewはこんな感じのものを想定
-- view : { userName : String, active : Bool } -> Html msg


main : Program () (Emaki.Model { userName : String, active : Bool }) Emaki.Msg
main =
runChapter <|
chapter
{ init = { userName = "", active = False }
, view = view
, controls =
[ Control.text
{ init = ""
, label = "user name"
, onChange = \newValue viewProps -> { viewProps | userName = newValue }
}
, Control.toggle
{ init = False
, label = "active?"
, onChange = \newValue viewProps -> { viewProps | active = newValue }
}
]
}
```

## 将来的な emaki の例

動作を見たい view 関数の実装`someView : Args -> Html msg`があった時、emaki ファイルをこんな
Expand Down

0 comments on commit 7b68049

Please sign in to comment.