Skip to content

Convert Style into AttributeValue #19

@israelsilvabarbara

Description

@israelsilvabarbara

Case:

use leptos_node_ref::AnyNodeRef;
use radix_leptos_label::Label as LabelPrimitive;
use tailwind_fuse::*;
use leptos_style::Style;

#[component]
pub fn Label( 
   #[prop(into, optional)] style: Signal<Style>,
) -> impl IntoView {
    view! {
        <LabelPrimitive
            attr:style=style.get()
        />
    }
}

gives me the error:

error[E0277]: the trait bound `leptos_style::Style: IntoAttributeValue` is not satisfied
  --> packages/leptos/label/src/default.rs:21:24
   |
19 | /     view! {
20 | |         <LabelPrimitive
21 | |             attr:style=style.get()
   | |                        ^^^^^^^^^^^ the trait `FnMut()` is not implemented for `leptos_style::Style`
...  |
25 | |         </LabelPrimitive>
26 | |     }
   | |_____- required by a bound introduced by this call
   |
   = note: required for `leptos_style::Style` to implement `ReactiveFunction`
   = note: required for `leptos_style::Style` to implement `AttributeValue`
   = note: required for `leptos_style::Style` to implement `IntoAttributeValue`

There is an option to use .to_string() which solves the problem but add unnecessary verbose into the code.

I have set up a small PR implementing IntoAttributeValue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions