Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CompactBrandTitle.tsx

71 lines2.1 KB

1import Constants from "expo-constants";
2import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
3import { Platform, View } from "react-native";
4​
5import { AppText as Text } from "./AppText";
6import { T3Wordmark } from "./T3Wordmark";
7import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
8import { resolveMobileStageLabel } from "../lib/mobileBranding";
9​
10/**
11 * Horizontal correction applied to content rendered in the brand title slot,
12 * shared with the connection-status swap so both align identically.
13 */
14export function brandTitleOffset(): number {
15 if (Platform.OS !== "ios") return 0;
16 return Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0;
18​
19/**
20 * Compact brand lockup sized for native navigation bars.
21 */
22export function CompactBrandTitle(
23 props: {
24 readonly allowFontScaling?: boolean;
25 } = {},
26) {
27 const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
28 const titleOffset = brandTitleOffset();
29​
30 return (
31 <View
32 aria-level={1}
33 accessibilityLabel="T3 Code, Threads"
34 accessible
35 role="heading"
36 className="flex-row items-center gap-1.5"
37 style={{ marginLeft: titleOffset }}
38 >
39 <T3Wordmark colorClassName="accent-icon" height={15} />
40 <Text
41 allowFontScaling={props.allowFontScaling}
42 className="font-t3-medium text-[21px] tracking-[-0.5px] text-foreground-muted"
43 >
44 Code
45 </Text>
46 <View className="rounded-full bg-subtle px-1.5 py-0.5">
47 <Text
48 allowFontScaling={props.allowFontScaling}
49 className="font-t3-bold text-[9px] tracking-[0.9px] text-foreground-muted uppercase"
50 >
51 {stageLabel}
52 </Text>
53 </View>
54 </View>
55 );
57​
58export function renderCompactBrandTitle() {
59 return <CompactBrandTitle allowFontScaling={Platform.OS === "ios"} />;
61​
62export function getCompactBrandHeaderOptions(
63 fallbackTitleStyle?: NativeStackNavigationOptions["headerTitleStyle"],
64): NativeStackNavigationOptions {
65 return {
66 headerTitle: renderCompactBrandTitle,
67 headerTitleStyle: fallbackTitleStyle,
68 title: "Threads",
69 unstable_headerLeftItems: undefined,
70 };