feat: add stylesheet component to dioxus document (#3138)
* feat: add stylesheet component to dioxus document * fix asset path * add cache key to playwright
This commit is contained in:
1 parent
9ebcbc6bd9
commit
42f6b91390
3 files changed
+36
-1
No files matched your search
@@ -254,6 +254,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
cache-all-crates: "true"
|
cache-all-crates: "true"
|
||||||
cache-on-failure: "true"
|
cache-on-failure: "true"
|
||||||
|
key: "playwright-tests"
|
||||||
|
|
||||||
- name: Playwright
|
- name: Playwright
|
||||||
working-directory: ./packages/playwright-tests
|
working-directory: ./packages/playwright-tests
|
||||||
@@ -346,7 +347,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
key: "${{ matrix.platform.target }}"
|
key: "matrix-${{ matrix.platform.target }}"
|
||||||
cache-all-crates: "true"
|
cache-all-crates: "true"
|
||||||
cache-on-failure: "true"
|
cache-on-failure: "true"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use dioxus_core_macro::*;
|
|||||||
|
|
||||||
mod link;
|
mod link;
|
||||||
pub use link::*;
|
pub use link::*;
|
||||||
|
mod stylesheet;
|
||||||
|
pub use stylesheet::*;
|
||||||
mod meta;
|
mod meta;
|
||||||
pub use meta::*;
|
pub use meta::*;
|
||||||
mod script;
|
mod script;
|
||||||
|
|||||||
@@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user