File tree Expand file tree Collapse file tree
packages/docs-gesture-handler/src/components/HeaderWithBadge Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { StyleSheet } from 'react-native' ;
2+
3+ interface HeaderWithBadgeProps {
4+ platforms : ( 'android' | 'ios' | 'web' ) [ ] ;
5+ children ?: React . ReactNode ;
6+ }
7+
8+ export function Badge ( { platform } : { platform : 'android' | 'ios' | 'web' } ) {
9+ const platformBadge =
10+ platform === 'android'
11+ ? styles . androidBadge
12+ : platform === 'ios'
13+ ? styles . iosBadge
14+ : platform === 'web'
15+ ? styles . webBadge
16+ : { } ;
17+
18+ return < div style = { { ...styles . badge , ...platformBadge } } > { platform } </ div > ;
19+ }
20+
21+ export default function HeaderWithBadge ( {
22+ platforms,
23+ children,
24+ } : HeaderWithBadgeProps ) {
25+ return (
26+ < div style = { styles . container } >
27+ { children }
28+
29+ { platforms . map ( ( platform ) => (
30+ < Badge key = { platform } platform = { platform } />
31+ ) ) }
32+ </ div >
33+ ) ;
34+ }
35+
36+ const styles = StyleSheet . create ( {
37+ container : {
38+ display : 'flex' ,
39+ flexDirection : 'row' ,
40+ gap : 10 ,
41+ marginBottom : 20 ,
42+ } ,
43+
44+ badge : {
45+ borderRadius : 10 ,
46+ paddingTop : 2 ,
47+ paddingBottom : 2 ,
48+ paddingLeft : 10 ,
49+ paddingRight : 10 ,
50+ color : 'white' ,
51+
52+ display : 'flex' ,
53+ alignItems : 'center' ,
54+ justifyContent : 'space-around' ,
55+ } ,
56+
57+ androidBadge : {
58+ backgroundColor : '#0f8142' ,
59+ } ,
60+
61+ iosBadge : {
62+ backgroundColor : '#000000' ,
63+ } ,
64+
65+ webBadge : {
66+ backgroundColor : '#1067c4' ,
67+ } ,
68+ } ) ;
You can’t perform that action at this time.
0 commit comments