Skip to content

Commit 292f7af

Browse files
authored
Merge pull request #500 from dev-five-git/add-header
Add header to css
2 parents 6e57683 + 30e0888 commit 292f7af

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"changes": { "bindings/devup-ui-wasm/package.json": "Patch" },
3+
"note": "Add header to css",
4+
"date": "2025-11-26T07:12:47.012760800Z"
5+
}

libs/sheet/src/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -554,23 +554,25 @@ impl StyleSheet {
554554
}
555555

556556
pub fn create_css(&self, filename: Option<&str>, import_main_css: bool) -> String {
557-
let mut css = self
558-
.imports
559-
.values()
560-
.flatten()
561-
.map(|import| {
562-
if import.starts_with("\"") {
563-
format!("@import {import};")
564-
} else {
565-
format!("@import \"{import}\";")
566-
}
567-
})
568-
.collect::<String>();
557+
let header = self.create_header();
558+
let mut css = format!(
559+
"{header}{}",
560+
self.imports
561+
.values()
562+
.flatten()
563+
.map(|import| {
564+
if import.starts_with("\"") {
565+
format!("@import {import};")
566+
} else {
567+
format!("@import \"{import}\";")
568+
}
569+
})
570+
.collect::<String>()
571+
);
569572

570573
let write_global = filename.is_none();
571574

572575
if write_global {
573-
css.insert_str(0, self.create_header().as_str());
574576
let mut style_orders: BTreeSet<u8> = BTreeSet::new();
575577
let mut base_styles = BTreeMap::<u8, HashSet<StyleSheetProperty>>::new();
576578
self.properties.values().for_each(|map| {

libs/sheet/src/snapshots/sheet__tests__import_css.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
source: libs/sheet/src/lib.rs
33
expression: "sheet.create_css(Some(\"index.tsx\"), true)"
44
---
5-
"@import \"./devup-ui.css\";"
5+
"/*! devup-ui v1.0.48, | Apache License 2.0 | https://devup-ui.com */@import \"./devup-ui.css\";"

libs/sheet/src/snapshots/sheet__tests__update_styles.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
source: libs/sheet/src/lib.rs
33
expression: "sheet.create_css(Some(\"index.tsx\"), true)"
44
---
5-
"@import \"./devup-ui.css\";"
5+
"/*! devup-ui v1.0.48, | Apache License 2.0 | https://devup-ui.com */@import \"./devup-ui.css\";"

0 commit comments

Comments
 (0)