Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-ravens-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/vite-plugin": patch
---

Fix css duplicate issue when exporting
5 changes: 5 additions & 0 deletions .changeset/young-chairs-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/wasm": patch
---

Apply css optimize
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default function App() {
hello
<Lib />
</Box>
<Text color="#777777"></Text>
<Text color="#777"></Text>
<Text color="#777"></Text>
<Text typography="header">typo</Text>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/next-chakra-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "next lint"
},
"dependencies": {
"@chakra-ui/react": "^3.15.0",
"@chakra-ui/react": "^3.15.1",
"@emotion/react": "^11.14.0",
"next": "^15.2.4",
"next-themes": "^0.4.6",
Expand Down
2 changes: 1 addition & 1 deletion bindings/devup-ui-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static GLOBAL_STYLE_SHEET: Lazy<Mutex<StyleSheet>> =
#[wasm_bindgen]
pub struct Output {
code: String,
styles: Vec<ExtractStyleValue>,
styles: HashSet<ExtractStyleValue>,
}
#[wasm_bindgen]
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion libs/css/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ fn optimize_color(value: &str) -> String {
format!("#{}", ret)
}

fn optimize_value(value: &str) -> String {
pub fn optimize_value(value: &str) -> String {
let mut ret = value.trim().to_string();
if ret.contains(",") {
ret = F_SPACE_RE.replace_all(&ret, ",").trim().to_string();
Expand Down
30 changes: 15 additions & 15 deletions libs/extractor/src/extract_style/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::utils::convert_value;
use crate::StyleProperty;
use crate::utils::convert_value;
use css::{
css_to_classname, sheet_to_classname, sheet_to_variable_name, short_to_long, StyleSelector,
StyleSelector, css_to_classname, optimize_value, sheet_to_classname, sheet_to_variable_name,
short_to_long,
};
use once_cell::sync::Lazy;
use std::collections::HashSet;

#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Eq, Hash, Ord, PartialOrd)]
pub struct ExtractStaticStyle {
/// property
property: String,
Expand Down Expand Up @@ -46,11 +47,11 @@ impl ExtractStaticStyle {
/// create a new ExtractStaticStyle
pub fn new(property: &str, value: &str, level: u8, selector: Option<StyleSelector>) -> Self {
Self {
value: if MAINTAIN_VALUE_PROPERTIES.contains(property) {
value: optimize_value(&if MAINTAIN_VALUE_PROPERTIES.contains(property) {
value.to_string()
} else {
convert_value(value)
},
}),
property: short_to_long(property),
level,
selector,
Expand All @@ -65,11 +66,11 @@ impl ExtractStaticStyle {
selector: Option<StyleSelector>,
) -> Self {
Self {
value: if MAINTAIN_VALUE_PROPERTIES.contains(property) {
value: optimize_value(&if MAINTAIN_VALUE_PROPERTIES.contains(property) {
value.to_string()
} else {
convert_value(value)
},
}),
property: property.to_string(),
level,
selector,
Expand Down Expand Up @@ -109,20 +110,19 @@ impl ExtractStyleProperty for ExtractStaticStyle {
StyleProperty::ClassName(sheet_to_classname(
self.property.as_str(),
self.level,
Some(
if MAINTAIN_VALUE_PROPERTIES.contains(self.property.as_str()) {
Some(&optimize_value(
&if MAINTAIN_VALUE_PROPERTIES.contains(self.property.as_str()) {
self.value.to_string()
} else {
convert_value(self.value.as_str())
}
.as_str(),
),
},
)),
s.as_deref(),
self.style_order,
))
}
}
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Eq, Hash, Ord, PartialOrd)]
pub struct ExtractCss {
/// css code
pub css: String,
Expand All @@ -135,7 +135,7 @@ impl ExtractStyleProperty for ExtractCss {
}
}

#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Eq, Hash, Ord, PartialOrd)]
pub struct ExtractDynamicStyle {
/// property
property: String,
Expand Down Expand Up @@ -207,7 +207,7 @@ impl ExtractStyleProperty for ExtractDynamicStyle {
}
}
}
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Eq, Hash, Ord, PartialOrd)]
pub enum ExtractStyleValue {
Static(ExtractStaticStyle),
Typography(String),
Expand Down
Loading