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 center prop to Box component #2716

Merged
merged 2 commits into from
Sep 12, 2024
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": "N8UDq+EKKrGSUr/xn+g8Fn0ebj34zd+6Urgv1S7pzuM=",
"shasum": "jBWYn37FTI6J3QI2ORlw36g4uXpIcBdH3n4o0CRdDvk=",
"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": "j2B/JJ/tTdTWMJo+c5S8vZpnt4pRk9Xp3MhYBmDaz1s=",
"shasum": "GKhf9ua3RUl21+DodL6sdx+DQFBkkdjVHMxHQy0GjGE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/snaps-sdk/src/jsx/components/Box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Box', () => {

it('renders a box with a conditional', () => {
const result = (
<Box direction="horizontal" alignment="space-between">
<Box direction="horizontal" alignment="space-between" center={true}>
{false && <Text>Hello</Text>}
</Box>
);
Expand All @@ -103,6 +103,7 @@ describe('Box', () => {
props: {
direction: 'horizontal',
alignment: 'space-between',
center: true,
children: false,
},
});
Expand Down
2 changes: 2 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createSnapComponent } from '../component';
* @property children - The children of the box.
* @property direction - The direction to stack the components within the box. Defaults to `vertical`.
* @property alignment - The alignment mode to use within the box. Defaults to `start`.
* @property center - Whether to center the children within the box. Defaults to `false`.
*/
export type BoxProps = {
// We can't use `JSXElement` because it causes a circular reference.
Expand All @@ -19,6 +20,7 @@ export type BoxProps = {
| 'space-between'
| 'space-around'
| undefined;
center?: boolean | undefined;
};

const TYPE = 'Box';
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 @@ -493,6 +493,7 @@ export const BoxStruct: Describe<BoxElement> = element('Box', {
literal('space-around'),
]),
),
center: optional(boolean()),
});

const FooterButtonStruct = refine(ButtonStruct, 'FooterButton', (value) => {
Expand Down
Loading