| 1 | import { Pressable, View } from "react-native"; |
| 2 | |
| 3 | import { AppText } from "../../components/AppText"; |
| 4 | import { SymbolView } from "../../components/AppSymbol"; |
| 5 | |
| 6 | /** Opens the thread's server-hosted browser tabs. Sits beside the device preview button. */ |
| 7 | export function BrowserPreviewButton(props: { |
| 8 | readonly count: number; |
| 9 | readonly onPress: () => void; |
| 10 | readonly compact?: boolean; |
| 11 | }) { |
| 12 | const compact = props.compact ?? true; |
| 13 | return ( |
| 14 | <Pressable |
| 15 | accessibilityRole="button" |
| 16 | accessibilityLabel={props.count === 1 ? "View browser" : `View ${props.count} browser tabs`} |
| 17 | accessibilityHint="Watch and control browser tabs open in this thread" |
| 18 | onPress={props.onPress} |
| 19 | className={ |
| 20 | compact |
| 21 | ? "size-11 shrink-0 items-center justify-center rounded-full active:bg-subtle" |
| 22 | : "h-11 shrink-0 flex-row items-center justify-center gap-2 rounded-full px-4 active:bg-subtle" |
| 23 | } |
| 24 | > |
| 25 | <SymbolView name="globe" size={20} tintColorClassName="accent-icon" type="monochrome" /> |
| 26 | {!compact ? ( |
| 27 | <AppText className="font-t3-medium text-xs text-foreground"> |
| 28 | {props.count === 1 ? "One tab open" : `${props.count} tabs open`} |
| 29 | </AppText> |
| 30 | ) : props.count > 1 ? ( |
| 31 | <View className="absolute right-1.5 top-1.5 min-w-4 items-center rounded-full bg-primary px-1"> |
| 32 | <AppText className="text-2xs font-t3-bold text-primary-foreground">{props.count}</AppText> |
| 33 | </View> |
| 34 | ) : null} |
| 35 | </Pressable> |
| 36 | ); |
| 37 | } |