Skip to content

Commit

Permalink
use method from package by name for cleaner syntax; tag 0.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Oct 31, 2024
1 parent e654313 commit dd670cd
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 267 deletions.
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiye/respo",
"version": "0.0.12",
"version": "0.0.13",
"deps": {
"tiye/dom-ffi": "0.0.4",
"tiye/cirru-parser": "0.0.7"
Expand Down
33 changes: 15 additions & 18 deletions src/lib/dialog/alert.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ fn comp_alert_modal[T](
effect_focus_data as @node.RespoEffect,
effect_modal_fade_data as @node.RespoEffect,
],
@node.div(
style=@node.RespoStyle::new(position=Absolute),
div(
style=respo_style(position=Absolute),
[
if show {
@node.div(
div(
class_name=@node.str_spaced(
[@respo.ui_fullscreen, @respo.ui_center, css_backdrop],
),
Expand All @@ -47,11 +47,11 @@ fn comp_alert_modal[T](
},
),
[
@node.div(
div(
class_name=@node.str_spaced(
[@respo.column, @respo.ui_global, css_modal_card],
[@respo.ui_column, ui_global, css_modal_card],
),
style=@node.RespoStyle::new(line_height=Px(32.0)).merge(
style=respo_style(line_height=Px(32.0)).merge(
options.card_style,
),
event={}..set(
Expand All @@ -65,18 +65,18 @@ fn comp_alert_modal[T](
},
),
[
@node.div(
div(
[
@node.span(inner_text=options.text.or("Alert!"), []),
@node.space(height=8),
@node.div(
span(inner_text=options.text.or("Alert!"), []),
space(height=8),
div(
class_name=@respo.ui_row_parted,
[
@node.span([]),
@node.button(
span([]),
button(
inner_text=options.button_text.or("Read"),
class_name=@node.str_spaced(
[@respo.ui_button, css_button, button_name],
class_name=str_spaced(
[ui_button, css_button, button_name],
),
event={}..set(
Click,
Expand All @@ -96,10 +96,7 @@ fn comp_alert_modal[T](
],
)
} else {
@node.span(
attrs=@node.respo_attrs()..set("data-name", "placeholder"),
[],
)
span(attrs=respo_attrs()..set("data-name", "placeholder"), [])
},
],
),
Expand Down
26 changes: 13 additions & 13 deletions src/lib/dialog/confirm.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ fn comp_confirm_modal[T](
let effect_modal_fade_data : EffectModalFade = { show, }
@node.RespoComponent::named(
"confirm-modal",
@node.div(
style=@node.RespoStyle::new(position=Absolute),
div(
style=respo_style(position=Absolute),
[
if show {
@node.div(
div(
class_name=@node.str_spaced(
[@respo.ui_fullscreen, @respo.ui_center, css_backdrop],
),
Expand All @@ -52,9 +52,9 @@ fn comp_confirm_modal[T](
},
),
[
@node.div(
div(
class_name=@node.str_spaced(
[@respo.column, @respo.ui_global, css_modal_card],
[@respo.ui_column, @respo.ui_global, css_modal_card],
),
style=options.card_style,
event={}..set(
Expand All @@ -69,20 +69,20 @@ fn comp_confirm_modal[T](
},
),
[
@node.div(
div(
[
@node.span(
span(
inner_text=options.text.or("Need confirmation..."),
[],
),
@node.space(height=8),
@node.div(
space(height=8),
div(
class_name=@respo.ui_row_parted,
[
@node.span([]),
@node.button(
span([]),
button(
inner_text=options.button_text.or("Confirm"),
class_name=@node.str_spaced(
class_name=str_spaced(
[@respo.ui_button, css_button, button_name],
),
event={}..set(
Expand All @@ -103,7 +103,7 @@ fn comp_confirm_modal[T](
],
)
} else {
@node.span(
span(
// attrs=@node.respo_attrs(data_name="placeholder"),
[],
)
Expand Down
20 changes: 10 additions & 10 deletions src/lib/dialog/dialogs.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ pub fn comp_esc_listener[T](
@node.RespoComponent::named(
"esc-listener",
effects=[effect_modal_close_data as @node.RespoEffect],
@node.input(
input(
value="",
style=@node.RespoStyle::new(display=None),
style=respo_style(display=None),
event={}..set(
Keydown,
fn(e, dispatch) {
Expand All @@ -175,11 +175,11 @@ pub fn comp_esc_listener[T](
).to_node()
}

let css_backdrop : String = @node.declare_static_style(
let css_backdrop : String = declare_static_style(
[
(
"&",
@node.RespoStyle::new(
respo_style(
background_color=Hsla(0, 30, 10, 0.6),
position=Fixed,
z_index=999,
Expand All @@ -188,11 +188,11 @@ let css_backdrop : String = @node.declare_static_style(
],
)

let css_modal_card : String = @node.declare_static_style(
let css_modal_card : String = declare_static_style(
[
(
"&",
@node.RespoStyle::new(
respo_style(
background_color=Hsl(0, 0, 100),
max_width=Px(600),
width=Percent(100),
Expand All @@ -207,11 +207,11 @@ let css_modal_card : String = @node.declare_static_style(
],
)

let css_drawer_card : String = @node.declare_static_style(
let css_drawer_card : String = declare_static_style(
[
(
"&",
@node.RespoStyle::new(
respo_style(
background_color=Hsl(0, 0, 100),
max_width=Vw(50),
width=Px(400),
Expand All @@ -229,11 +229,11 @@ let css_drawer_card : String = @node.declare_static_style(
],
)

let css_button : String = @node.declare_static_style(
let css_button : String = declare_static_style(
[
(
"&",
@node.RespoStyle::new(
respo_style(
border_radius=4.0,
background_color=White,
border_color=Hsl(0, 0, 0),
Expand Down
35 changes: 15 additions & 20 deletions src/lib/dialog/drawer.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn to_string[T](self : DrawerRenderer[T]) -> String {
}

pub fn DrawerRenderer::default[T]() -> DrawerRenderer[T] {
fn(_close) { @node.div([]) }
fn(_close) { div([]) }
}

pub fn DrawerRenderer::new[T](
Expand Down Expand Up @@ -53,13 +53,13 @@ fn comp_drawer[T](
effect_focus_data as @node.RespoEffect,
effect_drawer_fade_data as @node.RespoEffect,
],
@node.div(
style=@node.RespoStyle::new(position=Absolute),
div(
style=respo_style(position=Absolute),
[
if show {
@node.div(
div(
class_name=@node.str_spaced(
[@respo.ui_fullscreen, @respo.ui_center, css_backdrop],
[ui_fullscreen, ui_center, css_backdrop],
),
style=options.backdrop_style,
event={}..set(
Expand All @@ -74,13 +74,11 @@ fn comp_drawer[T](
},
),
[
@node.div(
div(
class_name=@node.str_spaced(
[@respo.column, @respo.ui_global, css_drawer_card],
),
style=@node.RespoStyle::new(padding=Px(0)).merge(
options.card_style,
[ui_column, ui_global, css_drawer_card],
),
style=respo_style(padding=Px(0)).merge(options.card_style),
event={}..set(
Click,
fn(e, _dispatch) {
Expand All @@ -92,14 +90,14 @@ fn comp_drawer[T](
},
),
[
@node.div(
class_name=@respo.column,
div(
class_name=@respo.ui_column,
[
@node.div(
class_name=@respo.ui_center,
[@node.span(inner_text=options.title.or("Drawer"), [])],
div(
class_name=ui_center,
[span(inner_text=options.title.or("Drawer"), [])],
),
@node.space(height=8),
space(height=8),
{
let f = options.render
f.run!(fn(dispatch) { close(dispatch) })
Expand All @@ -112,10 +110,7 @@ fn comp_drawer[T](
],
)
} else {
@node.span(
attrs=@node.respo_attrs()..set("data-name", "placeholder"),
[],
)
span(attrs=respo_attrs()..set("data-name", "placeholder"), [])
},
],
),
Expand Down
33 changes: 14 additions & 19 deletions src/lib/dialog/modal.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub type ModalRenderer[T] ((@node.DispatchFn[T]) -> Unit!@node.RespoCommonError)
]!@node.RespoCommonError

pub fn ModalRenderer::default[T]() -> ModalRenderer[T] {
fn(_close) { @node.div([]) }
fn(_close) { div([]) }
}

pub fn ModalRenderer::new[T](
Expand Down Expand Up @@ -48,12 +48,12 @@ fn comp_modal[T](
@node.RespoComponent::named(
"modal",
effects=[effect_modal_fade_data as @node.RespoEffect],
@node.div(
style=@node.RespoStyle::new(position=Absolute),
div(
style=respo_style(position=Absolute),
[
if show {
@node.div(
class_name=@node.str_spaced(
div(
class_name=str_spaced(
[@respo.ui_fullscreen, @respo.ui_center, css_backdrop],
),
style=options.backdrop_style,
Expand All @@ -69,11 +69,9 @@ fn comp_modal[T](
},
),
[
@node.div(
class_name=@node.str_spaced(
[@respo.column, @respo.ui_global, css_modal_card],
),
style=@node.RespoStyle::new(padding=Px(0), line_height=Px(32.0)).merge(
div(
class_name=str_spaced([ui_column, ui_global, css_modal_card]),
style=respo_style(padding=Px(0), line_height=Px(32.0)).merge(
options.card_style,
),
event={}..set(
Expand All @@ -87,12 +85,12 @@ fn comp_modal[T](
},
),
[
@node.div(
class_name=@respo.column,
div(
class_name=ui_column,
[
@node.div(
class_name=@respo.ui_center,
[@node.span(inner_text=options.title.or("Modal"), [])],
div(
class_name=ui_center,
[span(inner_text=options.title.or("Modal"), [])],
),
@node.space(height=8),
{
Expand All @@ -107,10 +105,7 @@ fn comp_modal[T](
],
)
} else {
@node.span(
attrs=@node.respo_attrs()..set("data-name", "placeholder"),
[],
)
span(attrs=respo_attrs()..set("data-name", "placeholder"), [])
},
],
),
Expand Down
32 changes: 30 additions & 2 deletions src/lib/dialog/moon.pkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
{
"import": [
{ "path": "tiye/respo/lib/node", "alias": "node" },
{ "path": "tiye/respo/lib", "alias": "respo" },
{
"path": "tiye/respo/lib/node",
"alias": "node",
"value": [
"div",
"space",
"str_spaced",
"span",
"button",
"respo_attrs",
"respo_style",
"input",
"declare_static_style"
]
},
{
"path": "tiye/respo/lib",
"alias": "respo",
"value": [
"ui_button",
"ui_input",
"ui_global",
"ui_row",
"ui_column",
"ui_center",
"ui_fullscreen",
"ui_textarea",
"ui_row_parted"
]
},
{ "path": "tiye/dom-ffi/lib", "alias": "dom_ffi" }
]
}
Loading

0 comments on commit dd670cd

Please sign in to comment.