Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "respo/app",
"version": "0.1.0",
"deps": {
"tiye/respo": "0.0.32",
"tiye/respo": "0.0.33",
"tiye/dom-ffi": "0.0.9"
},
"readme": "README.md",
Expand Down
40 changes: 16 additions & 24 deletions src/container.mbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
///|
typealias @respo_node.(RespoEvent, RespoNode, DispatchFn, RespoCommonError)
typealias @respo_node.RespoNode

///|
fnalias @respo_node.(text_node, textarea, declare_static_style)
fnalias @respo_node.(textarea, static_style)

///|
fnalias @respo.ui_textarea
Expand All @@ -22,38 +22,30 @@ fn comp_container(states : @respo.RespoStatesTree) -> RespoNode[ActionOp] {
class_list=[ui_textarea, style_textbox],
placeholder="Question",
value=state.draft,
event=Map::of([
(
Input,
fn(e, dispatch) {
if e is Input(value~, ..) {
dispatch.set_state!(cursor, ContainerState::{ draft: value })
}
},
),
(
Keydown,
fn(e, dispatch) {
if e is Keyboard(key_code~, meta_key~, ..) {
if key_code == 13 && meta_key {
ask_gemini(state.draft)
}
}
},
),
]),
on_input=fn(e, dispatch) {
if e is Input(value~, ..) {
dispatch.set_state!(cursor, ContainerState::{ draft: value })
}
},
on_keydown=fn(e, _dispatch) {
if e is Keyboard(key_code~, meta_key~, ..) {
if key_code == 13 && meta_key {
ask_gemini(state.draft)
}
}
},
),
button(
inner_text="Ask",
class_name=ui_button,
style=respo_style(margin=4 |> Px),
event={}..set(Click, fn(e, dispatch) { ask_gemini(state.draft) }),
on_click=fn(_e, _dispatch) { ask_gemini(state.draft) },
),
]),
])
}

///|
let style_textbox : String = declare_static_style([
let style_textbox : String = static_style([
("&", respo_style(width=600 |> Px, height=160 |> Px)),
])
2 changes: 1 addition & 1 deletion src/main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
fnalias @respo.(ui_global, ui_button)

///|
fnalias @respo_node.(div, span, button, respo_style)
fnalias @respo_node.(div, button, respo_style)

///|
let app_store_key : String = "mbt-workflow"
Expand Down
12 changes: 1 addition & 11 deletions src/store.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///|
struct Store {
mut counted : Int
counted : Int
tasks : Array[Task]
states : @respo.RespoStatesTree
} derive(ToJson, @json.FromJson)
Expand All @@ -21,9 +21,6 @@ struct Task {
///|
enum ActionOp {
StatesChange(@respo.RespoUpdateState)
Increment
Decrement
IncTwice
}

///|
Expand All @@ -36,10 +33,6 @@ impl Show for ActionOp with output(self, logger) -> Unit {
let s = match self {
StatesChange(states) =>
"StatesChange(\{states.cursor} \{states.data.to_json()})"
// Intent(_intent) => "Intent(...)"
Increment => "Increment"
Decrement => "Decrement"
IncTwice => "IncTwice"
}
logger.write_string(s)
}
Expand All @@ -52,10 +45,7 @@ fn get_states(self : Store) -> @respo.RespoStatesTree {
///| TODO mutation might break memoization in future
fn update(self : Store, op : ActionOp) -> Unit {
match op {
Increment => self.counted += 1
StatesChange(states) => self.states.set_in_mut(states)
Decrement => self.counted -= 1
_ => ()
}
}

Expand Down