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/beige-cups-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/wasm": patch
---

Optimize str argument
5 changes: 5 additions & 0 deletions .changeset/green-mails-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/react": patch
---

Fix selector type
6 changes: 3 additions & 3 deletions bindings/devup-ui-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Output {
}
}
ExtractStyleValue::Css(cs) => {
if sheet.add_css(cls, cs.css.clone()) {
if sheet.add_css(&cls, &cs.css) {
collected = true;
}
}
Expand Down Expand Up @@ -156,15 +156,15 @@ fn theme_object_to_hashmap(js_value: JsValue) -> Result<Theme, JsValue> {
if let (Some(var_key_str), Some(var_value_str)) =
(var_key.as_string(), var_value.as_string())
{
color_theme.add_color(var_key_str, var_value_str);
color_theme.add_color(&var_key_str, &var_value_str);
} else {
return Err(JsValue::from_str(
"Failed to get key and value from the theme object",
));
}
}
}
theme.colors.add_theme(key_str, color_theme);
theme.colors.add_theme(&key_str, color_theme);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions libs/sheet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ impl StyleSheet {
self.properties.entry(level).or_default().insert(prop)
}

pub fn add_css(&mut self, class_name: String, css: String) -> bool {
let prop = StyleSheetCss { class_name, css };
pub fn add_css(&mut self, class_name: &str, css: &str) -> bool {
let prop = StyleSheetCss {
class_name: class_name.to_string(),
css: css.to_string(),
};
self.css.insert(prop)
}

Expand Down Expand Up @@ -264,7 +267,7 @@ mod tests {
assert_debug_snapshot!(sheet.create_css());

let mut sheet = StyleSheet::new();
sheet.add_css("test".to_string(), "display:flex;".to_string());
sheet.add_css("test", "display:flex;");
sheet.set_theme(Theme::new());
assert_debug_snapshot!(sheet.create_css());
}
Expand Down
26 changes: 13 additions & 13 deletions libs/sheet/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ impl ColorTheme {
}
}

pub fn add_color(&mut self, name: String, value: String) {
self.data.insert(name, value);
pub fn add_color(&mut self, name: &str, value: &str) {
self.data.insert(name.to_string(), value.to_string());
}

pub fn get_color(&self, name: &str) -> Option<&String> {
Expand Down Expand Up @@ -54,8 +54,8 @@ impl Color {
}
}

pub fn add_theme(&mut self, name: String, theme: ColorTheme) {
self.themes.insert(name, theme);
pub fn add_theme(&mut self, name: &str, theme: ColorTheme) {
self.themes.insert(name.to_string(), theme);
}

pub fn get_theme(&self, name: &str) -> Option<&ColorTheme> {
Expand Down Expand Up @@ -156,12 +156,12 @@ impl Theme {
}
}

pub fn add_color_theme(&mut self, name: String, theme: ColorTheme) {
pub fn add_color_theme(&mut self, name: &str, theme: ColorTheme) {
self.colors.add_theme(name, theme);
}

pub fn add_typography(&mut self, name: String, typography: Vec<Typography>) {
self.typography.insert(name, typography);
pub fn add_typography(&mut self, name: &str, typography: Vec<Typography>) {
self.typography.insert(name.to_string(), typography);
}

pub fn to_css(&self) -> String {
Expand Down Expand Up @@ -233,13 +233,13 @@ mod tests {
fn to_css_from_theme() {
let mut theme = Theme::new();
let mut color_theme = ColorTheme::new();
color_theme.add_color("primary".to_string(), "#000".to_string());
theme.add_color_theme("default".to_string(), color_theme);
color_theme.add_color("primary", "#000");
theme.add_color_theme("default", color_theme);
let mut color_theme = ColorTheme::new();
color_theme.add_color("primary".to_string(), "#fff".to_string());
theme.add_color_theme("dark".to_string(), color_theme);
color_theme.add_color("primary", "#fff");
theme.add_color_theme("dark", color_theme);
theme.add_typography(
"default".to_string(),
"default",
vec![
Typography::new(
Some("Arial".to_string()),
Expand All @@ -261,7 +261,7 @@ mod tests {
);

theme.add_typography(
"default1".to_string(),
"default1",
vec![Typography::new(
Some("Arial".to_string()),
Some("24px".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"lint": "eslint",
"build": "vite build"
"build": "tsc && vite build"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/types/props/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import type { DevupUiImageProps } from './image'
import type { DevupUiInlineProps } from './inline'
import type { DevupUiListProps } from './list'
import type { DevupUiMaskingProps } from './masking'
import type { DevupMediaProps } from './media'
import type { DevupUiMotionPathProps } from './motion-path'
import type { DevupUiOverflowProps } from './overflow'
import type { DevupUiOverflowBehaviorProps } from './overflow-behavior'
import type { DevupUiPositionProps } from './position'
import type { DevupUiScrollbarProps } from './scrollbar'
import type { DevupSelectorProps } from './selector'
import type { DevupUiShapeProps } from './shape'
import type { DevupUiTableProps } from './table'
import type { DevupUiTextProps } from './text'
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface DevupCommonProps
DevupUiUiProps,
DevupUiViewTransitionProps {}

export interface DevupProps extends DevupCommonProps, DevupMediaProps {
export interface DevupProps extends DevupCommonProps, DevupSelectorProps {
as?: React.ElementType
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/types/props/selector/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DevupCommonProps } from '../index'

export interface DevupMediaProps {
export interface DevupSelectorProps {
_active?: DevupCommonProps
_checked?: DevupCommonProps
_default?: DevupCommonProps
Expand Down
Loading