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>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2025-01-31 15:06:14 -08:00
1 parent 2fd7684a93
commit 5bb7f51cba
1 file changed
+7 -2
+7 -2
View File
@@ -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. /// 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 // The style has a src, render it as a link tag
(Some(_), _) => { (Some(_), _) => {
attributes.push(("type", "text/css".into())); attributes.push(("type", "text/css".into()));
attributes.push(("rel", "stylesheet".into()));
document.create_link(LinkProps { document.create_link(LinkProps {
media: props.media, media: props.media,
title: props.title, title: props.title,
r#type: Some("text/css".to_string()), r#type: Some("text/css".to_string()),
additional_attributes: props.additional_attributes, additional_attributes: props.additional_attributes,
href: props.href, href: props.href,
rel: None, rel: Some("stylesheet".to_string()),
disabled: None, disabled: None,
r#as: None, r#as: None,
sizes: None, sizes: None,