Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "IdAFrQlUYgQaMo/lbXgEJOMKTFbB9RYylXwPvUFT6As=",
"shasum": "ecGX3duI1nyJ8BOjkIPLze204JXMQKL8Eq1ir8Mm/dg=",
"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": "bzhrHkJoo2dRz2utZ10KRNL2X2mgRxkur3DrGXHbNOc=",
"shasum": "KSkMBlnuET6wdxlrTCFlg6h1GDiCK8ShQoTbKPse0Ek=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
13 changes: 13 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ describe('Text', () => {
},
});
});

it('renders text with props', () => {
const result = <Text size="sm">Hello world!</Text>;

expect(result).toStrictEqual({
type: 'Text',
key: null,
props: {
children: 'Hello world!',
size: 'sm',
},
});
});
});
7 changes: 7 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export type TextColors =
* @property children - The text to display.
* @property alignment - The alignment of the text.
* @property color - The color of the text.
* @property size - The size of the text. Defaults to `md`.
*/
export type TextProps = {
children: TextChildren;
alignment?: 'start' | 'center' | 'end' | undefined;
color?: TextColors | undefined;
size?: 'sm' | 'md' | undefined;
};

const TYPE = 'Text';
Expand All @@ -44,6 +46,7 @@ const TYPE = 'Text';
* @param props.alignment - The alignment of the text.
* @param props.color - The color of the text.
* @param props.children - The text to display.
* @param props.size - The size of the text. Defaults to `md`.
* @returns A text element.
* @example
* <Text>
Expand All @@ -53,6 +56,10 @@ const TYPE = 'Text';
* <Text alignment="end">
* Hello <Bold>world</Bold>!
* </Text>
* @example
* <Text size="sm">
* Hello <Bold>world</Bold>!
* </Text>
*/
export const Text = createSnapComponent<TextProps, typeof TYPE>(TYPE);

Expand Down
1 change: 1 addition & 0 deletions packages/snaps-sdk/src/jsx/validation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ describe('TextStruct', () => {
<Text>
Hello, <Bold>world</Bold>
</Text>,
<Text size="sm">foo</Text>,
])('validates a text element', (value) => {
expect(is(value, TextStruct)).toBe(true);
});
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ export const TextStruct: Describe<TextElement> = element('Text', {
literal('warning'),
]),
),
size: optional(nullUnion([literal('sm'), literal('md')])),
});

/**
Expand Down
Loading