Skip to content

Commit 7c26c26

Browse files
authored
feat: Add crossAlignment to Box (#3115)
This PR adds a new prop to `Box` called `crossAlignment` which should bind to `align-items`. Fixes: #3114
1 parent a0e023a commit 7c26c26

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

packages/examples/packages/browserify-plugin/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snaps.git"
88
},
99
"source": {
10-
"shasum": "t/mItLdi/miIU7FWJjijmmaFT/5svN1dK4Ik+1LMbqw=",
10+
"shasum": "d0Rvxg6jxAfVxcrMdk2xdJOL7oDh74YKzhvRD2/Gs/s=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/examples/packages/browserify/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snaps.git"
88
},
99
"source": {
10-
"shasum": "3kC/z0z6RjjarArtxcs+iltJRQgvZNIPBueMP0cLQJw=",
10+
"shasum": "Oy5sCDh6f5WVjosPyzy5U70omD4/SI1WHwOBSmH6Zr8=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/snaps-sdk/src/jsx/components/Box.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ describe('Box', () => {
5858

5959
it('renders a box with props', () => {
6060
const result = (
61-
<Box direction="horizontal" alignment="space-between">
61+
<Box
62+
direction="horizontal"
63+
alignment="space-between"
64+
crossAlignment="center"
65+
>
6266
<Text>Hello</Text>
6367
<Text>World</Text>
6468
</Box>
@@ -70,6 +74,7 @@ describe('Box', () => {
7074
props: {
7175
direction: 'horizontal',
7276
alignment: 'space-between',
77+
crossAlignment: 'center',
7378
children: [
7479
{
7580
type: 'Text',

packages/snaps-sdk/src/jsx/components/Box.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createSnapComponent } from '../component';
77
* @property children - The children of the box.
88
* @property direction - The direction to stack the components within the box. Defaults to `vertical`.
99
* @property alignment - The alignment mode to use within the box. Defaults to `start`.
10+
* @property crossAlignment - The cross alignment mode to use within the box. Defaults to `start`.
1011
* @property center - Whether to center the children within the box. Defaults to `false`.
1112
*/
1213
export type BoxProps = {
@@ -20,6 +21,7 @@ export type BoxProps = {
2021
| 'space-between'
2122
| 'space-around'
2223
| undefined;
24+
crossAlignment?: 'start' | 'center' | 'end';
2325
center?: boolean | undefined;
2426
};
2527

packages/snaps-sdk/src/jsx/validation.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ describe('BoxStruct', () => {
589589
<Image src="<svg />" alt="alt" />
590590
</Row>
591591
</Box>,
592-
<Box direction="horizontal" alignment="space-between">
592+
<Box direction="horizontal" alignment="space-between" crossAlignment="end">
593593
<Text>foo</Text>
594594
<Row label="label">
595595
<Image src="<svg />" alt="alt" />
@@ -636,6 +636,10 @@ describe('BoxStruct', () => {
636636
<Image src="<svg />" alt="alt" />
637637
</Row>
638638
</Box>,
639+
// @ts-expect-error - Invalid props.
640+
<Box crossAlignment="bar">
641+
<Text>foo</Text>
642+
</Box>,
639643
<Box>
640644
<Value extra="foo" value="bar" />
641645
</Box>,

packages/snaps-sdk/src/jsx/validation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ export const BoxStruct: Describe<BoxElement> = element('Box', {
596596
literal('space-around'),
597597
]),
598598
),
599+
crossAlignment: optional(
600+
nullUnion([literal('start'), literal('center'), literal('end')]),
601+
),
599602
center: optional(boolean()),
600603
});
601604

0 commit comments

Comments
 (0)