-
-
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 STAKE-897-fe-add-earn-button-to-main-wallet-…
…actions
- Loading branch information
Showing
91 changed files
with
3,093 additions
and
397 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
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
49 changes: 49 additions & 0 deletions
49
app/component-library/components-temp/Buttons/ButtonPill/ButtonPill.styles.ts
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,49 @@ | ||
// Third party dependencies. | ||
import { StyleSheet } from 'react-native'; | ||
|
||
// External dependencies. | ||
import { Theme } from '../../../../util/theme/models'; | ||
|
||
/** | ||
* Style sheet input parameters. | ||
*/ | ||
export interface ButtonPillStyleSheetVars { | ||
isDisabled: boolean; | ||
isPressed: boolean; | ||
} | ||
|
||
/** | ||
* Style sheet function for ButtonPill component | ||
* | ||
* @param params Style sheet params | ||
* @param params.theme Theme object | ||
* @param params.vars Arbitrary inputs this style sheet depends on | ||
* @returns StyleSheet object | ||
*/ | ||
const styleSheet = (params: { | ||
theme: Theme; | ||
vars: ButtonPillStyleSheetVars; | ||
}) => { | ||
const { | ||
theme: { colors }, | ||
vars: { isDisabled, isPressed } | ||
} = params; | ||
|
||
return StyleSheet.create({ | ||
base: { | ||
backgroundColor: colors.background.alternative, | ||
color: colors.text.default, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
paddingHorizontal: 8, | ||
paddingVertical: 4, | ||
borderRadius: 99, | ||
opacity: isDisabled ? 0.5 : 1, | ||
...(isPressed && { | ||
backgroundColor: colors.background.alternativePressed, | ||
}), | ||
}, | ||
}); | ||
}; | ||
|
||
export default styleSheet; |
15 changes: 15 additions & 0 deletions
15
app/component-library/components-temp/Buttons/ButtonPill/ButtonPill.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,15 @@ | ||
// Third party dependencies. | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
|
||
// Internal dependencies. | ||
import ButtonPill from './ButtonPill'; | ||
|
||
describe('ButtonPill', () => { | ||
it('should render correctly', () => { | ||
const { toJSON } = render( | ||
<ButtonPill onPress={jest.fn} />, | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
app/component-library/components-temp/Buttons/ButtonPill/ButtonPill.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,69 @@ | ||
// Third party dependencies. | ||
import React, { useCallback, useState } from 'react'; | ||
import { GestureResponderEvent, TouchableOpacity, TouchableOpacityProps } from 'react-native'; | ||
|
||
// External dependencies. | ||
import { useStyles } from '../../../hooks'; | ||
|
||
// Internal dependencies. | ||
import stylesheet from './ButtonPill.styles'; | ||
|
||
/** | ||
* ButtonPill component props. | ||
*/ | ||
export interface ButtonPillProps extends TouchableOpacityProps { | ||
/** | ||
* Optional param to disable the button. | ||
*/ | ||
isDisabled?: boolean; | ||
} | ||
|
||
const ButtonPill = ({ | ||
onPress, | ||
onPressIn, | ||
onPressOut, | ||
style, | ||
isDisabled = false, | ||
children, | ||
...props | ||
}: ButtonPillProps) => { | ||
const [isPressed, setIsPressed] = useState(false); | ||
const { styles } = useStyles(stylesheet, { | ||
style, | ||
isPressed, | ||
isDisabled, | ||
}); | ||
|
||
const triggerOnPressedIn = useCallback( | ||
(e: GestureResponderEvent) => { | ||
setIsPressed(true); | ||
onPressIn?.(e); | ||
}, | ||
[setIsPressed, onPressIn], | ||
); | ||
|
||
const triggerOnPressedOut = useCallback( | ||
(e: GestureResponderEvent) => { | ||
setIsPressed(false); | ||
onPressOut?.(e); | ||
}, | ||
[setIsPressed, onPressOut], | ||
); | ||
|
||
return ( | ||
<TouchableOpacity | ||
style={styles.base} | ||
onPress={!isDisabled ? onPress : undefined} | ||
onPressIn={!isDisabled ? triggerOnPressedIn : undefined} | ||
onPressOut={!isDisabled ? triggerOnPressedOut : undefined} | ||
accessible | ||
activeOpacity={1} | ||
disabled={isDisabled} | ||
{...props} | ||
> | ||
{children} | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default ButtonPill; |
24 changes: 24 additions & 0 deletions
24
...mponent-library/components-temp/Buttons/ButtonPill/__snapshots__/ButtonPill.test.tsx.snap
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,24 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ButtonPill should render correctly 1`] = ` | ||
<TouchableOpacity | ||
accessible={true} | ||
activeOpacity={1} | ||
disabled={false} | ||
onPress={[Function]} | ||
onPressIn={[Function]} | ||
onPressOut={[Function]} | ||
style={ | ||
{ | ||
"alignItems": "center", | ||
"backgroundColor": "#f2f4f6", | ||
"borderRadius": 99, | ||
"color": "#141618", | ||
"justifyContent": "center", | ||
"opacity": 1, | ||
"paddingHorizontal": 8, | ||
"paddingVertical": 4, | ||
} | ||
} | ||
/> | ||
`; |
1 change: 1 addition & 0 deletions
1
app/component-library/components-temp/Buttons/ButtonPill/index.ts
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 @@ | ||
export { default } from './ButtonPill'; |
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
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
Oops, something went wrong.