From 2c94e708eb8f6136d0f0c6f7f2107e06bd01efc5 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 3 Jul 2024 14:46:04 +0200 Subject: [PATCH] Add footer component --- .../src/jsx/components/Footer.stories.tsx | 48 ++++++++ .../snaps-storybook/src/components/Header.tsx | 9 +- .../src/components/Renderer.tsx | 94 ++++++++++++--- .../src/components/custom/Extension.tsx | 43 ++++--- .../src/components/custom/utils.ts | 114 ++++++++++++++++++ .../src/components/snaps/box/Box.tsx | 4 +- .../components/snaps/button/Button.styles.tsx | 26 ++++ .../src/components/snaps/footer/Footer.tsx | 31 +++++ .../snaps/footer/components/Button.tsx | 30 +++++ .../snaps/footer/components/Buttons.tsx | 31 +++++ .../snaps/footer/components/CancelButton.tsx | 20 +++ .../snaps/footer/components/index.ts | 3 + .../src/components/snaps/footer/index.ts | 1 + .../src/components/snaps/heading/Heading.tsx | 4 +- .../src/components/snaps/index.ts | 2 + .../src/components/snaps/row/Row.tsx | 4 +- .../src/components/snaps/text/Text.tsx | 4 +- packages/snaps-storybook/src/render.tsx | 7 +- packages/snaps-storybook/src/theme/index.ts | 13 +- packages/snaps-storybook/src/theme/shadows.ts | 3 + packages/snaps-storybook/src/theme/utils.ts | 35 ++++++ 21 files changed, 472 insertions(+), 54 deletions(-) create mode 100644 packages/snaps-sdk/src/jsx/components/Footer.stories.tsx create mode 100644 packages/snaps-storybook/src/components/custom/utils.ts create mode 100644 packages/snaps-storybook/src/components/snaps/footer/Footer.tsx create mode 100644 packages/snaps-storybook/src/components/snaps/footer/components/Button.tsx create mode 100644 packages/snaps-storybook/src/components/snaps/footer/components/Buttons.tsx create mode 100644 packages/snaps-storybook/src/components/snaps/footer/components/CancelButton.tsx create mode 100644 packages/snaps-storybook/src/components/snaps/footer/components/index.ts create mode 100644 packages/snaps-storybook/src/components/snaps/footer/index.ts create mode 100644 packages/snaps-storybook/src/theme/shadows.ts diff --git a/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx b/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx new file mode 100644 index 0000000000..85388ecd4a --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx @@ -0,0 +1,48 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { FooterProps } from './Footer'; +import { Footer } from './Footer'; +import { Button } from './form'; + +const meta: Meta = { + title: 'Footer', + component: Footer, + argTypes: { + children: { + description: + 'The button(s) to render in the footer. If only one button is provided, a cancel button is added automatically.', + table: { + type: { + summary: 'Button | [Button, Button]', + }, + }, + }, + }, +}; + +export default meta; + +/** + * The footer component one custom button. A cancel button is added + * automatically if only one button is provided. + * + * When the user clicks the first button, the `onUserInput` handler is called + * with the name of the button (if provided). + */ +export const Default: Story = { + render: (props) =>