-
-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add stylesheet component to dioxus document (#3138)
* feat: add stylesheet component to dioxus document * fix asset path * add cache key to playwright
- Loading branch information
1 parent
9ebcbc6
commit 42f6b91
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use super::*; | ||
|
||
/// Render a [`link`](crate::elements::link) tag into the head of the page with the stylesheet rel. | ||
/// This is equivalent to the [`Link`](crate::Link) component with a slightly more ergonomic API. | ||
/// | ||
/// | ||
/// # Example | ||
/// ```rust, no_run | ||
/// # use dioxus::prelude::*; | ||
/// fn RedBackground() -> Element { | ||
/// rsx! { | ||
/// document::Stylesheet { | ||
/// src: asset!("/assets/style.css") | ||
/// } | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// <div class="warning"> | ||
/// | ||
/// Any updates to the props after the first render will not be reflected in the head. | ||
/// | ||
/// </div> | ||
#[component] | ||
pub fn Stylesheet(props: LinkProps, src: Option<String>) -> Element { | ||
super::Link(LinkProps { | ||
href: src.or_else(|| props.href.clone()), | ||
rel: Some("stylesheet".into()), | ||
r#type: Some("text/css".into()), | ||
..props | ||
}) | ||
} |