react-native-magic-tab-bar 1.0.0 → 2.0.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/README.md +253 -44
- package/lib/module/MagicTabBar.js +50 -7
- package/lib/module/MagicTabBar.js.map +1 -1
- package/lib/module/MagicTabItem.js +256 -23
- package/lib/module/MagicTabItem.js.map +1 -1
- package/lib/module/MagicTabs.js +95 -15
- package/lib/module/MagicTabs.js.map +1 -1
- package/lib/module/defaultTabs.js +5 -4
- package/lib/module/defaultTabs.js.map +1 -1
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theme.js +10 -1
- package/lib/module/theme.js.map +1 -1
- package/lib/typescript/MagicTabBar.d.ts +18 -1
- package/lib/typescript/MagicTabBar.d.ts.map +1 -1
- package/lib/typescript/MagicTabItem.d.ts +30 -4
- package/lib/typescript/MagicTabItem.d.ts.map +1 -1
- package/lib/typescript/MagicTabs.d.ts +43 -6
- package/lib/typescript/MagicTabs.d.ts.map +1 -1
- package/lib/typescript/defaultTabs.d.ts +5 -4
- package/lib/typescript/defaultTabs.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/theme.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +60 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +14 -4
- package/src/MagicTabBar.tsx +81 -7
- package/src/MagicTabItem.tsx +338 -19
- package/src/MagicTabs.tsx +168 -13
- package/src/defaultTabs.tsx +5 -4
- package/src/index.tsx +10 -1
- package/src/theme.ts +5 -0
- package/src/types.ts +64 -0
package/src/theme.ts
CHANGED
|
@@ -10,6 +10,11 @@ export const defaultTheme: MagicTabBarTheme = {
|
|
|
10
10
|
fontSize: 12,
|
|
11
11
|
height: 56,
|
|
12
12
|
radius: 28,
|
|
13
|
+
badgeColor: '#FF3B30',
|
|
14
|
+
badgeTextColor: '#FFFFFF',
|
|
15
|
+
actionColor: '#0A84FF',
|
|
16
|
+
actionIconColor: '#FFFFFF',
|
|
13
17
|
horizontalMargin: 14,
|
|
14
18
|
bottomInset: 10,
|
|
19
|
+
spring: { mass: 0.6, damping: 18, stiffness: 180 },
|
|
15
20
|
};
|
package/src/types.ts
CHANGED
|
@@ -19,10 +19,64 @@ export interface MagicTabConfig {
|
|
|
19
19
|
href: Href;
|
|
20
20
|
/** Optional text label rendered next to the icon while the tab is active. */
|
|
21
21
|
label?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Show this tab's label while active. Overrides the bar-level `showLabels`
|
|
24
|
+
* prop for this tab only. A tab without a `label` never shows text.
|
|
25
|
+
*/
|
|
26
|
+
showLabel?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Badge shown over the icon. `true` renders a small dot; a number or string
|
|
29
|
+
* renders a count bubble (numbers above 99 display as `99+`). Falsy values
|
|
30
|
+
* (`false`, `0`, `undefined`, `''`) render nothing.
|
|
31
|
+
*/
|
|
32
|
+
badge?: number | string | boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Dim the tab and block navigation to it. The tab still renders but cannot
|
|
35
|
+
* be pressed. Off by default.
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Render this tab as a raised, circular action ("FAB") button — common for a
|
|
40
|
+
* center "create"/"compose" tab. Ignores label/pill styling and uses the
|
|
41
|
+
* theme's `actionColor`/`actionIconColor`. Defaults to a normal tab.
|
|
42
|
+
*/
|
|
43
|
+
variant?: 'action';
|
|
44
|
+
/**
|
|
45
|
+
* When this tab is the active route, switch the whole bar into compact
|
|
46
|
+
* "light" mode (short, narrow, icon-only). Lets a single scroll-heavy screen
|
|
47
|
+
* (e.g. a feed) use a minimal bar while the other tabs keep the full one. The
|
|
48
|
+
* transition between modes is animated.
|
|
49
|
+
*/
|
|
50
|
+
isLight?: boolean;
|
|
22
51
|
/** Renders the tab's icon. */
|
|
23
52
|
icon: (props: MagicTabIconProps) => ReactNode;
|
|
24
53
|
}
|
|
25
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Fired when a tab is pressed. `name` is the tab's route name and `focused`
|
|
57
|
+
* is whether that tab was already the active one (useful for "scroll to top"
|
|
58
|
+
* or "reset stack" on re-press).
|
|
59
|
+
*/
|
|
60
|
+
export type MagicTabPressHandler = (name: string, focused: boolean) => void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* When labels are shown:
|
|
64
|
+
* - `'active'` — only on the focused tab (default).
|
|
65
|
+
* - `'always'` — on every tab, all the time.
|
|
66
|
+
* - `'never'` — icon-only bar.
|
|
67
|
+
*/
|
|
68
|
+
export type MagicLabelMode = 'active' | 'always' | 'never';
|
|
69
|
+
|
|
70
|
+
/** Where a tab's label sits relative to its icon. */
|
|
71
|
+
export type MagicLabelPosition = 'right' | 'bottom';
|
|
72
|
+
|
|
73
|
+
/** Spring parameters for the tab's focus/label animations. */
|
|
74
|
+
export interface MagicSpringConfig {
|
|
75
|
+
mass: number;
|
|
76
|
+
damping: number;
|
|
77
|
+
stiffness: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
26
80
|
/** Visual configuration for the tab bar. */
|
|
27
81
|
export interface MagicTabBarTheme {
|
|
28
82
|
/** Background color of the bar (ignored when `renderBackground` is provided). */
|
|
@@ -41,10 +95,20 @@ export interface MagicTabBarTheme {
|
|
|
41
95
|
height: number;
|
|
42
96
|
/** Corner radius of the bar and the active pill. */
|
|
43
97
|
radius: number;
|
|
98
|
+
/** Background color of a tab's badge. */
|
|
99
|
+
badgeColor: string;
|
|
100
|
+
/** Text color of a tab's badge count. */
|
|
101
|
+
badgeTextColor: string;
|
|
102
|
+
/** Background color of an `action`-variant tab. */
|
|
103
|
+
actionColor: string;
|
|
104
|
+
/** Icon color of an `action`-variant tab. */
|
|
105
|
+
actionIconColor: string;
|
|
44
106
|
/** Horizontal margin between the bar and the screen edges. */
|
|
45
107
|
horizontalMargin: number;
|
|
46
108
|
/** Extra space below the bar, added on top of the safe-area inset. */
|
|
47
109
|
bottomInset: number;
|
|
110
|
+
/** Spring used for the focus pill and label transitions. */
|
|
111
|
+
spring: MagicSpringConfig;
|
|
48
112
|
}
|
|
49
113
|
|
|
50
114
|
/** How the bar is positioned relative to screen content. */
|