-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ONE-3411] Merge react-native-components for wallet
- Loading branch information
1 parent
6b5de27
commit 8b72c8e
Showing
13 changed files
with
349 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { ComponentMeta, Story } from '@storybook/react'; | ||
import React, { useState } from 'react'; | ||
import { View } from 'react-native'; | ||
|
||
import { Button } from '../buttons'; | ||
import { Typography } from '../text'; | ||
import ActionModal from './ActionModal'; | ||
|
||
const Basic: Story = () => { | ||
const [visible, setVisible] = useState(false); | ||
return ( | ||
<> | ||
<Button title="Show modal" onPress={() => setVisible(true)} /> | ||
<ActionModal visible={visible}> | ||
<View> | ||
<Typography color={'white'}>Example text in modal</Typography> | ||
<Button title="Hide modal" onPress={() => setVisible(false)} /> | ||
</View> | ||
</ActionModal> | ||
</> | ||
); | ||
}; | ||
|
||
export { Basic as ActionModal }; | ||
|
||
export default { | ||
title: 'base/Action Modal', | ||
component: ActionModal, | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/Gd0Tj0234hxtl3HMcCJThW/App-Component-Library-(Design)?node-id=391-9097&t=WhKthlRU5MCuUWfw-0', | ||
}, | ||
}, | ||
} as ComponentMeta<typeof ActionModal>; |
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,45 @@ | ||
import React, { FunctionComponent, PropsWithChildren } from 'react'; | ||
import { Modal, StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; | ||
|
||
import { useAppColorScheme } from '../theme'; | ||
|
||
interface Props { | ||
contentStyle?: StyleProp<ViewStyle>; | ||
style?: StyleProp<ViewStyle>; | ||
visible: boolean; | ||
testID?: string; | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
background: { | ||
height: '100%', | ||
width: '100%', | ||
}, | ||
contentContainer: { | ||
borderTopLeftRadius: 20, | ||
borderTopRightRadius: 20, | ||
marginTop: 'auto', | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
const ActionModal: FunctionComponent<PropsWithChildren<Props>> = ({ | ||
children, | ||
contentStyle, | ||
style, | ||
visible, | ||
testID, | ||
}) => { | ||
const colorScheme = useAppColorScheme(); | ||
const overlay = 'rgba(0, 0, 0, 0.5)'; | ||
|
||
return ( | ||
<Modal animationType="fade" statusBarTranslucent style={style} transparent visible={visible}> | ||
<View testID={testID} style={[styles.background, { backgroundColor: overlay }]}> | ||
<View style={[styles.contentContainer, { backgroundColor: colorScheme.white }, contentStyle]}>{children}</View> | ||
</View> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ActionModal; |
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,3 @@ | ||
import ActionModal from './ActionModal'; | ||
|
||
export { ActionModal }; |
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,80 @@ | ||
import React, { FunctionComponent, useMemo } from 'react'; | ||
import { StyleSheet, useWindowDimensions } from 'react-native'; | ||
import Svg, { Defs, LinearGradient, Rect, Stop, SvgProps } from 'react-native-svg'; | ||
|
||
import { colorArray } from '../utils/color'; | ||
|
||
export interface GradientBackgroundProps extends SvgProps { | ||
/** | ||
* Custom boundary colors | ||
* default: colorScheme.linearGradient | ||
*/ | ||
colors?: readonly [string, string]; | ||
/** | ||
* Gradient color change direction | ||
* default: `undefined` (for background) | ||
*/ | ||
direction?: 'horizontal' | 'vertical'; | ||
/** | ||
* Flag for disabling absolute fill | ||
* default: `true` | ||
*/ | ||
absoluteFill?: boolean; | ||
} | ||
|
||
const linearGradient = ['rgba(255, 255, 255, 1)', 'rgba(255, 255, 255, 0)']; | ||
|
||
const GradientBackground: FunctionComponent<GradientBackgroundProps> = ({ | ||
style, | ||
colors, | ||
direction, | ||
absoluteFill = true, | ||
...props | ||
}) => { | ||
const sceenDimensions = useWindowDimensions(); | ||
|
||
const width = props.width ?? sceenDimensions.width; | ||
const height = props.height ?? sceenDimensions.height; | ||
|
||
const svgColors = useMemo( | ||
() => | ||
(colors ?? linearGradient).map(colorArray).map(([r, g, b, a]) => ({ | ||
stopColor: `rgb(${r * 255},${g * 255},${b * 255})`, | ||
stopOpacity: a, | ||
})), | ||
[colors], | ||
); | ||
|
||
let gradientDirectionProps; | ||
switch (direction) { | ||
case 'vertical': | ||
gradientDirectionProps = { | ||
gradientTransform: 'rotate(90)', | ||
}; | ||
break; | ||
case 'horizontal': | ||
gradientDirectionProps = {}; | ||
break; | ||
default: | ||
gradientDirectionProps = { x1: 0, y1: 0, x2: 0, y2: 1 }; | ||
break; | ||
} | ||
return ( | ||
<Svg | ||
accessible={false} | ||
width={width} | ||
height={height} | ||
style={[absoluteFill ? StyleSheet.absoluteFill : undefined, style]} | ||
{...props}> | ||
<Defs> | ||
<LinearGradient id="grad" {...gradientDirectionProps}> | ||
<Stop offset={0} {...svgColors[0]} /> | ||
<Stop offset={1} {...svgColors[1]} /> | ||
</LinearGradient> | ||
</Defs> | ||
<Rect x={0} y={0} width={width} height={height} fill="url(#grad)" /> | ||
</Svg> | ||
); | ||
}; | ||
|
||
export default GradientBackground; |
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,3 @@ | ||
import GradientBackground from './gradient-background'; | ||
|
||
export { GradientBackground }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ComponentMeta, Story } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import ErrorScreen, { ErrorScreenProps, ErrorScreenVariation } from './error-screen'; | ||
|
||
const Basic: Story<ErrorScreenProps> = (props) => <ErrorScreen {...props} />; | ||
|
||
Basic.args = { | ||
title: 'Error', | ||
subtitle: 'The app has reached an error state.', | ||
variation: ErrorScreenVariation.Neutral, | ||
buttons: [ | ||
{ label: 'Primary', onPress: () => null }, | ||
{ label: 'Secondary', onPress: () => null }, | ||
], | ||
}; | ||
|
||
export { Basic as ErrorScreen }; | ||
|
||
export default { | ||
title: 'view/loading/Error Screen', | ||
component: ErrorScreen, | ||
parameters: { | ||
noSafeArea: true, | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/baolhE7fB2BMdCN5RVjusX/App-Feature-Library?node-id=782%3A31982&t=EX6zyqvONranvehN-4', | ||
}, | ||
}, | ||
argTypes: { | ||
variation: { | ||
options: [ErrorScreenVariation.Neutral, ErrorScreenVariation.Accent], | ||
control: { type: 'radio' }, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof ErrorScreen>; |
Oops, something went wrong.