Skip to content

Commit 1229373

Browse files
committed
Make some updates to extend Skeleton params possibilities
1 parent 98a7dd2 commit 1229373

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

packages/snaps-sdk/src/jsx/components/Banner.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ButtonElement } from './form/Button';
33
import type { StandardFormattingElement } from './formatting';
44
import type { IconElement } from './Icon';
55
import type { LinkElement } from './Link';
6+
import type { SkeletonElement } from './Skeleton';
67
import type { TextElement } from './Text';
78

89
/**
@@ -14,6 +15,7 @@ export type BannerChildren = SnapsChildren<
1415
| LinkElement
1516
| IconElement
1617
| ButtonElement
18+
| SkeletonElement
1719
>;
1820

1921
/**

packages/snaps-sdk/src/jsx/components/Skeleton.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import type { BorderRadius } from './utils';
99
* @param borderRadius - Border radius of the Skeleton.
1010
*/
1111
export type SkeletonProps = {
12-
width: number | string;
13-
height: number | string;
12+
width?: number | string | undefined;
13+
height?: number | string | undefined;
1414
borderRadius?: BorderRadius | undefined;
1515
};
1616

packages/snaps-sdk/src/jsx/components/Text.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import { createSnapComponent } from '../component';
33
import type { StandardFormattingElement } from './formatting';
44
import type { IconElement } from './Icon';
55
import type { LinkElement } from './Link';
6+
import type { SkeletonElement } from './Skeleton';
67

78
/**
89
* The children of the {@link Text} component.
910
*/
1011
export type TextChildren = SnapsChildren<
11-
string | StandardFormattingElement | LinkElement | IconElement
12+
| string
13+
| StandardFormattingElement
14+
| LinkElement
15+
| IconElement
16+
| SkeletonElement
1217
>;
1318

1419
/**

packages/snaps-sdk/src/jsx/validation.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,7 @@ describe('BannerStruct', () => {
16231623

16241624
describe('SkeletonStruct', () => {
16251625
it.each([
1626+
<Skeleton />,
16261627
<Skeleton width={320} height={32} />,
16271628
<Skeleton width="30%" height="30%" />,
16281629
<Skeleton width={32} height="30%" />,
@@ -1641,8 +1642,6 @@ describe('SkeletonStruct', () => {
16411642
{},
16421643
[],
16431644
// @ts-expect-error - Invalid props.
1644-
<Skeleton />,
1645-
// @ts-expect-error - Invalid props.
16461645
<Skeleton foo="bar">foo</Skeleton>,
16471646
// @ts-expect-error - Invalid props.
16481647
<Skeleton title={<Copyable value="bar" />} severity="info">

packages/snaps-sdk/src/jsx/validation.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,17 @@ export const LinkStruct: Describe<LinkElement> = element('Link', {
692692
]),
693693
});
694694

695+
/**
696+
* A struct for the {@link SkeletonElement} type.
697+
*/
698+
export const SkeletonStruct: Describe<SkeletonElement> = element('Skeleton', {
699+
width: optional(union([number(), string()])),
700+
height: optional(union([number(), string()])),
701+
borderRadius: optional(
702+
nullUnion([literal('none'), literal('medium'), literal('full')]),
703+
),
704+
});
705+
695706
/**
696707
* A struct for the {@link TextElement} type.
697708
*/
@@ -701,7 +712,13 @@ export const TextStruct: Describe<TextElement> = element('Text', {
701712
if (typeof value === 'string') {
702713
return string();
703714
}
704-
return typedUnion([BoldStruct, ItalicStruct, LinkStruct, IconStruct]);
715+
return typedUnion([
716+
BoldStruct,
717+
ItalicStruct,
718+
LinkStruct,
719+
IconStruct,
720+
SkeletonStruct,
721+
]);
705722
}),
706723
]),
707724
alignment: optional(
@@ -797,6 +814,7 @@ export const BannerStruct: Describe<BannerElement> = element('Banner', {
797814
ButtonStruct,
798815
BoldStruct,
799816
ItalicStruct,
817+
SkeletonStruct,
800818
]),
801819
title: string(),
802820
severity: union([
@@ -807,17 +825,6 @@ export const BannerStruct: Describe<BannerElement> = element('Banner', {
807825
]),
808826
});
809827

810-
/**
811-
* A struct for the {@link SkeletonElement} type.
812-
*/
813-
export const SkeletonStruct: Describe<SkeletonElement> = element('Skeleton', {
814-
width: union([number(), string()]),
815-
height: union([number(), string()]),
816-
borderRadius: optional(
817-
nullUnion([literal('none'), literal('medium'), literal('full')]),
818-
),
819-
});
820-
821828
/**
822829
* A struct for the {@link RowElement} type.
823830
*/

0 commit comments

Comments
 (0)