Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle warnings; fix insert_before; fix remove style #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "tiye/respo",
"version": "0.0.21",
"version": "0.0.22",
"deps": {
"tiye/dom-ffi": "0.0.6",
"tiye/cirru-parser": "0.0.10"
"tiye/dom-ffi": "0.0.8",
"tiye/cirru-parser": "0.0.11"
},
"readme": "README.md",
"repository": "https://github.com/Respo/respo.mbt/",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dialog/confirm.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub(all) struct ConfirmPlugin[T] {
}

///|
pub fn render[T : @node.RespoAction](
pub fn ConfirmPlugin::render[T : @node.RespoAction](
self : ConfirmPlugin[T]
) -> @node.RespoNode[T] {
let on_confirm = self.on_confirm
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn render[T : @node.RespoAction](
}

///|
pub fn show[T : @node.RespoAction](
pub fn ConfirmPlugin::show[T : @node.RespoAction](
self : ConfirmPlugin[T],
dispatch : @node.DispatchFn[T],
next_task : () -> Unit
Expand Down
6 changes: 3 additions & 3 deletions src/lib/dialog/drawer.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(all) struct DrawerPlugin[T] {
}

///|
pub fn render[T : @node.RespoAction](
pub fn DrawerPlugin::render[T : @node.RespoAction](
self : DrawerPlugin[T]
) -> @node.RespoNode[T][email protected] {
let cursor = self.cursor.copy()
Expand All @@ -136,15 +136,15 @@ pub fn render[T : @node.RespoAction](
}

///|
pub fn show[T : @node.RespoAction](
pub fn DrawerPlugin::show[T : @node.RespoAction](
self : DrawerPlugin[T],
dispatch : @node.DispatchFn[T]
) -> [email protected] {
dispatch.run_state!(self.cursor, DrawerPluginState::{ show: true })
}

///|
pub fn close[T : @node.RespoAction](
pub fn DrawerPlugin::close[T : @node.RespoAction](
self : DrawerPlugin[T],
dispatch : @node.DispatchFn[T]
) -> [email protected] {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dialog/modal.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn ModalRenderer::new[T](
}

///|
fn run[T](
fn ModalRenderer::run[T](
self : ModalRenderer[T],
close : (@node.DispatchFn[T]) -> [email protected]
) -> [email protected] {
Expand Down Expand Up @@ -122,7 +122,7 @@ pub(all) struct ModalPlugin[T] {
}

///|
pub fn render[T : @node.RespoAction](
pub fn ModalPlugin::render[T : @node.RespoAction](
self : ModalPlugin[T]
) -> @node.RespoNode[T][email protected] {
let cursor = self.cursor
Expand All @@ -136,15 +136,15 @@ pub fn render[T : @node.RespoAction](
}

///|
pub fn show[T : @node.RespoAction](
pub fn ModalPlugin::show[T : @node.RespoAction](
self : ModalPlugin[T],
dispatch : @node.DispatchFn[T]
) -> [email protected] {
dispatch.run_state!(self.cursor, ModalPluginState::{ show: true })
}

///|
pub fn close[T : @node.RespoAction](
pub fn ModalPlugin::close[T : @node.RespoAction](
self : ModalPlugin[T],
dispatch : @node.DispatchFn[T]
) -> [email protected] {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/dialog/moon.pkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"ui_row_parted"
]
},
{ "path": "tiye/dom-ffi/lib", "alias": "dom_ffi" }
{
"path": "tiye/dom-ffi/lib",
"alias": "dom_ffi"
}
]
}
8 changes: 4 additions & 4 deletions src/lib/dialog/prompt.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(all) struct PromptOptions {
pub(all) type PromptValidator (String) -> Result[Unit, String]

///|
pub fn to_string(self : PromptValidator) -> String {
pub fn PromptValidator::to_string(self : PromptValidator) -> String {
"(PromptValidator \{self})"
}

Expand Down Expand Up @@ -248,7 +248,7 @@ pub(all) struct PromptPlugin[T] {
}

///|
pub fn render[T : @node.RespoAction](
pub fn PromptPlugin::render[T : @node.RespoAction](
self : PromptPlugin[T]
) -> @node.RespoNode[T] {
let on_submit = self.on_submit
Expand Down Expand Up @@ -287,7 +287,7 @@ pub fn render[T : @node.RespoAction](
}

///|
pub fn show[T : @node.RespoAction](
pub fn PromptPlugin::show[T : @node.RespoAction](
self : PromptPlugin[T],
dispatch : @node.DispatchFn[T],
next_task : (String) -> Unit
Expand All @@ -301,7 +301,7 @@ pub fn show[T : @node.RespoAction](
}

///|
pub fn close[T : @node.RespoAction](
pub fn PromptPlugin::close[T : @node.RespoAction](
self : PromptPlugin[T],
dispatch : @node.DispatchFn[T]
) -> [email protected] {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/node/alias.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ pub fn input[T](
attrs.set(
"autocomplete",
match autocomplete {
TextareaElementAutoComplete::On => "on"
TextareaElementAutoComplete::Off => "off"
On => "on"
Off => "off"
},
)
None => ()
Expand Down Expand Up @@ -475,8 +475,8 @@ pub fn img[T](
attrs.set(
"loading",
match loading {
ImgElementLoading::Eager => "eager"
ImgElementLoading::Lazy => "lazy"
Eager => "eager"
Lazy => "lazy"
},
)
None => ()
Expand Down
2 changes: 1 addition & 1 deletion src/lib/node/component.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn op_equal[T](self : RespoComponent[T], other : RespoComponent[T]) -> Bool
}

///|
fn to_string[T](self : RespoComponent[T]) -> String {
fn RespoComponent::to_string[T](self : RespoComponent[T]) -> String {
"(RespoComponent \{self.name})"
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/node/css.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn is_empty(self : RespoStyle) -> Bool {
}

///|
pub fn to_string(self : RespoStyle) -> String {
pub fn RespoStyle::to_string(self : RespoStyle) -> String {
let mut result = ""
for pair in self._ {
let (property, value) = pair
Expand Down Expand Up @@ -705,7 +705,7 @@ pub fn CssBorderStyle::to_string(self : CssBorderStyle) -> String {
pub(all) type CssBorder (Float, CssBorderStyle, CssColor)

///|
pub fn to_string(self : CssBorder) -> String {
pub fn CssBorder::to_string(self : CssBorder) -> String {
let (width, style, color) = self._
str_spaced([width.to_string() + "px " + style.to_string(), color.to_string()])
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/node/dom-change.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(all) enum RespoCoord {
}

///|
pub fn to_string(self : RespoCoord) -> String {
pub fn RespoCoord::to_string(self : RespoCoord) -> String {
match self {
Key(key) => "(Key " + key.to_string() + ")"
Comp(comp) => "(Comp " + comp + ")"
Expand Down Expand Up @@ -59,7 +59,7 @@ enum DomChange[T] {
}

///|
impl[T] Show for DomChange[T] with output(self, logger) {
pub impl[T] Show for DomChange[T] with output(self, logger) {
logger.write_string(self.to_string())
}

Expand Down Expand Up @@ -110,7 +110,7 @@ fn DomChange::to_string[T](self : DomChange[T]) -> String {
}

///|
pub fn to_cirru[T](self : DomChange[T]) -> @cirru.Cirru {
pub fn DomChange::to_cirru[T](self : DomChange[T]) -> @cirru.Cirru {
match self {
Effect(coord~, dom_path~, effect_type~, skip_indexes~) =>
@cirru.List([
Expand Down Expand Up @@ -231,7 +231,7 @@ fn ChildDomOp::to_string[T](self : ChildDomOp[T]) -> String {
}

///|
pub fn to_cirru[T](self : ChildDomOp[T]) -> @cirru.Cirru {
pub fn ChildDomOp::to_cirru[T](self : ChildDomOp[T]) -> @cirru.Cirru {
match self {
InsertAfter(index, key, node) =>
@cirru.List([
Expand Down
7 changes: 5 additions & 2 deletions src/lib/node/effect.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ impl RespoEffect with updated(_self, _node) -> Unit { }
impl RespoEffect with before_unmount(_self, _node) -> Unit { }

///|
pub fn op_equal(self : RespoEffectBox, b : RespoEffectBox) -> Bool {
pub fn RespoEffectBox::op_equal(
self : RespoEffectBox,
b : RespoEffectBox
) -> Bool {
self.args == b.args
}

Expand All @@ -80,7 +83,7 @@ pub fn RespoEffectType::to_string(self : RespoEffectType) -> String {
}

///|
pub fn to_cirru(self : RespoEffectType) -> @cirru.Cirru {
pub fn RespoEffectType::to_cirru(self : RespoEffectType) -> @cirru.Cirru {
match self {
Mounted => Leaf("::mounted")
BeforeUpdate => Leaf("::before-update")
Expand Down
13 changes: 8 additions & 5 deletions src/lib/node/element.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pub(all) type RespoIndexKey String derive(Eq)

///|
pub fn to_cirru(self : RespoIndexKey) -> @cirru.Cirru {
pub fn RespoIndexKey::to_cirru(self : RespoIndexKey) -> @cirru.Cirru {
Leaf(self._)
}

///|
pub fn to_string(self : RespoIndexKey) -> String {
pub fn RespoIndexKey::to_string(self : RespoIndexKey) -> String {
self._
}

Expand All @@ -34,7 +34,10 @@ pub fn RespoElement::to_node[T](self : RespoElement[T]) -> RespoNode[T] {
}

///|
pub fn op_equal[T](self : RespoElement[T], other : RespoElement[T]) -> Bool {
pub fn RespoElement::op_equal[T](
self : RespoElement[T],
other : RespoElement[T]
) -> Bool {
if self.name != other.name {
return false
}
Expand Down Expand Up @@ -62,7 +65,7 @@ pub fn op_equal[T](self : RespoElement[T], other : RespoElement[T]) -> Bool {
}

///|
pub fn to_string[T](self : RespoElement[T]) -> String {
pub fn RespoElement::to_string[T](self : RespoElement[T]) -> String {
"(RespoElement \{self.name})"
}

Expand Down Expand Up @@ -207,7 +210,7 @@ pub fn respo_attrs(
}

///|
pub fn to_cirru[T](self : RespoElement[T]) -> @cirru.Cirru {
pub fn RespoElement::to_cirru[T](self : RespoElement[T]) -> @cirru.Cirru {
let attrs = self.attrs
// let event = self.event
// let style = self.style
Expand Down
4 changes: 2 additions & 2 deletions src/lib/node/listener.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(all) enum RespoEvent {
}

///|
pub fn to_string(self : RespoEvent) -> String {
pub fn RespoEvent::to_string(self : RespoEvent) -> String {
match self {
Click(..) => "(Click)".to_string()
Keyboard(..) => "(Keyboard)".to_string()
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Show for RespoEventType with output(self, logger) {
}

///|
pub fn to_cirru(self : RespoEventType) -> @cirru.Cirru {
pub fn RespoEventType::to_cirru(self : RespoEventType) -> @cirru.Cirru {
match self {
Click => Leaf("::click")
DblClick => Leaf("::dbl-click")
Expand Down
11 changes: 7 additions & 4 deletions src/lib/node/node.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ pub(all) enum RespoNode[T] {
}

///|
pub fn op_equal[T](self : RespoNode[T], other : RespoNode[T]) -> Bool {
pub fn RespoNode::op_equal[T](
self : RespoNode[T],
other : RespoNode[T]
) -> Bool {
match (self, other) {
(Component(left), Component(right)) => left == right
(Element(left), Element(right)) => left == right
Expand All @@ -14,15 +17,15 @@ pub fn op_equal[T](self : RespoNode[T], other : RespoNode[T]) -> Bool {
}

///|
fn to_string[T](self : RespoNode[T]) -> String {
fn RespoNode::to_string[T](self : RespoNode[T]) -> String {
match self {
Component(component) => component.to_string()
Element(element) => element.to_string()
}
}

///|
pub fn to_cirru[T](self : RespoNode[T]) -> @cirru.Cirru {
pub fn RespoNode::to_cirru[T](self : RespoNode[T]) -> @cirru.Cirru {
match self {
Component(component) => component.to_cirru()
Element(element) => element.to_cirru()
Expand All @@ -33,7 +36,7 @@ pub fn to_cirru[T](self : RespoNode[T]) -> @cirru.Cirru {
pub(all) type! RespoCommonError String

///|
pub fn to_string(self : RespoCommonError) -> String {
pub fn RespoCommonError::to_string(self : RespoCommonError) -> String {
match self {
RespoCommonError(msg) => "(RespoError \{msg})"
}
Expand Down
Loading
Loading