@momo-kits/foundation 0.169.11-beta.2 → 0.169.11-beta.3
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.
|
@@ -13,6 +13,9 @@ import { Text } from '../../Text';
|
|
|
13
13
|
import ScaleSizeProvider from '../ScaleSizeProvider';
|
|
14
14
|
import { TabBarMetrics, TabBarMotion } from './metrics';
|
|
15
15
|
|
|
16
|
+
// text badges keep 5 characters, then "..." ("Khám phá" -> "Khám...")
|
|
17
|
+
const BADGE_MAX_CHARS = 5;
|
|
18
|
+
|
|
16
19
|
type Props = {
|
|
17
20
|
focused: boolean;
|
|
18
21
|
// '' shows a dot, anything else a label badge
|
|
@@ -30,7 +33,7 @@ type Props = {
|
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Badge value of a tab: undefined hides it, '' is a dot (also 0 when `showDot`), numbers
|
|
33
|
-
* cap at 99
|
|
36
|
+
* cap at 99+, text keeps its first 5 characters.
|
|
34
37
|
*/
|
|
35
38
|
export const getTabBadge = (
|
|
36
39
|
badgeLabel?: string | number,
|
|
@@ -50,7 +53,9 @@ export const getTabBadge = (
|
|
|
50
53
|
}
|
|
51
54
|
return value > 99 ? '99+' : text;
|
|
52
55
|
}
|
|
53
|
-
return text
|
|
56
|
+
return text.length > BADGE_MAX_CHARS
|
|
57
|
+
? `${text.slice(0, BADGE_MAX_CHARS).trimEnd()}...`
|
|
58
|
+
: text;
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
/**
|
|
@@ -8,8 +8,6 @@ import { isIPhoneDuo } from './utils';
|
|
|
8
8
|
|
|
9
9
|
// Top navigation spec, shared with the Compose / SwiftUI kits
|
|
10
10
|
const HEADER_FRAME_MAX_WIDTH = 600;
|
|
11
|
-
// stretch frame on hold until design confirms it: `stretch` lays out like `grid`
|
|
12
|
-
const IS_STRETCH_FRAME_ENABLED = false;
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Top navigation geometry on every device
|
|
@@ -37,8 +35,7 @@ const HeaderBarMetrics = {
|
|
|
37
35
|
|
|
38
36
|
/**
|
|
39
37
|
* `grid` keeps the header row at the bar edges, `stretch` centers it in a 600pt
|
|
40
|
-
* frame on wide windows
|
|
41
|
-
* bar always span the window.
|
|
38
|
+
* frame on wide windows. Background and status bar always span the window.
|
|
42
39
|
*/
|
|
43
40
|
type HeaderContentLayout = 'grid' | 'stretch';
|
|
44
41
|
|
|
@@ -84,8 +81,7 @@ const getHeaderLayout = ({
|
|
|
84
81
|
const isLargeWindow = Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
|
|
85
82
|
const isWide = !isDuo && isLargeWindow;
|
|
86
83
|
let frameInset = sidePadding;
|
|
87
|
-
|
|
88
|
-
if (isWide && isStretch) {
|
|
84
|
+
if (isWide && contentLayout === 'stretch') {
|
|
89
85
|
const centered = (width - HEADER_FRAME_MAX_WIDTH) / 2;
|
|
90
86
|
frameInset = Math.max(sidePadding, centered);
|
|
91
87
|
}
|
|
@@ -138,7 +134,7 @@ const useHeaderFrameOptions = (
|
|
|
138
134
|
const { width } = useWindowDimensions();
|
|
139
135
|
const isDuo = isIPhoneDuo();
|
|
140
136
|
return useMemo(() => {
|
|
141
|
-
if (
|
|
137
|
+
if (contentLayout !== 'stretch' || isDuo) {
|
|
142
138
|
return undefined;
|
|
143
139
|
}
|
|
144
140
|
// the header content row already sits this far in on large iOS windows
|