Browse Source

Remove the stylesheet component (#3176)

* Remove the stylesheet component

* add props to style component

* don't remove stylesheet

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Evan Almloff 4 months ago
parent
commit
5bb7f51cba
1 changed files with 7 additions and 2 deletions
  1. 7 2
      packages/document/src/elements/style.rs

+ 7 - 2
packages/document/src/elements/style.rs

@@ -41,7 +41,7 @@ impl StyleProps {
     }
 }
 
-/// Render a [`style`](crate::elements::style) tag into the head of the page.
+/// Render a [`style`](crate::elements::style) or [`link`](crate::elements::link) tag into the head of the page.
 ///
 /// If present, the children of the style component must be a single static or formatted string. If there are more children or the children contain components, conditionals, loops, or fragments, the style will not be added.
 ///
@@ -59,6 +59,10 @@ impl StyleProps {
 ///                 }}
 ///             "#
 ///         }
+///         // You could also use a style with a href to load a stylesheet asset
+///         document::Style {
+///             href: asset!("/assets/style.css")
+///         }
 ///     }
 /// }
 /// ```
@@ -90,13 +94,14 @@ pub fn Style(props: StyleProps) -> Element {
             // The style has a src, render it as a link tag
             (Some(_), _) => {
                 attributes.push(("type", "text/css".into()));
+                attributes.push(("rel", "stylesheet".into()));
                 document.create_link(LinkProps {
                     media: props.media,
                     title: props.title,
                     r#type: Some("text/css".to_string()),
                     additional_attributes: props.additional_attributes,
                     href: props.href,
-                    rel: None,
+                    rel: Some("stylesheet".to_string()),
                     disabled: None,
                     r#as: None,
                     sizes: None,