Repository navigation
Expand file tree
/
Copy pathProviderTutorial.tsx
More file actions
164 lines (160 loc) · 5.03 KB
/
Copy pathProviderTutorial.tsx
File metadata and controls
164 lines (160 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import {useState} from 'react';
import {
Modal,
Pressable,
ScrollView,
StyleSheet,
Text,
useWindowDimensions,
View,
} from 'react-native';
import {providerTutorial} from '../utils/providerTutorial';
type TutorialStep = (typeof providerTutorial)[number];
function Explanation({step}: {step: TutorialStep}) {
return (
<View style={styles.explanation}>
<Text style={styles.eyebrow}>
{step.number} · {step.title.toUpperCase()}
</Text>
<Text style={styles.heading}>{step.heading}</Text>
<Text style={styles.description}>{step.description}</Text>
<Text selectable style={styles.contract}>
{step.contract}
</Text>
<Text style={styles.source}>Read: {step.source}</Text>
</View>
);
}
export default function ProviderTutorial() {
const wide = useWindowDimensions().width >= 768;
const [selected, setSelected] = useState<TutorialStep>(providerTutorial[0]);
const [visible, setVisible] = useState(false);
return (
<View style={styles.section}>
<Text style={styles.sectionTitle}>How the pieces connect</Text>
<Text style={styles.hint}>
{wide
? 'Choose a layer to inspect its role.'
: 'Tap a layer for its role and source.'}
</Text>
<View style={[styles.layout, wide && styles.wideLayout]}>
<View style={[styles.menu, wide && styles.wideMenu]}>
{providerTutorial.map((step) => (
<Pressable
key={step.id}
accessibilityRole="button"
accessibilityLabel={`Learn about ${step.title}`}
accessibilityState={{selected: wide && selected.id === step.id}}
onPress={() => {
setSelected(step);
if (!wide) setVisible(true);
}}
style={({pressed}) => [
styles.menuItem,
wide && selected.id === step.id && styles.selected,
pressed && styles.pressed,
]}
>
<Text style={styles.number}>{step.number}</Text>
<Text style={styles.menuTitle}>{step.title}</Text>
<Text style={styles.affordance}>
{wide ? '›' : 'Learn more ↗'}
</Text>
</Pressable>
))}
</View>
{wide ? <Explanation step={selected} /> : null}
</View>
<Modal
visible={!wide && visible}
transparent
animationType="slide"
onRequestClose={() => setVisible(false)}
>
<View style={styles.overlay}>
<View style={styles.sheet} accessibilityViewIsModal>
<View style={styles.sheetHeader}>
<Text style={styles.sectionTitle}>Integration guide</Text>
<Pressable
accessibilityRole="button"
accessibilityLabel="Close integration guide"
hitSlop={8}
onPress={() => setVisible(false)}
style={styles.close}
>
<Text style={styles.closeText}>Close ✕</Text>
</Pressable>
</View>
<ScrollView>
<Explanation step={selected} />
</ScrollView>
</View>
</View>
</Modal>
</View>
);
}
const styles = StyleSheet.create({
section: {gap: 10},
sectionTitle: {color: '#0F172A', fontSize: 16, fontWeight: '700'},
hint: {color: '#64748B', fontSize: 12, lineHeight: 18},
layout: {gap: 12},
wideLayout: {flexDirection: 'row', alignItems: 'flex-start'},
menu: {flexDirection: 'row', gap: 9},
wideMenu: {width: 150, flexDirection: 'column'},
menuItem: {
flex: 1,
gap: 7,
minHeight: 86,
padding: 12,
backgroundColor: '#F1F5F9',
borderWidth: 1,
borderColor: '#DDE5EE',
borderRadius: 12,
},
selected: {borderColor: '#0F766E', backgroundColor: '#EFFAF7'},
pressed: {opacity: 0.7},
number: {fontSize: 10, color: '#64748B', fontWeight: '600'},
menuTitle: {fontSize: 13, color: '#334155', fontWeight: '600'},
affordance: {fontSize: 10, color: '#0F766E'},
explanation: {flex: 1, minWidth: 0, gap: 14, padding: 18},
eyebrow: {
color: '#0F766E',
fontSize: 11,
fontWeight: '700',
letterSpacing: 1,
},
heading: {color: '#0F172A', fontSize: 22, fontWeight: '700'},
description: {color: '#475569', fontSize: 14, lineHeight: 22},
contract: {
color: '#115E59',
fontSize: 12,
lineHeight: 20,
backgroundColor: '#EFFAF7',
padding: 14,
borderRadius: 10,
},
source: {color: '#64748B', fontSize: 12, lineHeight: 18},
overlay: {
flex: 1,
backgroundColor: 'rgba(15,23,42,0.45)',
justifyContent: 'flex-end',
padding: 12,
},
sheet: {
maxHeight: '85%',
backgroundColor: '#FFFFFF',
borderRadius: 22,
padding: 6,
paddingBottom: 20,
},
sheetHeader: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
padding: 14,
gap: 12,
},
close: {minHeight: 44, justifyContent: 'center', paddingHorizontal: 8},
closeText: {color: '#0F766E', fontWeight: '600', fontSize: 13},
});