Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requireScroll prop to Footer component #3031

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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": "R4WjwqkDLNMUtU07n8AGq0WZKjsqjTjQXlASF++J4ws=",
"shasum": "De8O5Kl1WuhMlQ0x4AHRdPJJ7zaXd4ZNzfT5LyXshtg=",
"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": "06xWu+ehUlNMpbJQxTZi2mlnAJId3cLHEK6fWD2Z9rc=",
"shasum": "4l1mZ42J5xkiQDL32cK7LzGnCsQHJAtPt5mRIgbLN8g=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/snaps-sdk/src/jsx/components/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Footer', () => {

it('renders a footer element with multiple buttons', () => {
const result = (
<Footer>
<Footer requireScroll>
<Button name="cancel">Cancel</Button>
<Button name="confirm">Confirm</Button>
</Footer>
Expand All @@ -37,6 +37,7 @@ describe('Footer', () => {
type: 'Footer',
key: null,
props: {
requireScroll: true,
children: [
{
type: 'Button',
Expand Down
8 changes: 8 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import type { ButtonElement } from './form';
* The props of the {@link Footer} component.
*
* @property children - The single or multiple buttons in the footer.
* @property requireScroll - Controls whether footer buttons require all content to be viewed before becoming active.
*/
export type FooterProps = {
children: ButtonElement | [ButtonElement, ButtonElement];
requireScroll?: boolean | undefined;
};

const TYPE = 'Footer';
Expand All @@ -16,13 +18,19 @@ const TYPE = 'Footer';
* A footer component, which is used to create a footer with buttons.
*
* @param props - The props of the component.
* @param props.requireScroll - Controls whether footer buttons require all content to be viewed before becoming active.
* The prop also activates an arrow that allows you to scroll to bottom.
* @param props.children - The single or multiple buttons in the footer.
* @returns A footer element.
* @example
* <Footer>
* <Button name="cancel">Cancel</Button>
* <Button name="confirm">Confirm</Button>
* </Footer>
* @example
* <Footer requireScroll>
* <Button name="accept">Accept</Button>
* </Footer>
*/
export const Footer = createSnapComponent<FooterProps, typeof TYPE>(TYPE);

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 @@ -656,6 +656,9 @@ describe('FooterStruct', () => {
<Footer>
<Button name="cancel">Cancel {true && 'foo'}</Button>
</Footer>,
<Footer requireScroll>
<Button name="accept">Accept</Button>
</Footer>,
])('validates a footer element', (value) => {
expect(is(value, FooterStruct)).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 @@ -671,6 +671,7 @@ export const FooterChildStruct = selectiveUnion((value) => {
*/
export const FooterStruct: Describe<FooterElement> = element('Footer', {
children: FooterChildStruct,
requireScroll: optional(boolean()),
hmalik88 marked this conversation as resolved.
Show resolved Hide resolved
});

/**
Expand Down
Loading