Skip to content

Commit c2cb9bc

Browse files
committed
Add backgroundColor property to Container component
Minor refactoring Update manifest shasum Update manifest shasum Revert Box changes
1 parent 6861362 commit c2cb9bc

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Text } from './Text';
77
describe('Container', () => {
88
it('renders a container element with a box', () => {
99
const result = (
10-
<Container>
10+
<Container backgroundColor="alternative">
1111
<Box>
1212
<Text>Hello world!</Text>
1313
</Box>
@@ -18,6 +18,7 @@ describe('Container', () => {
1818
type: 'Container',
1919
key: null,
2020
props: {
21+
backgroundColor: 'alternative',
2122
children: {
2223
type: 'Box',
2324
key: null,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import type { GenericSnapElement } from '../component';
22
import { createSnapComponent } from '../component';
33
import type { FooterElement } from './Footer';
44

5+
/**
6+
* Definition of container background colors.
7+
*/
8+
export type ContainerBackgroundColor = 'default' | 'alternative';
9+
510
/**
611
* The props of the {@link Container} component.
712
*
813
* @property children - The Box and the Footer or the Box element.
914
*/
1015
export type ContainerProps = {
1116
children: [GenericSnapElement, FooterElement] | GenericSnapElement;
17+
backgroundColor?: ContainerBackgroundColor | undefined;
1218
};
1319

1420
const TYPE = 'Container';
@@ -17,10 +23,11 @@ const TYPE = 'Container';
1723
* A container component, which is used to create a container with a box and a footer.
1824
*
1925
* @param props - The props of the component.
26+
* @param props.backgroundColor - The color of the background.
2027
* @param props.children - The Box and the Footer or the Box element.
2128
* @returns A container element.
2229
* @example
23-
* <Container>
30+
* <Container backgroundColor="default">
2431
* <Box>
2532
* <Text>Hello world!</Text>
2633
* </Box>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ describe('ContainerStruct', () => {
759759
<Container>
760760
<Text>Hello world!</Text>
761761
</Container>,
762+
<Container backgroundColor="default">
763+
<Text>Hello world!</Text>
764+
</Container>,
765+
<Container backgroundColor="alternative">
766+
<Text>Hello world!</Text>
767+
</Container>,
762768
<Container>
763769
<Text>Hello world!</Text>
764770
<Footer>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ export const ContainerStruct: Describe<ContainerElement> = element(
877877
[GenericSnapElement, FooterElement] | GenericSnapElement,
878878
null
879879
>,
880+
backgroundColor: optional(
881+
nullUnion([literal('default'), literal('alternative')]),
882+
),
880883
},
881884
);
882885

0 commit comments

Comments
 (0)