Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 committed Apr 3, 2024
1 parent 146e5f9 commit e29e126
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 32 deletions.
38 changes: 21 additions & 17 deletions examples/attributes-passthrough/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
use sycamore::prelude::*;

#[derive(Props)]
pub struct AccessibleInputProps<G: Html> {
pub struct AccessibleInputProps {
label_id: &'static str,
attributes: Attributes<G>,
children: Children<G>,
// attributes: Attributes<G>,
children: Children,
}

#[component]
fn AccessibleSearchBox<G: Html>(props: AccessibleInputProps<G>) -> View<G> {
props
.attributes
.exclude_keys(&["aria-role", "aria-labelledby"]);
let children = props.children.call();

view! {
input(aria-role="searchbox", aria-labelledby=props.label_id, ..props.attributes) {
(children)
}
}
fn AccessibleSearchBox(props: AccessibleInputProps) -> View {
let _ = props.label_id;
let _ = props.children;
// props
// .attributes
// .exclude_keys(&["aria-role", "aria-labelledby"]);
// let children = props.children.call();
//
// view! {
// input(aria-role="searchbox", aria-labelledby=props.label_id, ..props.attributes) {
// (children)
// }
// }
todo!("attributes passthrough")
}

#[component]
fn App<G: Html>() -> View<G> {
fn App() -> View {
view! {
div {
p { "Passthrough attributes demo" }

div {
label(id="searchbox1_label") { "Search Box 1" }
AccessibleSearchBox(label_id="searchbox1_label", attr:style="background-color:red;") {}
// AccessibleSearchBox(label_id="searchbox1_label", attr:style="background-color:red;") {}
AccessibleSearchBox(label_id="searchbox1_label") {}
}

div {
label(id="searchbox2_label") { "Search Box 2" }
AccessibleSearchBox(label_id="searchbox2_label", attr:style="background-color:yellow;") { }
// AccessibleSearchBox(label_id="searchbox2_label", attr:style="background-color:yellow;") { }
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions examples/higher-order-components/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ pub struct MyComponentProps {
}

#[component]
fn MyComponent<G: Html>(props: MyComponentProps) -> View<G> {
fn MyComponent(props: MyComponentProps) -> View {
view! {
(props.value)
}
}

fn higher_order_component<G: Html>(
Comp: &dyn Fn(MyComponentProps) -> View<G>,
) -> impl Fn() -> View<G> + '_ {
fn higher_order_component(Comp: &dyn Fn(MyComponentProps) -> View) -> impl Fn() -> View + '_ {
move || {
view! {
div {
Expand Down
4 changes: 1 addition & 3 deletions packages/sycamore-web/src/bind.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Definition for bind-able attributes/properties.
use wasm_bindgen::JsValue;

use self::events::EventDescriptor;
use crate::events::EventDescriptor;
use crate::*;

/// Description for a bind-able attribute/property.
Expand Down
3 changes: 1 addition & 2 deletions packages/sycamore-web/src/dom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use wasm_bindgen::closure::Closure;
use wasm_bindgen::{intern, JsValue};
use wasm_bindgen::intern;

use crate::*;

Expand Down
6 changes: 1 addition & 5 deletions packages/sycamore-web/src/elements.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#![allow(non_snake_case)]

use std::cell::Cell;

use wasm_bindgen::JsValue;

use super::*;
use crate::*;

/// Create an HTML element with `tag`.
pub(crate) fn element(tag: &'static str) -> HtmlElement {
Expand Down
1 change: 0 additions & 1 deletion packages/sycamore-web/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![allow(non_snake_case)]

use std::cell::Cell;
use std::collections::HashMap;
use std::hash::Hash;
use std::ops::Deref;
Expand Down
1 change: 1 addition & 0 deletions packages/sycamore/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::prelude::*;
/// _This API requires the following crate features to be activated: `suspense`, `ssr`_
#[cfg(all(feature = "ssr", feature = "suspense"))]
pub async fn render_to_string_await_suspense(view: impl FnOnce() -> View + 'static) -> String {
let _ = view;
// use std::cell::RefCell;
// use std::rc::Rc;
//
Expand Down

0 comments on commit e29e126

Please sign in to comment.