Skip to content

Commit 6100644

Browse files
committed
Add Image component
1 parent 8994a50 commit 6100644

File tree

26 files changed

+188
-53
lines changed

26 files changed

+188
-53
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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ jobs:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111
runs-on: ubuntu-latest
12+
container:
13+
image: xd009642/tarpaulin:develop-nightly
14+
options: --security-opt seccomp=unconfined
1215
steps:
1316
- name: Checkout
1417
uses: actions/checkout@v4
1518
- uses: actions-rust-lang/setup-rust-toolchain@v1
16-
- name: Cargo tarpaulin
17-
run: cargo install cargo-tarpaulin
1819
- uses: jetli/[email protected]
1920
with:
2021
version: 'latest'
@@ -34,3 +35,10 @@ jobs:
3435
pnpm build
3536
pnpm lint
3637
pnpm test
38+
- name: Generate code coverage
39+
run: |
40+
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml
41+
- name: Upload to codecov.io
42+
uses: codecov/codecov-action@v5
43+
with:
44+
fail_ci_if_error: true

.github/workflows/publish.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ jobs:
1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
1313
cancel-in-progress: false
14+
container:
15+
image: xd009642/tarpaulin:develop-nightly
16+
options: --security-opt seccomp=unconfined
1417
steps:
1518
- name: Checkout
1619
uses: actions/checkout@v4
1720

1821
- uses: actions-rust-lang/setup-rust-toolchain@v1
19-
- name: Cargo tarpaulin
20-
run: cargo install cargo-tarpaulin
2122
- uses: pnpm/action-setup@v4
2223
name: Install pnpm
2324
with:
@@ -37,6 +38,13 @@ jobs:
3738
pnpm build
3839
pnpm lint
3940
pnpm test
41+
- name: Generate code coverage
42+
run: |
43+
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml
44+
- name: Upload to codecov.io
45+
uses: codecov/codecov-action@v5
46+
with:
47+
fail_ci_if_error: true
4048
- name: Create Release Pull Request or Publish to npm
4149
id: changesets
4250
uses: changesets/action@v1

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,51 @@ pub fn get_theme_interface(
260260
))
261261
}
262262
}
263+
264+
#[cfg(test)]
265+
mod tests {
266+
use super::*;
267+
use wasm_bindgen_test::*;
268+
269+
#[wasm_bindgen_test]
270+
fn test_object_to_typography() {
271+
let obj = Object::new();
272+
Reflect::set(
273+
&obj,
274+
&JsValue::from_str("fontFamily"),
275+
&JsValue::from_str("Arial"),
276+
)
277+
.unwrap();
278+
Reflect::set(
279+
&obj,
280+
&JsValue::from_str("fontSize"),
281+
&JsValue::from_str("12px"),
282+
)
283+
.unwrap();
284+
Reflect::set(
285+
&obj,
286+
&JsValue::from_str("fontWeight"),
287+
&JsValue::from_str("bold"),
288+
)
289+
.unwrap();
290+
Reflect::set(
291+
&obj,
292+
&JsValue::from_str("lineHeight"),
293+
&JsValue::from_str("1.5"),
294+
)
295+
.unwrap();
296+
Reflect::set(
297+
&obj,
298+
&JsValue::from_str("letterSpacing"),
299+
&JsValue::from_str("1px"),
300+
)
301+
.unwrap();
302+
let typography = object_to_typography(obj, 0).unwrap();
303+
assert_eq!(typography.font_family, "Arial");
304+
assert_eq!(typography.font_size, "12px");
305+
assert_eq!(typography.font_weight, "bold");
306+
assert_eq!(typography.line_height, "1.5");
307+
assert_eq!(typography.letter_spacing, "1px");
308+
assert_eq!(typography.level, 0);
309+
}
310+
}

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!(

libs/extractor/src/visit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ impl<'a> VisitMut<'a> for DevupVisitor<'a> {
120120
|| name == "role"
121121
|| name == "ref"
122122
|| name == "key"
123+
|| name == "alt"
124+
|| name == "src"
123125
|| name == "children"
124126
{
125127
continue;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "module",
77
"scripts": {
88
"lint": "pnpm -r lint",
9-
"test": "cargo tarpaulin && vitest test --coverage --run",
9+
"test": "cargo tarpaulin && vitest test --coverage --run && pnpm -r test",
1010
"build": "pnpm -r build",
1111
"dev": "pnpm -r dev"
1212
},

packages/next-plugin/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"next": "^15.1"
88
},
99
"scripts": {
10-
"test": "vitest run --coverage",
1110
"test:s": "vitest run -u",
1211
"lint": "eslint",
1312
"build": "tsc && vite build"

0 commit comments

Comments
 (0)