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": "d1js9Y4zJwk7n/e47V5fdMreo1FBtVKl4GtPhfckZrs=",
"shasum": "lyy+HECzOFQzuzjyD1nas6GPc4kMt340ChbqQZl7uEo=",
"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": "2OhDjaajEbvT1LdHB1G/Jl9NpfRtJxYl87w1c+1eJck=",
"shasum": "k7NYoT8jI2E4u785PN5PoruwtjF18KNOSagNY9fS44U=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
19 changes: 19 additions & 0 deletions packages/snaps-sdk/src/jsx/components/form/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,23 @@ describe('Button', () => {
key: null,
});
});

it('returns a button element with a variant and loading state', () => {
const result = (
<Button type="button" variant="primary" loading={true}>
foo
</Button>
);

expect(result).toStrictEqual({
type: 'Button',
props: {
children: 'foo',
type: 'button',
variant: 'primary',
loading: true,
},
key: null,
});
});
});
2 changes: 2 additions & 0 deletions packages/snaps-sdk/src/jsx/components/form/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { ImageElement } from '../Image';
* @property variant - The variant of the button, i.e., `'primary'` or
* `'destructive'`. Defaults to `'primary'`.
* @property disabled - Whether the button is disabled. Defaults to `false`.
* @property loading - Whether the button is loading. Defaults to `false`.
* @property form - The name of the form component to associate the button with.
*/
export type ButtonProps = {
Expand All @@ -24,6 +25,7 @@ export type ButtonProps = {
type?: 'button' | 'submit' | undefined;
variant?: 'primary' | 'destructive' | undefined;
disabled?: boolean | undefined;
loading?: boolean | undefined;
form?: string | undefined;
};

Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/jsx/validation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ describe('ButtonStruct', () => {
<Button type="submit">foo</Button>,
<Button variant="destructive">foo</Button>,
<Button disabled={true}>foo</Button>,
<Button variant="primary" loading={true}>
foo
</Button>,
<Button key="button">foo</Button>,
<Button>
<Icon name="wifi" />
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 @@ -245,6 +245,7 @@ export const ButtonStruct: Describe<ButtonElement> = element('Button', {
type: optional(nullUnion([literal('button'), literal('submit')])),
variant: optional(nullUnion([literal('primary'), literal('destructive')])),
disabled: optional(boolean()),
loading: optional(boolean()),
form: optional(string()),
});

Expand Down
Loading