Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion packages/snaps-sdk/src/jsx/components/Box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ describe('Box', () => {

it('renders a box with props', () => {
const result = (
<Box direction="horizontal" alignment="space-between">
<Box
direction="horizontal"
alignment="space-between"
crossAlignment="center"
>
<Text>Hello</Text>
<Text>World</Text>
</Box>
Expand All @@ -70,6 +74,7 @@ describe('Box', () => {
props: {
direction: 'horizontal',
alignment: 'space-between',
crossAlignment: 'center',
children: [
{
type: 'Text',
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 crossAlignment - The cross 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 = {
Expand All @@ -20,6 +21,7 @@ export type BoxProps = {
| 'space-between'
| 'space-around'
| undefined;
crossAlignment?: 'start' | 'center' | 'end';
center?: boolean | undefined;
};

Expand Down
6 changes: 5 additions & 1 deletion packages/snaps-sdk/src/jsx/validation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ describe('BoxStruct', () => {
<Image src="<svg />" alt="alt" />
</Row>
</Box>,
<Box direction="horizontal" alignment="space-between">
<Box direction="horizontal" alignment="space-between" crossAlignment="end">
<Text>foo</Text>
<Row label="label">
<Image src="<svg />" alt="alt" />
Expand Down Expand Up @@ -636,6 +636,10 @@ describe('BoxStruct', () => {
<Image src="<svg />" alt="alt" />
</Row>
</Box>,
// @ts-expect-error - Invalid props.
<Box crossAlignment="bar">
<Text>foo</Text>
</Box>,
<Box>
<Value extra="foo" value="bar" />
</Box>,
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ export const BoxStruct: Describe<BoxElement> = element('Box', {
literal('space-around'),
]),
),
crossAlignment: optional(
nullUnion([literal('start'), literal('center'), literal('end')]),
),
center: optional(boolean()),
});

Expand Down
Loading