@vvedantb/native-ui 0.3.16 → 0.3.17
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/README.md +1 -1
- package/package.json +1 -1
- package/src/FloatingTabBar.tsx +8 -7
- package/src/controlStyles.ts +16 -0
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ To hide a tab, give its screen Expo Router's `href: null`. From 0.3.9 `FloatingT
|
|
|
50
50
|
</Tabs>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
From 0.3.16 the focused tab sits on a rounded pill
|
|
53
|
+
From 0.3.16 the focused tab sits on a rounded pill with the `TabsTrigger` pills outline, with the foreground label and icon; the other tabs are muted. From 0.3.17 the pill fill is `floatingTabPillColors(scheme)`: the muted `palette.default` (`--default`, `#ebebeb`) in light, so it shows on the near-white glass bar, and `palette.segment` (`--segment`, `#474747`) in dark. On the web the `--segment` pill sits on a `--default` track; here the bar is the raised surface, so the light pill takes the track fill. A route's `tabBarActiveTintColor` and `tabBarInactiveTintColor` still override the label and icon colours. The pill is one tab wide, inset 4 from the bar on every side, and slides to a newly focused tab over the web `--tabs-dur` (200 ms) and `--tabs-ease`. It counts only the tabs drawn, and there is none while a hidden route is focused.
|
|
54
54
|
|
|
55
55
|
## Entry points
|
|
56
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar and the family app marks.",
|
|
6
6
|
"type": "module",
|
package/src/FloatingTabBar.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import Animated, {
|
|
|
7
7
|
withTiming,
|
|
8
8
|
} from "react-native-reanimated";
|
|
9
9
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
|
-
import { tabColors, typeStyle } from "./controlStyles";
|
|
10
|
+
import { floatingTabPillColors, tabColors, typeStyle } from "./controlStyles";
|
|
11
11
|
import { selectionHaptic } from "./haptics";
|
|
12
12
|
import { FloatingSurface } from "./FloatingSurface";
|
|
13
13
|
import { isTabBarRouteVisible, type FloatingTabOptions } from "./tabBarRoutes";
|
|
@@ -53,8 +53,8 @@ export type FloatingTabBarProps = {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* The floating pill tab bar, for the `tabBar` prop of Expo Router's `Tabs`.
|
|
56
|
-
* The focused tab sits on a pill
|
|
57
|
-
*
|
|
56
|
+
* The focused tab sits on a pill (`floatingTabPillColors`), with the
|
|
57
|
+
* foreground label; the others are muted. A route's
|
|
58
58
|
* `tabBarActiveTintColor` and `tabBarInactiveTintColor` override the label
|
|
59
59
|
* and icon colours. Hide a tab with `options={{ href: null }}` on its
|
|
60
60
|
* `Tabs.Screen`: the bar draws no tab for it (`isTabBarRouteVisible`), and
|
|
@@ -170,9 +170,10 @@ export function FloatingTabBar({
|
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* The pill behind tab `index` of `count` drawn tabs: one tab wide (they share
|
|
173
|
-
* the row equally), `TAB_BAR_PADDING` inside the bar, in
|
|
174
|
-
*
|
|
175
|
-
*
|
|
173
|
+
* the row equally), `TAB_BAR_PADDING` inside the bar, in
|
|
174
|
+
* `floatingTabPillColors` (the muted `--default` in light, `--segment` in
|
|
175
|
+
* dark, so it shows on the glass bar) and the `TabsTrigger` pills outline.
|
|
176
|
+
* It slides to a newly focused tab, as the web segmented pill does,
|
|
176
177
|
* and moves at once with Reduce Motion. Behind the tablist, so assistive tech
|
|
177
178
|
* reads only the tabs.
|
|
178
179
|
*/
|
|
@@ -210,7 +211,7 @@ function ActiveTabPill({ index, count }: { index: number; count: number }) {
|
|
|
210
211
|
bottom: 0,
|
|
211
212
|
width: `${100 / count}%` as const,
|
|
212
213
|
borderRadius: FLOATING_PILL_RADIUS,
|
|
213
|
-
backgroundColor:
|
|
214
|
+
backgroundColor: floatingTabPillColors(scheme).backgroundColor,
|
|
214
215
|
},
|
|
215
216
|
slide,
|
|
216
217
|
]}
|
package/src/controlStyles.ts
CHANGED
|
@@ -337,6 +337,22 @@ export function tabTrackStyle(scheme: Scheme) {
|
|
|
337
337
|
return { backgroundColor: palette.default[scheme] };
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Fill and label of the `FloatingTabBar` active pill. On the web the raised
|
|
342
|
+
* `--segment` pill sits on a muted `--default` track. The floating bar is
|
|
343
|
+
* already the raised surface (`tokens.color.fill`, near-white in light), so in
|
|
344
|
+
* light the pill takes the muted track fill (`palette.default`), as a white
|
|
345
|
+
* `--segment` pill would not show on it. In dark it keeps `--segment`
|
|
346
|
+
* (`palette.segment`), lighter than the dark glass. The label is the
|
|
347
|
+
* segmented `--tabs-text-active`, as `tabColors("segmented", true, scheme)`.
|
|
348
|
+
*/
|
|
349
|
+
export function floatingTabPillColors(scheme: Scheme): TabColors {
|
|
350
|
+
return {
|
|
351
|
+
backgroundColor: scheme === "light" ? palette.default.light : palette.segment.dark,
|
|
352
|
+
color: tabColors("segmented", true, scheme).color,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
340
356
|
/**
|
|
341
357
|
* Box and check colours, from the web `Checkbox` classes: `bg-field-background
|
|
342
358
|
* border-border`, and `bg-primary border-primary text-primary-foreground` when
|