-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Artur Bien
committed
Jan 17, 2021
1 parent
da690c8
commit 70d0aae
Showing
7 changed files
with
108 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { Label } from 'react95-native'; | ||
|
||
import Container from '../util/Container'; | ||
|
||
const PanelExample = () => { | ||
return ( | ||
<Container> | ||
<Label elevation={0}>No elevation</Label> | ||
<Label elevation={6} style={{ marginTop: 16 }} onPress={() => {}}> | ||
High elevation | ||
</Label> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default PanelExample; |
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,77 @@ | ||
import React from 'react'; | ||
import { | ||
StyleProp, | ||
StyleSheet, | ||
Animated, | ||
View, | ||
ViewStyle, | ||
TouchableWithoutFeedback, | ||
} from 'react-native'; | ||
|
||
import { withTheme } from '../../core/theming'; | ||
import shadow from '../../styles/shadow'; | ||
import type { Theme } from '../../types'; | ||
|
||
import { Text } from '../..'; | ||
|
||
type Props = React.ComponentPropsWithRef<typeof View> & { | ||
accessible?: boolean; | ||
children?: React.ReactNode; | ||
elevation?: number; | ||
onLongPress?: () => void; | ||
onPress?: () => void; | ||
radius?: number; | ||
style?: StyleProp<ViewStyle>; | ||
theme: Theme; | ||
}; | ||
|
||
const Label = ({ | ||
accessible, | ||
children, | ||
elevation = 0, | ||
onLongPress, | ||
onPress, | ||
radius = 4, | ||
style = {}, | ||
theme, | ||
...rest | ||
}: Props) => { | ||
return ( | ||
// TODO: fix this TS error | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
<Animated.View | ||
{...rest} | ||
style={[ | ||
styles.container, | ||
{ | ||
backgroundColor: theme.tooltip, | ||
borderRadius: radius, | ||
}, | ||
shadow(elevation), | ||
style, | ||
]} | ||
> | ||
<TouchableWithoutFeedback | ||
delayPressIn={0} | ||
disabled={!(onPress || onLongPress)} | ||
onLongPress={onLongPress} | ||
onPress={onPress} | ||
accessible={accessible} | ||
> | ||
<Text>{children}</Text> | ||
</TouchableWithoutFeedback> | ||
</Animated.View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
position: 'relative', | ||
borderWidth: 2, | ||
paddingHorizontal: 12, | ||
paddingVertical: 6, | ||
}, | ||
}); | ||
|
||
export default withTheme(Label); |
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 './Label'; |
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