diff --git a/.changeset/big-waves-dance.md b/.changeset/big-waves-dance.md new file mode 100644 index 00000000..82e82b63 --- /dev/null +++ b/.changeset/big-waves-dance.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/wasm": patch +--- + +Fix multi imports issue diff --git a/.changeset/flat-states-relax.md b/.changeset/flat-states-relax.md new file mode 100644 index 00000000..a7b9f8c0 --- /dev/null +++ b/.changeset/flat-states-relax.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/wasm": patch +--- + +Optimize rgba func diff --git a/apps/landing/src/app/layout.tsx b/apps/landing/src/app/layout.tsx index 98fcfbd2..76a8d989 100644 --- a/apps/landing/src/app/layout.tsx +++ b/apps/landing/src/app/layout.tsx @@ -26,7 +26,6 @@ export const metadata: Metadata = { resetCss() globalCss({ - imports: ['https://cdn.jsdelivr.net/gh/joungkyun/font-d2coding/d2coding.css'], table: { borderCollapse: 'collapse', borderSpacing: 0, @@ -76,6 +75,10 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= + , #[serde(default)] - pub imports: BTreeMap, + pub imports: BTreeMap>, #[serde(skip)] pub theme: Theme, } @@ -182,7 +182,10 @@ impl StyleSheet { pub fn add_import(&mut self, file: &str, import: &str) { self.global_css_files.insert(file.to_string()); - self.imports.insert(file.to_string(), import.to_string()); + self.imports + .entry(file.to_string()) + .or_default() + .insert(import.to_string()); } pub fn add_css(&mut self, file: &str, css: &str) -> bool { @@ -289,6 +292,7 @@ impl StyleSheet { let mut css = self .imports .values() + .flatten() .map(|import| format!("@import \"{import}\";")) .collect::>() .join(""); @@ -902,12 +906,26 @@ mod tests { #[test] fn test_create_css_with_imports() { - let mut sheet = StyleSheet::default(); - sheet.add_import("test.tsx", "@devup-ui/core/css/global.css"); - sheet.add_import("test2.tsx", "@devup-ui/core/css/global2.css"); - sheet.add_import("test3.tsx", "@devup-ui/core/css/global3.css"); - sheet.add_import("test4.tsx", "@devup-ui/core/css/global4.css"); - assert_debug_snapshot!(sheet.create_css()); + { + let mut sheet = StyleSheet::default(); + sheet.add_import("test.tsx", "@devup-ui/core/css/global.css"); + sheet.add_import("test2.tsx", "@devup-ui/core/css/global2.css"); + sheet.add_import("test3.tsx", "@devup-ui/core/css/global3.css"); + sheet.add_import("test4.tsx", "@devup-ui/core/css/global4.css"); + assert_debug_snapshot!(sheet.create_css()); + } + { + let mut sheet = StyleSheet::default(); + sheet.add_import("test.tsx", "@devup-ui/core/css/global.css"); + sheet.add_import("test.tsx", "@devup-ui/core/css/new-global.css"); + assert_debug_snapshot!(sheet.create_css()); + } + { + let mut sheet = StyleSheet::default(); + sheet.add_import("test.tsx", "@devup-ui/core/css/global.css"); + sheet.add_import("test.tsx", "@devup-ui/core/css/global.css"); + assert_debug_snapshot!(sheet.create_css()); + } } #[test] diff --git a/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-2.snap b/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-2.snap new file mode 100644 index 00000000..2432f960 --- /dev/null +++ b/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-2.snap @@ -0,0 +1,5 @@ +--- +source: libs/sheet/src/lib.rs +expression: sheet.create_css() +--- +"@import \"@devup-ui/core/css/global.css\";@import \"@devup-ui/core/css/new-global.css\";" diff --git a/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-3.snap b/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-3.snap new file mode 100644 index 00000000..218604a2 --- /dev/null +++ b/libs/sheet/src/snapshots/sheet__tests__create_css_with_imports-3.snap @@ -0,0 +1,5 @@ +--- +source: libs/sheet/src/lib.rs +expression: sheet.create_css() +--- +"@import \"@devup-ui/core/css/global.css\";"