全部試しました
明らかに使わないものを除いて、全部試してみました
HTMLの機能ズラーッっと並んでるのでよければoutput見てみてほしい
ellie-app.com
この記事を読む前に 言っておくッ! おれは今 Elmを ほんのちょっぴりだが 勉強した
い…いや… 勉強したというよりは 出来る人に 教わっていただけだが……
あ…ありのまま 今 起こった事を話すぜ!
「おれは Htmlモジュールの勉強をしていたと
思ったら いつのまにかHTMLの勉強をしていた」
な… 何を言っているのか わからねーと思うが
おれも 何をしているのか わからなかった…
頭がどうにかなりそうだった… Elmだとかモジュールだとか
そんなチャチなもんじゃあ 断じてねえ
もっと恐ろしいものの片鱗を 味わったぜ…
覚えたこと
Htmlモジュールの記法
だいたいこれ
タグ名 [タグの属性] [タグの要素]
<div name="hoge"> <p>text</p> </div>
これを作りたかったらこう書く
view : Model -> Html Msg view model = div [ name "hoge" ] [ p [] [ text "text" ] ]
最初混乱したけど、慣れたらスラスラ書けるようになった
全てを制覇した今、この構文は目を瞑っても書けるであろう
Html.Attributesに存在しない属性
object
のdata
属性とoptgroup
の`label`属性がなかった
のでこうやって対応した
, object [ attribute "data" "https://~~" , width 500 , height 300 ] [] , select [] [ optgroup [ attribute "label" "animals" ] [ option [] [ text "dog" ] , option [] [ text "cat" ] , option [] [ text "crocodile" ] ] ] ]
data
に限らずdata-
属性どうするんだろう?と思って調べたら出てきた
stackoverflow.com
モジュール内の名前がかぶった場合
-- 良くないと思うけど全部インポートしたいので(..)した import Html.Attributes exposing (..) progress [ value "80" , max "100" ] []
以下のエラーが出た
mbiguous name This usage of `max` is ambiguous: 243| , max "100" ^^^ This name is exposed by 2 of your imports, so I am not sure which one to use: Basics.max Html.Attributes.max I recommend using qualified names for imported values. I also recommend having at most one `exposing (..)` per file to make name clashes like this less common in the long run. Note: Check out <https://elm-lang.org/0.19.1/imports> for more info on the import syntax.
意訳
Basics.maxとHtml.Attributes.maxがぶつかってて Elmはどっちを使っていいかわからないよ、助けて><;
どうやらimport方法には色々あるらしい
uehaj.hatenablog.com
とりあえず今回は使う側で完全修飾名(?)で対応することにした
import Html.Attributes exposing (..) progress [ value "80" , Html.Attributes.max "100" ] []
間違っている気もするので、調べて適切なやり方を覚える予定
typeとtype_
, input [ type_ "search" , list "input-list" ] []
特に何も考えずinput type
のtype
を決めようとしたらエラーが出た
unfinished list I am partway through parsing a list, but I got stuck here: 169| [ type "search" ^ I was expecting to see a closing square bracket before this, so try adding a ] and see if that helps? Note: When I get stuck like this, it usually means that there is a missing parenthesis or bracket somewhere earlier. It could also be a stray keyword or operator.
意訳
閉じ]ないからつけてみて! で、その結果うまく行ったか確認してみて! こういう時大体はカッコがない、キーワードか演算子間違ってるだよん
実はtype
ではなくtype_
だった
Html.Attributes - html 1.0.0
言われてみれば納得
Elm
の型定義type
と被るから分けてるのかな
出力したHTMLの解説とか面白さとか
整形されたテキストをそのまま貼れる 順番があるテキストを定義する 初めてHTML触った時ぶりに触った 全く意識してなかったけど、丁寧な文章構造作るなら必須だなと思ったElm要素薄いので折りたたみ
pre
, pre [] [ text """
5pb. x Nitroplus
There is no end though there is a start in space. ---Infinity.
It has own power, it ruins, and it goes though there is a start also in the star. ---Finite.
Only the person who was wisdom can read the most foolish one from the history.
The fish that lives in the sea doesn't know the world in the land. It also ruins and goes if they have wisdom.
It is funnier that man exceeds the speed of light than fish start living in the land.
It can be said that this is an final ultimatum from the god to the people who can fight.
,, ,,
ヽ(*゚д゚)ノ < カイバー
""" ]
pre
タグ
長くて整形されてて…って思いついたのは
Steins;Gateのスカイクラッドの観測者の映像の文章でした
https://www.youtube.com/watch?v=i-uyoAHzRUY
さらに整形といえばAAなのでそのまま貼り付けて実験してみたol li
[ text "APPENDE A HACER SUSHI"
, ol []
[ li [] [ text "Ingredients: Seaweed, Smoked salmon, Rice, Soy sauce" ]
, li [] [ text "First, roll the salmon in rice. Then..." ]
, li [] [ text "Holy shit, you ruined everything. Like everything you do" ]
, li [] [ text "This sushi is like your life" ]
, li [] [ text "※Begining a lot of things, left undone" ]
, li [] [ text "And nobody loves you." ]
]
]
ol``li
タグ
順番があるテキスト…で思いついたのは
手巻き寿司作るmemeでした
誰もお前を愛さない (だれもおまえをあいさない)とは【ピクシブ百科事典】iframe
, iframe [ src "https://www.google.com/" ] []
まだ生きてたのかform周り
, Html.form []
[ fieldset []
[ legend [] [ text "legend" ]
, input
[ type_ "text"
, placeholder "placeholder text"
]
[]
, button [] [ text "form button" ]
, input [ id "form-input" ] []
, label [ for "form-input" ] [ text "form-input-label" ]
, input
[ type_ "search"
, list "input-list"
]
[]
, datalist [ id "input-list" ]
[ option [ value "seach-a" ] []
, option [ value "seach-b" ] []
, option [ value "seach-c" ] []
]
, select []
[ optgroup [ attribute "label" "animals" ]
[ option [] [ text "dog" ]
, option [] [ text "cat" ]
, option [] [ text "crocodile" ]
]
]
]
]
そういえばfieldset
全然使ったことなかったので触ってみたfieldset
form
の入力項目をグループ化するのに使うらしい
使わなくても動いたけど、SEO?
的には意識したほうがいいのかなlegend
fieldset
内のグループに名前つけるやつ
なんでlegend
なんだろうってずっと思ってるdatalist
, input
[ type_ "search"
, list "input-list"
]
[]
, datalist [ id "input-list" ]
[ option [ value "seach-a" ] []
, option [ value "seach-b" ] []
, option [ value "seach-c" ] []
]
input
要素の入力候補をdatalist
とlist
で定義できるの初めて知った
しかも選択できる
jsライブラリでこれを更に絞り込めるやつがあった気がするoptgroup
, select []
[ optgroup [ attribute "label" "animals" ]
[ option [] [ text "dog" ]
, option [] [ text "cat" ]
, option [] [ text "crocodile" ]
]
]
]
option
リストをグループ化出来る
これ関数使ってList
から出力する時、意識して出せたらカッコいいよねouput
[ Html.form []
[ p [] [ text "add number (ugokanai)" ]
, input
[ name "a"
, id "a"
, type_ "number"
]
[ text "+" ]
, input
[ name "b"
, id "b"
, type_ "number"
]
[ text "=" ]
, output
[ name "o"
, id "o"
, for "a b"
]
[]
]
]
output
要素にjs
の結果を出力できるらしい
とりあえず覚えるために土台だけ定義したmain
, main_ []
[ article []
[ header [] [ text "header" ]
, nav []
[ ul []
[ li [] [ text "nav 1" ]
, li [] [ text "nav 2" ]
, li [] [ text "nav 3" ]
]
]
, section [] [ h1 [] [ text "section" ] ]
, section []
[ h1 [] [ text "section-h1" ]
, p [] [ text "section paragraph-1" ]
, p [] [ text "section paragraph-2" ]
]
, footer [] [ text "footer" ]
, address [] [ text "https://twitter.com/nek0roll" ]
]
]
progress mater
, progress
[ value "80"
, Html.Attributes.max "100"
]
[]
, p [] [ text "meter" ]
, meter
[ value "80"
, Html.Attributes.max "100"
]
[]
範囲と現在地設定するだけでバーが出るの凄すぎる
css-animation
とかupdate
(?)組み合わせて、データん変動に合わせて増えたらすごいカッコいいと思うvideo embed object
, p [] [ text "steins;gate op fatima ※音が出ます" ]
, video [ controls True ] [ source [ src "https://animethemes.moe/video/SteinsGateZero-OP1.webm" ] [] ]
, p [] [ text "embed gif" ]
, embed
[ src "https://64.media.tumblr.com/1d471b04f2f2def1e78c389214d72228/tumblr_ornzk3fWxw1wn2b96o1_500.gifv"
, width 500
, height 300
]
[]
, p [] [ text "object gif" ]
, object
[ attribute "data" "https://64.media.tumblr.com/b8eabb3c49077329ec20b042d24524ee/tumblr_pe0dsl4f1W1vmzfszo1_500.gifv"
, width 500
, height 300
]
[]
webm
とgif
埋め込んだだけで表示された
control
属性がすごくてTrue
渡すだけで操作パネルが出た
動画を埋め込む場合ベストな選択肢だと思う
svg
(?)css-animation
あたりをこれに埋め込んだらどうなるのか気になるところ
まとめ
- 脳が適応して
view
の構造読みやすくなった
おまけでjs
にHTML
タグ書くの何か嫌だアレルギーが治った - 意図せずHTMLを学び直す機会になった
適切な文章構造って難しいネ HTML
を直書きするよりElm
から出力したほうが良い- 文章構造が適切になる
- (学習進めたら)もっと効率よく吐き出せそう
- DOM意識しなくていいっていいよね
- 記法と困ったときの対応法を覚えた
公式Github覗いたり似たような書き方調べたり
今後
attribute
も見てみる
Html.Attributes - html 1.0.0css
も見てみる
ライブラリとかあるのかな?
そこの選定か、ライブラリ無しでやってみるかは要検討css-animation
も触ってみたい(動かしたい)module
の適切なimport
方法- まだ単に
HTML
ゴリゴリしただけなので、関数からHTML
吐き出したい
List
からtable
吐き出したりしたい