Skip to content

Commit

Permalink
add optional props to center children in box
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Sep 12, 2024
1 parent dfaea71 commit 1274285
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
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 @@ -471,6 +471,7 @@ export const BoxStruct: Describe<BoxElement> = element('Box', {
literal('space-around'),
]),
),
center: optional(boolean()),
});

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

0 comments on commit 1274285

Please sign in to comment.