Skip to content

Commit 14bdb20

Browse files
authored
Merge pull request #197 from dev-five-git/add-vendor-properties
Add vendor properties
2 parents 511865d + bb2f49f commit 14bdb20

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

.changeset/honest-mirrors-know.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@devup-ui/react": patch
3+
"@devup-ui/wasm": patch
4+
---
5+
6+
Add vendor properties (moz, webkit, ms)

libs/css/src/lib.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,22 @@ pub fn convert_property(property: &str) -> PropertyType {
312312
1 => PropertyType::Single(v[0].to_string()),
313313
_ => PropertyType::Multi(v.iter().map(|v| v.to_string()).collect()),
314314
})
315-
.unwrap_or_else(|| to_kebab_case(property).into())
315+
.unwrap_or_else(|| {
316+
if (property.starts_with("Webkit")
317+
&& property.len() > 6
318+
&& property.chars().nth(6).unwrap().is_uppercase())
319+
|| (property.starts_with("Moz")
320+
&& property.len() > 3
321+
&& property.chars().nth(3).unwrap().is_uppercase())
322+
|| (property.starts_with("ms")
323+
&& property.len() > 2
324+
&& property.chars().nth(2).unwrap().is_uppercase())
325+
{
326+
PropertyType::Single(format!("-{}", to_kebab_case(property)))
327+
} else {
328+
to_kebab_case(property).into()
329+
}
330+
})
316331
}
317332

318333
pub fn short_to_long(property: &str) -> String {
@@ -877,6 +892,22 @@ mod tests {
877892
);
878893
}
879894

895+
#[test]
896+
fn test_convert_vendor_property() {
897+
assert_eq!(
898+
convert_property("MozUserSelect"),
899+
PropertyType::Single("-moz-user-select".to_string())
900+
);
901+
assert_eq!(
902+
convert_property("msAccelerator"),
903+
PropertyType::Single("-ms-accelerator".to_string())
904+
);
905+
assert_eq!(
906+
convert_property("WebkitAlignContent"),
907+
PropertyType::Single("-webkit-align-content".to_string())
908+
);
909+
}
910+
880911
#[test]
881912
fn test_property_type_from() {
882913
assert_eq!(

packages/react/src/types/props/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ import type { DevupUiTextProps } from './text'
2828
import type { DevupUiTransformProps } from './transform'
2929
import type { DevupUiTransitionProps } from './transition'
3030
import type { DevupUiUiProps } from './ui'
31+
import type { DevupUiVendorProps } from './vendor'
3132
import type { DevupUiViewTransitionProps } from './view-transition'
3233

3334
export interface DevupCommonProps
34-
extends DevupUiAnimationProps,
35+
extends DevupUiVendorProps,
36+
DevupUiAnimationProps,
3537
DevupUiBackgroundProps,
3638
DevupUiBlendingProps,
3739
DevupUiBorderProps,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type {
2+
VendorLonghandProperties,
3+
VendorShorthandProperties,
4+
} from 'csstype'
5+
6+
import type { ResponsiveValue } from '../responsive-value'
7+
8+
export type DevupUiVendorProps = {
9+
[key in keyof (VendorLonghandProperties &
10+
VendorShorthandProperties)]: ResponsiveValue<
11+
(VendorLonghandProperties & VendorShorthandProperties)[key]
12+
>
13+
}

0 commit comments

Comments
 (0)