@momo-kits/foundation 0.169.17 → 0.169.18-beta.2
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/Application/BottomSheet.parts.tsx +4 -4
- package/Application/BottomSheet.tsx +16 -6
- package/Application/Components/HeaderAnimated.tsx +9 -33
- package/Application/Components/HeaderExtendHeader.tsx +18 -28
- package/Application/Components/SearchHeader.tsx +5 -7
- package/Application/ModalIconButton.tsx +15 -13
- package/Application/ModalScreen.tsx +4 -13
- package/Application/headerLayout.ts +30 -114
- package/Application/modalLayout.ts +11 -43
- package/Application/types.header.ts +1 -7
- package/Input/ErrorView.tsx +1 -1
- package/Input/InputMoneyView.tsx +14 -6
- package/Layout/Screen.tsx +16 -13
- package/Layout/Section.tsx +14 -3
- package/Layout/__tests__/screenFooter.test.ts +142 -0
- package/Layout/layoutMetrics.ts +2 -2
- package/Layout/screenContent.tsx +10 -4
- package/Layout/screenFooter.tsx +267 -22
- package/Layout/screenHeader.tsx +31 -26
- package/Layout/screenTypes.ts +27 -4
- package/Layout/styles.ts +10 -0
- package/Layout/types.ts +12 -0
- package/package.json +1 -1
- package/Application/__tests__/headerLayout.test.ts +0 -113
- package/Layout/useHeaderBarOptions.ts +0 -54
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getHeaderFrameOptions,
|
|
3
|
-
getHeaderLayout,
|
|
4
|
-
getSearchHeaderHeight,
|
|
5
|
-
HeaderBarMetrics,
|
|
6
|
-
} from '../headerLayout';
|
|
7
|
-
|
|
8
|
-
const PHONE = { width: 375, height: 812 };
|
|
9
|
-
const FOLD_INNER = { width: 760, height: 840 };
|
|
10
|
-
const DUO_INNER = { width: 932, height: 678 };
|
|
11
|
-
|
|
12
|
-
describe('getHeaderLayout', () => {
|
|
13
|
-
it('keeps the phone row at the bar edges with a full-width banner', () => {
|
|
14
|
-
const layout = getHeaderLayout({ ...PHONE, isDuo: false });
|
|
15
|
-
expect(layout.isWide).toBe(false);
|
|
16
|
-
expect(layout.isBannerCentered).toBe(false);
|
|
17
|
-
expect(layout.bannerScale).toBe(1);
|
|
18
|
-
expect(layout.frameInset).toBe(HeaderBarMetrics.sidePadding);
|
|
19
|
-
expect(layout.frameWidth).toBe(351);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('keeps the grid row at the bar edges on a 760 window', () => {
|
|
23
|
-
const layout = getHeaderLayout({ ...FOLD_INNER, isDuo: false });
|
|
24
|
-
expect(layout.isWide).toBe(true);
|
|
25
|
-
expect(layout.frameInset).toBe(HeaderBarMetrics.sidePadding);
|
|
26
|
-
expect(layout.frameWidth).toBe(736);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('centers the stretch row in the 600 frame on a 760 window', () => {
|
|
30
|
-
const input = { ...FOLD_INNER, isDuo: false };
|
|
31
|
-
const layout = getHeaderLayout({ ...input, contentLayout: 'stretch' });
|
|
32
|
-
expect(layout.frameInset).toBe(80);
|
|
33
|
-
expect(layout.frameWidth).toBe(600);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('scales the centered banner to 450 on a 760 window', () => {
|
|
37
|
-
const layout = getHeaderLayout({ ...FOLD_INNER, isDuo: false });
|
|
38
|
-
expect(layout.isBannerCentered).toBe(true);
|
|
39
|
-
expect(layout.bannerScale).toBe(1.2);
|
|
40
|
-
expect(layout.bannerWidth).toBe(450);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('centers the banner on the iPhone Duo inner display, without the frame', () => {
|
|
44
|
-
const input = { ...DUO_INNER, isDuo: true };
|
|
45
|
-
const layout = getHeaderLayout({ ...input, contentLayout: 'stretch' });
|
|
46
|
-
expect(layout.isWide).toBe(false);
|
|
47
|
-
expect(layout.isBannerCentered).toBe(true);
|
|
48
|
-
expect(layout.bannerScale).toBe(1.2);
|
|
49
|
-
expect(layout.frameInset).toBe(HeaderBarMetrics.sidePadding);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('getSearchHeaderHeight', () => {
|
|
54
|
-
it('grows a 48 bar row to the 56 search row', () => {
|
|
55
|
-
expect(getSearchHeaderHeight(48 + 47, 47)).toBe(56 + 47);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('keeps a row taller than the search row', () => {
|
|
59
|
-
expect(getSearchHeaderHeight(72, 0)).toBe(72);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('getHeaderFrameOptions', () => {
|
|
64
|
-
const NO_EDGE = { left: 0, right: 0 };
|
|
65
|
-
const DUO_EDGE = { left: 60, right: 90 };
|
|
66
|
-
const frameInput = (contentLayout?: 'grid' | 'stretch') => {
|
|
67
|
-
const layout = getHeaderLayout({
|
|
68
|
-
...FOLD_INNER,
|
|
69
|
-
isDuo: false,
|
|
70
|
-
contentLayout,
|
|
71
|
-
});
|
|
72
|
-
return { layout, isDuo: false, headerMargin: 0, edgePadding: NO_EDGE };
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
it('leaves the options alone when contentLayout is unset', () => {
|
|
76
|
-
expect(getHeaderFrameOptions(frameInput())).toBeUndefined();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('pulls the stretch row into the 600 frame on a 760 window', () => {
|
|
80
|
-
const options = getHeaderFrameOptions({
|
|
81
|
-
...frameInput('stretch'),
|
|
82
|
-
contentLayout: 'stretch',
|
|
83
|
-
});
|
|
84
|
-
expect(options?.headerLeftContainerStyle).toEqual({ paddingLeft: 68 });
|
|
85
|
-
expect(options?.headerRightContainerStyle).toEqual({ paddingRight: 68 });
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('resets grid to the bar edges, so a former stretch frame does not stay', () => {
|
|
89
|
-
const options = getHeaderFrameOptions({
|
|
90
|
-
...frameInput('grid'),
|
|
91
|
-
contentLayout: 'grid',
|
|
92
|
-
});
|
|
93
|
-
expect(options?.headerLeftContainerStyle).toEqual({ paddingLeft: 0 });
|
|
94
|
-
expect(options?.headerRightContainerStyle).toEqual({ paddingRight: 0 });
|
|
95
|
-
expect(options?.headerTitleContainerStyle).toMatchObject({
|
|
96
|
-
left: HeaderBarMetrics.titleGap,
|
|
97
|
-
});
|
|
98
|
-
expect(options?.headerTitleContainerStyle).not.toHaveProperty('maxWidth');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('keeps the iPhone Duo status bar clearance with stretch', () => {
|
|
102
|
-
const layout = getHeaderLayout({ ...DUO_INNER, isDuo: true });
|
|
103
|
-
const options = getHeaderFrameOptions({
|
|
104
|
-
layout,
|
|
105
|
-
isDuo: true,
|
|
106
|
-
headerMargin: 0,
|
|
107
|
-
edgePadding: DUO_EDGE,
|
|
108
|
-
contentLayout: 'stretch',
|
|
109
|
-
});
|
|
110
|
-
expect(options?.headerLeftContainerStyle).toEqual({ paddingLeft: 60 });
|
|
111
|
-
expect(options?.headerRightContainerStyle).toEqual({ paddingRight: 90 });
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { StackNavigationOptions } from '@react-navigation/stack';
|
|
3
|
-
import {
|
|
4
|
-
getSearchHeaderHeight,
|
|
5
|
-
type HeaderContentLayout,
|
|
6
|
-
useHeaderFrameOptions,
|
|
7
|
-
} from '../Application/headerLayout';
|
|
8
|
-
import type { ScreenLayout } from './layoutTypes';
|
|
9
|
-
|
|
10
|
-
type HeaderBarOptions = {
|
|
11
|
-
barOptions: StackNavigationOptions;
|
|
12
|
-
searchTitleOptions: StackNavigationOptions;
|
|
13
|
-
searchOptions: StackNavigationOptions;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Header row options for the Screen setters: the plain bar and the taller title row
|
|
18
|
-
* above an `inputSearchProps` search, both in the `contentLayout` frame, and the
|
|
19
|
-
* search header row, which spans the window and leaves the frame.
|
|
20
|
-
*/
|
|
21
|
-
const useHeaderBarOptions = (
|
|
22
|
-
layout: ScreenLayout,
|
|
23
|
-
contentLayout?: HeaderContentLayout,
|
|
24
|
-
): HeaderBarOptions => {
|
|
25
|
-
const frameOptions = useHeaderFrameOptions(contentLayout);
|
|
26
|
-
// the search header fills the bar, so it keeps the bar-edge row with either layout
|
|
27
|
-
let searchLayout: HeaderContentLayout | undefined;
|
|
28
|
-
if (contentLayout) {
|
|
29
|
-
searchLayout = 'grid';
|
|
30
|
-
}
|
|
31
|
-
const edgeOptions = useHeaderFrameOptions(searchLayout);
|
|
32
|
-
const { headerHeight, headerStatusBarHeight } = layout;
|
|
33
|
-
const searchHeight = getSearchHeaderHeight(
|
|
34
|
-
headerHeight,
|
|
35
|
-
headerStatusBarHeight,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// the height is re-applied on every header type, so a former search row does not stay
|
|
39
|
-
const barOptions = useMemo((): StackNavigationOptions => {
|
|
40
|
-
return { ...frameOptions, headerStyle: { height: headerHeight } };
|
|
41
|
-
}, [frameOptions, headerHeight]);
|
|
42
|
-
|
|
43
|
-
const searchTitleOptions = useMemo((): StackNavigationOptions => {
|
|
44
|
-
return { ...frameOptions, headerStyle: { height: searchHeight } };
|
|
45
|
-
}, [frameOptions, searchHeight]);
|
|
46
|
-
|
|
47
|
-
const searchOptions = useMemo((): StackNavigationOptions => {
|
|
48
|
-
return { ...edgeOptions, headerStyle: { height: searchHeight } };
|
|
49
|
-
}, [edgeOptions, searchHeight]);
|
|
50
|
-
|
|
51
|
-
return { barOptions, searchTitleOptions, searchOptions };
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { useHeaderBarOptions };
|