@dloizides/ui-nav 1.31.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ var navStyles = StyleSheet.create({
60
60
  },
61
61
  // --- Topbar ---
62
62
  topbarContainer: {
63
- height: 64,
63
+ minHeight: 64,
64
64
  paddingHorizontal: 12,
65
65
  borderBottomWidth: 1,
66
66
  flexDirection: "row",
@@ -81,7 +81,7 @@ var navStyles = StyleSheet.create({
81
81
  userBlock: { marginHorizontal: 12, alignItems: "flex-end", flexShrink: 1, minWidth: 0 },
82
82
  userName: { fontWeight: "600", maxWidth: "100%" },
83
83
  accountNameBtn: { flexShrink: 1, maxWidth: "100%", minHeight: MIN_TOUCH_TARGET, minWidth: MIN_TOUCH_TARGET, justifyContent: "center", alignItems: "flex-end" },
84
- userEmail: { fontSize: 12 },
84
+ userEmail: { fontSize: 12, maxWidth: "100%" },
85
85
  accountBtn: {
86
86
  marginLeft: 8,
87
87
  paddingHorizontal: 10,
@@ -932,7 +932,22 @@ var FocusableTouchable = ({
932
932
  }
933
933
  );
934
934
  };
935
+ var RAIL_FULL_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
936
+ var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
937
+ function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
938
+ if (!hasSidebar) return "none";
939
+ if (hasCollapsed) {
940
+ if (viewport >= range.max) return "full";
941
+ if (viewport >= range.min) return "collapsed";
942
+ return "drawer";
943
+ }
944
+ return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
945
+ }
935
946
  var TEXT_ON_PRIMARY = "#ffffff";
947
+ var ON_BRAND_SCALE = "onBrand";
948
+ var USER_BLOCK_COMPACT = { marginHorizontal: 4 };
949
+ var MAIN_STEP = "500";
950
+ var WRAP_ANYWHERE = Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
936
951
  function isAccountState(account) {
937
952
  return "displayName" in account;
938
953
  }
@@ -942,6 +957,14 @@ function planToneColor(theme, tone) {
942
957
  if (tone === "enterprise") return palette.accent?.["500"] ?? palette.primary["500"];
943
958
  return theme.colors.textSecondary;
944
959
  }
960
+ function onBrandInk(palette) {
961
+ const scales = palette;
962
+ return scales[ON_BRAND_SCALE]?.[MAIN_STEP] ?? TEXT_ON_PRIMARY;
963
+ }
964
+ function planBadgeInk(theme, tone) {
965
+ const fillIsPrimary = planToneColor(theme, tone) === theme.palette.primary["500"];
966
+ return fillIsPrimary ? onBrandInk(theme.palette) : TEXT_ON_PRIMARY;
967
+ }
945
968
  var Topbar = ({
946
969
  left,
947
970
  center,
@@ -955,6 +978,9 @@ var Topbar = ({
955
978
  const { theme } = useUi();
956
979
  const colors = theme.colors;
957
980
  const primaryColor = theme.palette.primary["500"];
981
+ const onPrimaryInk = onBrandInk(theme.palette);
982
+ const { width: viewportWidth } = useWindowDimensions();
983
+ const userBlockStyle = [navStyles.userBlock, viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null];
958
984
  const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
959
985
  const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
960
986
  const upgrade = richAccount?.upgrade;
@@ -983,11 +1009,11 @@ var Topbar = ({
983
1009
  }
984
1010
  ) : null,
985
1011
  renderTextSlot(notificationSlot, { color: colors.text }),
986
- user ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
987
- /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
988
- /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
1012
+ user ? /* @__PURE__ */ jsxs(View, { accessible: true, accessibilityLabel: `${user.name}, ${user.email}`, style: userBlockStyle, children: [
1013
+ /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, WRAP_ANYWHERE, { color: colors.text }], children: user.name }),
1014
+ /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, WRAP_ANYWHERE, { color: colors.textSecondary }], children: user.email })
989
1015
  ] }) : null,
990
- richAccount ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
1016
+ richAccount ? /* @__PURE__ */ jsxs(View, { style: userBlockStyle, children: [
991
1017
  richAccount.onAccount ? /* @__PURE__ */ jsx(
992
1018
  FocusableTouchable,
993
1019
  {
@@ -1013,7 +1039,7 @@ var Topbar = ({
1013
1039
  {
1014
1040
  style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
1015
1041
  testID: NAV_TEST_IDS.accountPlan,
1016
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: TEXT_ON_PRIMARY }], children: richAccount.plan.label })
1042
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
1017
1043
  }
1018
1044
  ) : null
1019
1045
  ] }) : null,
@@ -1026,7 +1052,7 @@ var Topbar = ({
1026
1052
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1027
1053
  testID: legacyAccount.testID,
1028
1054
  onPress: legacyAccount.onPress,
1029
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: legacyAccount.label })
1055
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: legacyAccount.label })
1030
1056
  }
1031
1057
  ) : null,
1032
1058
  upgrade ? /* @__PURE__ */ jsx(
@@ -1038,7 +1064,7 @@ var Topbar = ({
1038
1064
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1039
1065
  testID: upgrade.testID ?? NAV_TEST_IDS.accountUpgrade,
1040
1066
  onPress: upgrade.onPress,
1041
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: upgrade.label })
1067
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: upgrade.label })
1042
1068
  }
1043
1069
  ) : null,
1044
1070
  /* @__PURE__ */ jsx(
@@ -1050,7 +1076,7 @@ var Topbar = ({
1050
1076
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1051
1077
  testID: logout.testID,
1052
1078
  onPress: richAccount ? richAccount.onLogout : logout.onPress,
1053
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: logout.label })
1079
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
1054
1080
  }
1055
1081
  )
1056
1082
  ] })
@@ -1615,17 +1641,6 @@ var Nav = (props) => {
1615
1641
  }
1616
1642
  return /* @__PURE__ */ jsx(NavBar, { ...props });
1617
1643
  };
1618
- var RAIL_FULL_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
1619
- var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
1620
- function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
1621
- if (!hasSidebar) return "none";
1622
- if (hasCollapsed) {
1623
- if (viewport >= range.max) return "full";
1624
- if (viewport >= range.min) return "collapsed";
1625
- return "drawer";
1626
- }
1627
- return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
1628
- }
1629
1644
  var styles5 = StyleSheet.create({
1630
1645
  band: { left: 0, position: "absolute", right: 0, top: 0 }
1631
1646
  });