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
7 changes: 7 additions & 0 deletions .changeset/puny-jeans-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@devup-ui/wasm": patch
---

css util support media query
support devup json interface with wrong char
optimize zero value
60 changes: 30 additions & 30 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions apps/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"@devup-ui/reset-css": "workspace:*",
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@next/mdx": "^15.3.5",
"@next/mdx": "^15.4.1",
"@types/mdx": "^2.0.13",
"body-scroll-lock": "3.1.5",
"clsx": "^2.1.1",
"next": "^15.3.5",
"next": "^15.4.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-markdown": "^10.1.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"next": "^15.3.5",
"next": "^15.4.1",
"@devup-ui/react": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@devup-ui/react": "workspace:*"
},
"devDependencies": {
"@rsbuild/core": "^1.4.5",
"@rsbuild/core": "^1.4.7",
"@rsbuild/plugin-react": "^1.3.4",
"@devup-ui/rsbuild-plugin": "workspace:*"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/vite-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"react": "^19.1.0",
"@devup-ui/react": "workspace:*",
"vite": "^7.0.3"
"vite": "^7.0.5"
},
"devDependencies": {
"vite-plugin-dts": "^4.5.4",
Expand Down
2 changes: 1 addition & 1 deletion apps/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"@devup-ui/vite-plugin": "workspace:*",
"vite": "^7.0.3",
"vite": "^7.0.5",
"@vitejs/plugin-react": "^4.6.0",
"typescript": "^5",
"@types/node": "^24",
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 @@ -12,7 +12,7 @@
"dependencies": {
"@chakra-ui/react": "^3.22.0",
"@emotion/react": "^11.14.0",
"next": "^15.3.5",
"next": "^15.4.1",
"next-themes": "^0.4.6",
"react": "^19.1.0",
"react-dom": "^19.1.0",
Expand Down
2 changes: 1 addition & 1 deletion benchmark/next-devup-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"next": "^15.3.5",
"next": "^15.4.1",
"@devup-ui/react": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/next-kuma-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"next": "^15.3.5",
"next": "^15.4.1",
"@kuma-ui/core": "^1.5.9"
},
"devDependencies": {
Expand Down
86 changes: 6 additions & 80 deletions bindings/devup-ui-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,50 +231,12 @@ pub fn get_theme_interface(
theme_interface_name: &str,
) -> String {
let sheet = GLOBAL_STYLE_SHEET.lock().unwrap();
let mut color_keys = HashSet::new();
let mut typography_keys = HashSet::new();
let mut theme_keys = HashSet::new();
for color_theme in sheet.theme.colors.values() {
color_theme.0.keys().for_each(|key| {
color_keys.insert(key.clone());
});
}
sheet.theme.typography.keys().for_each(|key| {
typography_keys.insert(key.clone());
});

sheet.theme.colors.keys().for_each(|key| {
theme_keys.insert(key.clone());
});

if color_keys.is_empty() && typography_keys.is_empty() {
String::new()
} else {
format!(
"import \"{}\";declare module \"{}\"{{interface {}{{{}}}interface {}{{{}}}interface {}{{{}}}}}",
package_name,
package_name,
color_interface_name,
color_keys
.into_iter()
.map(|key| format!("${key}:null;"))
.collect::<Vec<String>>()
.join(""),
typography_interface_name,
typography_keys
.into_iter()
.map(|key| format!("{key}:null;"))
.collect::<Vec<String>>()
.join(""),
theme_interface_name,
theme_keys
.into_iter()
// key to pascal
.map(|key| format!("{key}:null;"))
.collect::<Vec<String>>()
.join("")
)
}
sheet.create_interface(
package_name,
color_interface_name,
typography_interface_name,
theme_interface_name,
)
}
#[cfg(test)]
mod tests {
Expand Down Expand Up @@ -311,42 +273,6 @@ mod tests {
);
}

#[test]
#[serial]
fn test_get_theme_interface() {
{
let mut sheet = GLOBAL_STYLE_SHEET.lock().unwrap();
*sheet = StyleSheet::default();
}
assert_eq!(
get_theme_interface(
"package",
"ColorInterface",
"TypographyInterface",
"ThemeInterface"
),
""
);

{
let mut sheet = GLOBAL_STYLE_SHEET.lock().unwrap();
let mut theme = Theme::default();
let mut color_theme = ColorTheme::default();
color_theme.add_color("primary", "#000");
theme.add_color_theme("dark", color_theme);
sheet.set_theme(theme);
}
assert_eq!(
get_theme_interface(
"package",
"ColorInterface",
"TypographyInterface",
"ThemeInterface"
),
"import \"package\";declare module \"package\"{interface ColorInterface{$primary:null;}interface TypographyInterface{}interface ThemeInterface{dark:null;}}"
);
}

#[test]
fn deserialize_theme() {
{
Expand Down
4 changes: 4 additions & 0 deletions libs/css/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ pub(super) static DOUBLE_SEPARATOR: phf::Set<&str> = phf_set! {
};

pub(super) static F_SPACE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\s*,\s*").unwrap());
pub(super) static F_DOT_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\b|,)0\.(\d+)").unwrap());
pub(super) static DOT_ZERO_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(\b|,)-?0\.0+([^\d])").unwrap());

pub(super) static COLOR_HASH: Lazy<Regex> = Lazy::new(|| Regex::new(r"#([0-9a-zA-Z]+)").unwrap());
pub(super) static ZERO_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(^|\s|\(|,)-?0(px|em|rem|vh|vw|%|dvh|dvw)").unwrap());
Loading