Skip to content

Commit

Permalink
Refactor Border Radius struct
Browse files Browse the repository at this point in the history
  • Loading branch information
david0xd committed Jan 20, 2025
1 parent ac90ec9 commit 9b0d9a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "BiCtwmtmQRs6IrssjgH8PXZWH7afx75+RKXMnl9KDZ8=",
"shasum": "B0senywfM+w5lQ+iMvK+bVcKJ6VeLDj7HiUVYR5Cuag=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "9K88gT7CbGCXTc/Qx63zbS91VQtHTkFFXWLjyXoM6YU=",
"shasum": "PS0U7SHYXWpFhO8QMtArHKU1rFzMkwtTLFlc3/g1HQ4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
17 changes: 11 additions & 6 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,22 @@ function elementWithSelectiveProps<
});
}

/**
* Shared struct used to validate border radius values used by various Snaps components.
*/
export const BorderRadiusStruct = nullUnion([
literal('none'),
literal('medium'),
literal('full'),
]);

/**
* A struct for the {@link ImageElement} type.
*/
export const ImageStruct: Describe<ImageElement> = element('Image', {
src: svg(),
alt: optional(string()),
borderRadius: optional(
nullUnion([literal('none'), literal('medium'), literal('full')]),
),
borderRadius: optional(BorderRadiusStruct),
});

const IconNameStruct: Struct<`${IconName}`, null> = nullUnion(
Expand Down Expand Up @@ -698,9 +705,7 @@ export const LinkStruct: Describe<LinkElement> = element('Link', {
export const SkeletonStruct: Describe<SkeletonElement> = element('Skeleton', {
width: optional(union([number(), string()])),
height: optional(union([number(), string()])),
borderRadius: optional(
nullUnion([literal('none'), literal('medium'), literal('full')]),
),
borderRadius: optional(BorderRadiusStruct),
});

/**
Expand Down

0 comments on commit 9b0d9a7

Please sign in to comment.