-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/stake-803-integrate-unstake-method-from…
…-sdk
- Loading branch information
Showing
36 changed files
with
1,995 additions
and
183 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
app/component-library/components/Pickers/PickerBase/PickerBase.stories.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,57 @@ | ||
/* eslint-disable react/display-name */ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
// External dependencies. | ||
import React from 'react'; | ||
import { View, Text } from 'react-native'; | ||
|
||
// Internal dependencies. | ||
import PickerBase from './PickerBase'; | ||
import { IconSize } from '../../Icons/Icon'; | ||
|
||
const PickerBaseMeta = { | ||
title: 'Component Library / Pickers', | ||
component: PickerBase, | ||
argTypes: { | ||
children: { | ||
control: { type: 'text' }, | ||
defaultValue: 'Select an option', | ||
}, | ||
iconSize: { | ||
options: Object.values(IconSize), | ||
control: { type: 'select' }, | ||
defaultValue: IconSize.Md, | ||
}, | ||
}, | ||
}; | ||
|
||
export default PickerBaseMeta; | ||
|
||
export const Default = { | ||
render: ({ | ||
children, | ||
iconSize, | ||
}: { | ||
children: string; | ||
iconSize: IconSize; | ||
}) => ( | ||
<View style={{ alignItems: 'flex-start' }}> | ||
<PickerBase onPress={() => null} iconSize={iconSize}> | ||
<Text>{children}</Text> | ||
</PickerBase> | ||
</View> | ||
), | ||
}; | ||
|
||
export const WithCustomStyles = { | ||
render: () => ( | ||
<View style={{ alignItems: 'flex-start' }}> | ||
<PickerBase | ||
onPress={() => null} | ||
style={{ width: 200 }} | ||
dropdownIconStyle={{ marginLeft: 20 }} | ||
> | ||
<Text>Custom Styled Picker</Text> | ||
</PickerBase> | ||
</View> | ||
), | ||
}; |
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
68 changes: 64 additions & 4 deletions
68
app/component-library/components/Pickers/PickerBase/PickerBase.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 |
---|---|---|
@@ -1,18 +1,78 @@ | ||
// Third party dependencies. | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import { render } from '@testing-library/react-native'; | ||
import { Text } from 'react-native'; | ||
import { render, fireEvent } from '@testing-library/react-native'; | ||
|
||
// Internal dependencies. | ||
import PickerBase from './PickerBase'; | ||
import { IconName, IconSize } from '../../Icons/Icon'; | ||
|
||
describe('PickerBase', () => { | ||
it('should render correctly', () => { | ||
const { toJSON } = render( | ||
<PickerBase onPress={jest.fn}> | ||
<View /> | ||
<PickerBase onPress={jest.fn()}> | ||
<Text>Test Content</Text> | ||
</PickerBase>, | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call onPress when pressed', () => { | ||
const onPressMock = jest.fn(); | ||
const { getByText } = render( | ||
<PickerBase onPress={onPressMock}> | ||
<Text>Test Content</Text> | ||
</PickerBase>, | ||
); | ||
|
||
fireEvent.press(getByText('Test Content')); | ||
expect(onPressMock).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should render children correctly', () => { | ||
const { getByText } = render( | ||
<PickerBase onPress={jest.fn()}> | ||
<Text>Child Component</Text> | ||
</PickerBase>, | ||
); | ||
|
||
expect(getByText('Child Component')).toBeTruthy(); | ||
}); | ||
|
||
it('should render dropdown icon', () => { | ||
const { UNSAFE_getByProps } = render( | ||
<PickerBase onPress={jest.fn()}> | ||
<Text>Test Content</Text> | ||
</PickerBase>, | ||
); | ||
|
||
const icon = UNSAFE_getByProps({ name: IconName.ArrowDown }); | ||
expect(icon).toBeTruthy(); | ||
}); | ||
|
||
it('should apply custom icon size', () => { | ||
const { UNSAFE_getByProps } = render( | ||
<PickerBase onPress={jest.fn()} iconSize={IconSize.Lg}> | ||
<Text>Test Content</Text> | ||
</PickerBase>, | ||
); | ||
|
||
const icon = UNSAFE_getByProps({ | ||
name: IconName.ArrowDown, | ||
size: IconSize.Lg, | ||
}); | ||
expect(icon).toBeTruthy(); | ||
}); | ||
|
||
it('should apply custom dropdown icon style', () => { | ||
const customStyle = { marginLeft: 20 }; | ||
const { UNSAFE_getByProps } = render( | ||
<PickerBase onPress={jest.fn()} dropdownIconStyle={customStyle}> | ||
<Text>Test Content</Text> | ||
</PickerBase>, | ||
); | ||
|
||
const icon = UNSAFE_getByProps({ name: IconName.ArrowDown }); | ||
expect(icon.props.style).toEqual(expect.objectContaining(customStyle)); | ||
}); | ||
}); |
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
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
57 changes: 57 additions & 0 deletions
57
app/component-library/components/Texts/SensitiveText/README.md
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,57 @@ | ||
# SensitiveText | ||
|
||
SensitiveText is a component that extends the Text component to handle sensitive information. It provides the ability to hide or show the text content, replacing it with dots when hidden. | ||
|
||
## Props | ||
|
||
This component extends all props from the [Text](../Text/README.md) component and adds the following: | ||
|
||
### `isHidden` | ||
|
||
Boolean to determine whether the text should be hidden or visible. | ||
|
||
| <span style="color:gray;font-size:14px">TYPE</span> | <span style="color:gray;font-size:14px">REQUIRED</span> | <span style="color:gray;font-size:14px">DEFAULT</span> | | ||
| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- | | ||
| boolean | Yes | false | | ||
|
||
### `length` | ||
|
||
Determines the length of the hidden text (number of dots). Can be a predefined SensitiveTextLength or a custom string number. | ||
|
||
| <span style="color:gray;font-size:14px">TYPE</span> | <span style="color:gray;font-size:14px">REQUIRED</span> | <span style="color:gray;font-size:14px">DEFAULT</span> | | ||
| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- | | ||
| [SensitiveTextLengthType](./SensitiveText.types.ts#L14) \| [CustomLength](./SensitiveText.types.ts#L19) | No | SensitiveTextLength.Short | | ||
|
||
### `children` | ||
|
||
The text content to be displayed or hidden. | ||
|
||
| <span style="color:gray;font-size:14px">TYPE</span> | <span style="color:gray;font-size:14px">REQUIRED</span> | <span style="color:gray;font-size:14px">DEFAULT</span> | | ||
| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- | | ||
| string | Yes | - | | ||
|
||
## Usage | ||
|
||
```javascript | ||
import SensitiveText from 'app/component-library/components/Texts/SensitiveText'; | ||
import { TextVariant } from 'app/component-library/components/Texts/Text'; | ||
import { SensitiveTextLength } from 'app/component-library/components/Texts/SensitiveText/SensitiveText.types'; | ||
|
||
<SensitiveText | ||
isHidden={true} | ||
length={SensitiveTextLength.Medium} | ||
variant={TextVariant.BodyMD} | ||
> | ||
Sensitive Information | ||
</SensitiveText> | ||
|
||
<SensitiveText | ||
isHidden={true} | ||
length="15" | ||
variant={TextVariant.BodyMD} | ||
> | ||
Custom Length Hidden Text | ||
</SensitiveText> | ||
``` | ||
|
||
This will render a Text component with dots instead of the actual text when `isHidden` is true, and the original text when `isHidden` is false. The number of asterisks is determined by the `length` prop. |
Oops, something went wrong.