Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Apr 19, 2024
1 parent f80f6ab commit 06ebc00
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 25 deletions.
3 changes: 1 addition & 2 deletions crates/core/src/dom/component/stateful_component.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{
dom::{
events::on_component_mount, program::MountProcedure, Application, Cmd, Component,
events::on_component_mount, program::MountProcedure, Application, Cmd, Component, DomAttr,
DomAttrValue, DomNode, Program,
DomAttr,
},
vdom::{Attribute, AttributeName, Leaf, Node},
};
Expand Down
9 changes: 2 additions & 7 deletions crates/core/src/dom/dom_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,7 @@ impl DomNode {
}

/// set the attributes of the dom element
pub fn set_dom_attrs(
&self,
attrs: impl IntoIterator<Item = DomAttr>,
) -> Result<(), JsValue> {
pub fn set_dom_attrs(&self, attrs: impl IntoIterator<Item = DomAttr>) -> Result<(), JsValue> {
for attr in attrs.into_iter() {
self.set_dom_attr(attr)?;
}
Expand Down Expand Up @@ -847,9 +844,7 @@ where
let dom_attrs: Vec<DomAttr> = comp.attrs.iter().map(|a| self.convert_attr(a)).collect();
for dom_attr in dom_attrs.into_iter() {
log::info!("calling attribute changed..");
comp.comp
.borrow_mut()
.attribute_changed(dom_attr);
comp.comp.borrow_mut().attribute_changed(dom_attr);
}

// the component children is manually appended to the StatefulComponent
Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/dom/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ impl InputEvent {
}

/// call prevent default on the underlying event
pub fn prevent_default(&self){
pub fn prevent_default(&self) {
self.event.prevent_default()
}

/// call stop_propagation on the underlying event
pub fn stop_propagation(&self){
pub fn stop_propagation(&self) {
self.event.stop_propagation()
}

Expand All @@ -307,15 +307,15 @@ impl InputEvent {
} else if let Some(select) = target.dyn_ref::<HtmlSelectElement>() {
select.value()
} else if let Some(html_elm) = target.dyn_ref::<HtmlElement>() {
if let Some(value) = html_elm.get_attribute("value"){
if let Some(value) = html_elm.get_attribute("value") {
log::info!("got value: {}", value);
value
}else{
} else {
log::info!("no value..");
if let Some(content) = html_elm.get_attribute("content"){
if let Some(content) = html_elm.get_attribute("content") {
log::info!("got content: {}", content);
content
}else{
} else {
log::info!("no content either..");
"".to_string()
}
Expand Down
2 changes: 1 addition & 1 deletion examples/experimentals/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Application for App {
{stateful_component(Button::default(), [], [text!("External child of btn stateful_component: {}", self.click_count)])}
</div>
<div>
{datebox([date("2022-07-07"), time("07:07"),
{datebox([date("2022-07-07"), time("07:07"),
on_input(|ie|{
log::info!("on_input is triggered...");
Msg::DateChanged(ie.value())
Expand Down
14 changes: 6 additions & 8 deletions examples/experimentals/src/datebox.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sauron::dom::DomAttr;
use sauron::dom::DomNode;
use sauron::*;
use std::fmt::Debug;
use sauron::dom::DomAttr;

#[derive(Debug, Clone)]
pub enum Msg {
Expand Down Expand Up @@ -32,17 +32,13 @@ impl Default for DateBox {
}
}

impl DateBox
{

impl DateBox {
fn date_time(&self) -> String {
format!("{} {}", self.date, self.time)
}

}

impl sauron::Component for DateBox
{
impl sauron::Component for DateBox {
type MSG = Msg;
type XMSG = ();

Expand Down Expand Up @@ -76,7 +72,9 @@ impl sauron::Component for DateBox
Msg::Mounted(mount_event) => {
log::info!("==> Ok the DateTime widget is now mounted for real..");
let mount_element = mount_event.target_node;
mount_element.set_dom_attrs(self.dom_attrs.drain(..)).unwrap();
mount_element
.set_dom_attrs(self.dom_attrs.drain(..))
.unwrap();
self.host_element = Some(mount_element);
Effects::none()
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fancy-ui/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::Theme;
use css_colors::Color;
use sauron::dom::DomNode;
use sauron::{
dom::DomAttr,
html::{attributes::*, events::*, *},
vdom::Callback,
dom::DomAttr,
*,
};
use std::collections::BTreeMap;
Expand Down

0 comments on commit 06ebc00

Please sign in to comment.