Skip to content

Commit 5f6e8da

Browse files
authored
Merge pull request #4 from dev-five-git/add-image
Add Image component
2 parents b9a7d5f + cc40ada commit 5f6e8da

File tree

30 files changed

+296
-91
lines changed

30 files changed

+296
-91
lines changed

.changeset/odd-zebras-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/webpack-plugin": patch
3+
---
4+
5+
Fix hot reload issue

.changeset/tricky-roses-ring.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@devup-ui/wasm": patch
3+
"@devup-ui/react": patch
4+
---
5+
6+
Add Image component

.github/workflows/check-pr.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- name: Upload to codecov.io
4444
uses: codecov/codecov-action@v5
4545
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
4647
fail_ci_if_error: true
4748
- name: Create Release Pull Request or Publish to npm
4849
id: changesets

apps/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"react": "^19.0.0",
1414
"react-dom": "^19.0.0",
15-
"next": "15.1.3",
15+
"next": "^15.1.4",
1616
"@devup-ui/react": "workspace:*"
1717
},
1818
"devDependencies": {

bindings/devup-ui-wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
"types": "./pkg/index.d.ts",
2626
"scripts": {
2727
"build": "wasm-pack build --target nodejs --out-dir ./pkg --out-name index",
28-
"test": "cargo test"
28+
"test": "wasm-pack test --node"
2929
}
3030
}

bindings/devup-ui-wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn code_extract(
106106
Err(error) => Err(JsValue::from_str(error.to_string().as_str())),
107107
}
108108
}
109-
fn object_to_typography(obj: Object, level: u8) -> Result<Typography, JsValue> {
109+
pub fn object_to_typography(obj: Object, level: u8) -> Result<Typography, JsValue> {
110110
Ok(Typography::new(
111111
Reflect::get(&obj, &JsValue::from_str("fontFamily"))?
112112
.as_string()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use devup_ui_wasm::object_to_typography;
2+
use js_sys::{Object, Reflect};
3+
use wasm_bindgen::JsValue;
4+
use wasm_bindgen_test::*;
5+
6+
#[allow(dead_code)]
7+
#[wasm_bindgen_test]
8+
fn test_object_to_typography() {
9+
let obj = Object::new();
10+
Reflect::set(
11+
&obj,
12+
&JsValue::from_str("fontFamily"),
13+
&JsValue::from_str("Arial"),
14+
)
15+
.unwrap();
16+
Reflect::set(
17+
&obj,
18+
&JsValue::from_str("fontSize"),
19+
&JsValue::from_str("12px"),
20+
)
21+
.unwrap();
22+
Reflect::set(
23+
&obj,
24+
&JsValue::from_str("fontWeight"),
25+
&JsValue::from_str("bold"),
26+
)
27+
.unwrap();
28+
Reflect::set(
29+
&obj,
30+
&JsValue::from_str("lineHeight"),
31+
&JsValue::from_str("1.5"),
32+
)
33+
.unwrap();
34+
Reflect::set(
35+
&obj,
36+
&JsValue::from_str("letterSpacing"),
37+
&JsValue::from_str("1px"),
38+
)
39+
.unwrap();
40+
let typography = object_to_typography(obj, 0).unwrap();
41+
assert_eq!(typography.font_family, "Arial");
42+
assert_eq!(typography.font_size, "12px");
43+
assert_eq!(typography.font_weight, "bold");
44+
assert_eq!(typography.line_height, "1.5");
45+
assert_eq!(typography.letter_spacing, "1px");
46+
assert_eq!(typography.level, 0);
47+
}

bindings/devup-ui-wasm/tests/web.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

libs/extractor/src/component.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub enum ExportVariableKind {
1111
Flex,
1212
VStack,
1313
Center,
14+
Image,
1415
Css,
1516
}
1617

@@ -23,6 +24,7 @@ impl ExportVariableKind {
2324
| ExportVariableKind::Flex
2425
| ExportVariableKind::Box => Ok("div"),
2526
ExportVariableKind::Text => Ok("span"),
27+
ExportVariableKind::Image => Ok("img"),
2628
ExportVariableKind::Button => Ok("button"),
2729
ExportVariableKind::Input => Ok("input"),
2830
ExportVariableKind::Css => Err("Css does not have a tag"),
@@ -37,6 +39,7 @@ impl ExportVariableKind {
3739
| ExportVariableKind::Button
3840
| ExportVariableKind::Css
3941
| ExportVariableKind::Text
42+
| ExportVariableKind::Image
4043
| ExportVariableKind::Box => vec![],
4144
ExportVariableKind::Flex => vec![Static(ExtractStaticStyle {
4245
value: "flex".to_string(),
@@ -93,6 +96,7 @@ impl TryFrom<String> for ExportVariableKind {
9396
match value.as_str() {
9497
"Box" => Ok(ExportVariableKind::Box),
9598
"Text" => Ok(ExportVariableKind::Text),
99+
"Image" => Ok(ExportVariableKind::Image),
96100
"Button" => Ok(ExportVariableKind::Button),
97101
"Input" => Ok(ExportVariableKind::Input),
98102
"Flex" => Ok(ExportVariableKind::Flex),
@@ -118,6 +122,10 @@ mod tests {
118122
ExportVariableKind::try_from("Text".to_string()),
119123
Ok(ExportVariableKind::Text)
120124
);
125+
assert_eq!(
126+
ExportVariableKind::try_from("Image".to_string()),
127+
Ok(ExportVariableKind::Image)
128+
);
121129
assert_eq!(
122130
ExportVariableKind::try_from("Button".to_string()),
123131
Ok(ExportVariableKind::Button)
@@ -149,6 +157,7 @@ mod tests {
149157
fn test_to_tag() {
150158
assert_eq!(ExportVariableKind::Box.to_tag(), Ok("div"));
151159
assert_eq!(ExportVariableKind::Text.to_tag(), Ok("span"));
160+
assert_eq!(ExportVariableKind::Image.to_tag(), Ok("img"));
152161
assert_eq!(ExportVariableKind::Button.to_tag(), Ok("button"));
153162
assert_eq!(ExportVariableKind::Input.to_tag(), Ok("input"));
154163
assert_eq!(ExportVariableKind::Flex.to_tag(), Ok("div"));
@@ -161,6 +170,7 @@ mod tests {
161170
fn test_extract_style_from_kind() {
162171
assert_eq!(ExportVariableKind::Box.extract(), vec![]);
163172
assert_eq!(ExportVariableKind::Text.extract(), vec![]);
173+
assert_eq!(ExportVariableKind::Image.extract(), vec![]);
164174
assert_eq!(ExportVariableKind::Button.extract(), vec![]);
165175
assert_eq!(ExportVariableKind::Input.extract(), vec![]);
166176
assert_eq!(

0 commit comments

Comments
 (0)