@momo-kits/foundation 0.169.4 → 0.169.5-beta.1

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.
@@ -0,0 +1,110 @@
1
+ import { AdoptionStore } from '../KitAdoption/AdoptionStore';
2
+ import type { ScreenSnapshot } from '../KitAdoption/types';
3
+
4
+ /** Snapshot with the given K/R/O counts for one app and screen. */
5
+ const makeSnapshot = (
6
+ screen: string,
7
+ counts: { K: number; R: number; O: number },
8
+ appId = 'app-1',
9
+ ): ScreenSnapshot => ({
10
+ counts,
11
+ kit: {},
12
+ rn: {},
13
+ other: {},
14
+ top_transparent: [],
15
+ fibers: 0,
16
+ truncated: false,
17
+ status: 'ok',
18
+ app_id: appId,
19
+ screen_name: screen,
20
+ platform: 'ios',
21
+ ts: 0,
22
+ walk_ms: 0,
23
+ });
24
+
25
+ describe('AdoptionStore save', () => {
26
+ it('keeps the existing snapshot when it has more nodes', () => {
27
+ const store = new AdoptionStore();
28
+ store.save(makeSnapshot('Home', { K: 3, R: 0, O: 0 }));
29
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }));
30
+
31
+ expect(store.getAll()).toHaveLength(1);
32
+ expect(store.getAll()[0].counts.K).toBe(3);
33
+ });
34
+
35
+ it('replaces the existing snapshot when the new one has more nodes', () => {
36
+ const store = new AdoptionStore();
37
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }));
38
+ store.save(makeSnapshot('Home', { K: 2, R: 2, O: 1 }));
39
+
40
+ expect(store.getAll()[0].counts).toEqual({ K: 2, R: 2, O: 1 });
41
+ });
42
+
43
+ it('keys snapshots by app and screen', () => {
44
+ const store = new AdoptionStore();
45
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }, 'app-1'));
46
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }, 'app-2'));
47
+
48
+ expect(store.getAll()).toHaveLength(2);
49
+ });
50
+
51
+ it('getLatest returns the most recently saved screen', () => {
52
+ const store = new AdoptionStore();
53
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }));
54
+ store.save(makeSnapshot('Detail', { K: 1, R: 0, O: 0 }));
55
+
56
+ expect(store.getLatest()?.screen_name).toBe('Detail');
57
+ });
58
+
59
+ it('clear empties the store and getLatest', () => {
60
+ const store = new AdoptionStore();
61
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }));
62
+ store.clear();
63
+
64
+ expect(store.getAll()).toEqual([]);
65
+ expect(store.getLatest()).toBeUndefined();
66
+ });
67
+ });
68
+
69
+ describe('AdoptionStore subscribe', () => {
70
+ it('notifies listeners on save and stops after unsubscribe', () => {
71
+ const store = new AdoptionStore();
72
+ const listener = jest.fn();
73
+ const unsubscribe = store.subscribe(listener);
74
+
75
+ store.save(makeSnapshot('Home', { K: 1, R: 0, O: 0 }));
76
+ expect(listener).toHaveBeenCalledTimes(1);
77
+
78
+ unsubscribe();
79
+ store.save(makeSnapshot('Detail', { K: 1, R: 0, O: 0 }));
80
+ expect(listener).toHaveBeenCalledTimes(1);
81
+ });
82
+ });
83
+
84
+ describe('AdoptionStore active measurer', () => {
85
+ it('remeasureActive calls the active measurer', () => {
86
+ const store = new AdoptionStore();
87
+ const measure = jest.fn();
88
+ store.setActive(measure);
89
+
90
+ store.remeasureActive();
91
+
92
+ expect(measure).toHaveBeenCalledTimes(1);
93
+ });
94
+
95
+ it('clearActive only clears the measurer that is still active', () => {
96
+ const store = new AdoptionStore();
97
+ const first = jest.fn();
98
+ const second = jest.fn();
99
+ store.setActive(first);
100
+ store.setActive(second);
101
+
102
+ store.clearActive(first);
103
+ store.remeasureActive();
104
+ expect(second).toHaveBeenCalledTimes(1);
105
+
106
+ store.clearActive(second);
107
+ store.remeasureActive();
108
+ expect(second).toHaveBeenCalledTimes(1);
109
+ });
110
+ });
@@ -16,10 +16,10 @@ describe('getModalLayout', () => {
16
16
  expect(layout.isFoldable).toBe(false);
17
17
  expect(layout.popup.width).toBe(342);
18
18
  expect(layout.popup.maxHeight).toBeUndefined();
19
- expect(layout.popup.radius).toBe(24);
19
+ expect(layout.popup.radius).toBe(16);
20
20
  expect(layout.sheet.width).toBeUndefined();
21
21
  expect(layout.sheet.maxHeight).toBeUndefined();
22
- expect(layout.sheet.radius).toBe(24);
22
+ expect(layout.sheet.radius).toBe(12);
23
23
  expect(layout.scrimOpacity).toBe(0.6);
24
24
  });
25
25
 
@@ -33,7 +33,7 @@ describe('getModalLayout', () => {
33
33
  expect(layout.isFoldable).toBe(false);
34
34
  expect(layout.popup.width).toBe(844 - 48);
35
35
  expect(layout.popup.maxHeight).toBeUndefined();
36
- expect(layout.popup.radius).toBe(24);
36
+ expect(layout.popup.radius).toBe(16);
37
37
  expect(layout.sheet.width).toBeUndefined();
38
38
  expect(layout.scrimOpacity).toBe(0.6);
39
39
  });
@@ -112,9 +112,9 @@ const getModalLayout = ({
112
112
  minWidth: popupWidth,
113
113
  maxWidth: popupWidth,
114
114
  margin: Spacing.XL,
115
- radius: Radius.XL,
115
+ radius: Radius.L,
116
116
  },
117
- sheet: { margin: 0, radius: Radius.XL },
117
+ sheet: { margin: 0, radius: Radius.M },
118
118
  scrimOpacity: SCRIM_OPACITY,
119
119
  };
120
120
  }
@@ -183,12 +183,18 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
183
183
  const body = (
184
184
  <>
185
185
  {!!image && (
186
- <Image source={{ uri: image }} style={styles.image} />
186
+ <Image
187
+ source={{ uri: image }}
188
+ style={[
189
+ styles.image,
190
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
191
+ ]}
192
+ />
187
193
  )}
188
194
  <View style={[styles.content, isFoldable && styles.shrink]}>
189
195
  <Text
190
196
  typography={'header_default_bold'}
191
- numberOfLines={2}
197
+ numberOfLines={3}
192
198
  accessibilityLabel={'title_popup_notify'}
193
199
  // keeps the title clear of the close button on a text only popup
194
200
  style={
@@ -244,7 +250,6 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
244
250
  width: popupWidth,
245
251
  maxHeight,
246
252
  },
247
- styles.card,
248
253
  showBaseLineDebug && styles.debugBaseLine,
249
254
  ]}
250
255
  >
@@ -257,10 +262,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
257
262
 
258
263
  const styles = StyleSheet.create({
259
264
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
260
- // clips the image and content to the card radius
261
- card: { overflow: 'hidden' },
262
265
  image: {
263
266
  aspectRatio: 1.7777,
267
+ overflow: 'hidden',
264
268
  },
265
269
  shrink: { flexShrink: 1 },
266
270
  content: { padding: Spacing.XL },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.4",
3
+ "version": "0.169.5-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},