-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea4b4e4
commit 21dac9d
Showing
5 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/snaps-sdk/src/jsx/components/SettingCell.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Input } from './form'; | ||
import { SettingCell } from './SettingCell'; | ||
|
||
describe('SettingCell', () => { | ||
it('renders a setting cell', () => { | ||
const result = ( | ||
<SettingCell title="Title" description="Description"> | ||
<Input name="setting1" /> | ||
</SettingCell> | ||
); | ||
|
||
expect(result).toStrictEqual({ | ||
type: 'SettingCell', | ||
key: null, | ||
props: { | ||
title: 'Title', | ||
description: 'Description', | ||
children: { | ||
type: 'Input', | ||
key: null, | ||
props: { | ||
name: 'setting1', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
createSnapComponent, | ||
type GenericSnapElement, | ||
type SnapsChildren, | ||
} from '../component'; | ||
|
||
/** | ||
* The props of the {@link SettingCell} component. | ||
* | ||
* @property title - The title. | ||
* @property description - The description. | ||
* @property children - The children to show within the cell. | ||
*/ | ||
export type SettingCellProps = { | ||
title: string; | ||
description: string; | ||
children: SnapsChildren<GenericSnapElement>; | ||
}; | ||
|
||
const TYPE = 'SettingCell'; | ||
|
||
/** | ||
* A setting cell component which can be used to display a setting control. | ||
* | ||
* @param props - The props of the component. | ||
* @param props.title - The title. | ||
* @param props.description - The description. | ||
* @param props.children - The children to show within the cell. | ||
* @returns A setting cell element. | ||
* @example | ||
* <SettingCell title="Title" description="Description"> | ||
* <Input name="setting1" /> | ||
* </SettingCell> | ||
*/ | ||
export const SettingCell = createSnapComponent<SettingCellProps, typeof TYPE>( | ||
TYPE, | ||
); | ||
|
||
/** | ||
* A setting cell element. | ||
* | ||
* @see SettingCell | ||
*/ | ||
export type SettingCellElement = ReturnType<typeof SettingCell>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters