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

[package] Follow new control api #37

Merged
merged 16 commits into from
Jul 15, 2024
Merged

[package] Follow new control api #37

merged 16 commits into from
Jul 15, 2024

Conversation

y047aka
Copy link
Owner

@y047aka y047aka commented Feb 26, 2024

#34 の実装を受けて、既存のControlモジュール側からも新APIに寄せてみます

@y047aka y047aka marked this pull request as draft February 26, 2024 16:37
@y047aka y047aka marked this pull request as ready for review March 1, 2024 16:07
Comment on lines -171 to +173
, onClickPlus = ProgressMsg Progress.CounterPlus
, onClickMinus = ProgressMsg Progress.CounterMinus
, onClickPlus = \ps -> { ps | value = Progress.clampValue (ps.value + 13) }
, onClickMinus = \ps -> { ps | value = Progress.clampValue (ps.value - 11) }
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ view : Html (props -> props) }にすると、外のmsgを使えないのがお悩みポイントではある。
制約と思えば今のところは許せるので、妥協案に変更しました。

@@ -160,6 +160,7 @@ progressPlayground : Bool -> Progress.Model -> Html Msg
progressPlayground isDarkMode pm =
playground
{ isDarkMode = isDarkMode
, toMsg = UpdateProgress
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

寄せてはみたものの、このPRではまだview関数のままなので、toMsg : (a -> a) -> msgをここで指定して辻褄合わせしています。フィールド毎に指定する必要がなくなったので、全体的な記述はすっきりしたかなと。

@@ -92,6 +92,11 @@ update msg model =
( model, Random.generate SetValue (Random.int -15 -10) )


clampValue : Float -> Float
clampValue =
max 0 >> min 100
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilotがこれで良いんじゃない?って言ってたのを採用。
min 100 (max 0 n)が微妙に分かりづらい印象を受けたので、ポイントフリースタイルにしてみた)

Comment on lines +26 to +27
type alias Control props =
{ view : Html (props -> props) }
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新APIに寄せつつも、段階的に進めるべく、このPRではview関数の形を維持しています。

Base automatically changed from propsSections to main July 15, 2024 11:14
@y047aka y047aka merged commit 01f1074 into main Jul 15, 2024
1 check failed
@y047aka y047aka deleted the follow_new_Control_API branch July 15, 2024 12:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant