@tactics/toddle-styleguide 1.2.5 → 1.2.7
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/App.tsx +8 -0
- package/package.json +1 -1
- package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
- package/src/components/atoms/quick-message/__snapshots__/quick-message.test.js.snap +72 -0
- package/src/components/atoms/quick-message/quick-message.component.d.ts +7 -0
- package/src/components/atoms/quick-message/quick-message.component.tsx +32 -0
- package/src/components/atoms/quick-message/quick-message.preview.d.ts +1 -0
- package/src/components/atoms/quick-message/quick-message.preview.tsx +33 -0
- package/src/components/atoms/quick-message/quick-message.styles.d.ts +14 -0
- package/src/components/atoms/quick-message/quick-message.styles.js +18 -0
- package/src/components/atoms/quick-message/quick-message.test.js +26 -0
- package/src/components/molecules/button/__snapshots__/button.test.js.snap +72 -0
- package/src/components/molecules/button/button.component.d.ts +1 -1
- package/src/components/molecules/button/button.component.tsx +8 -15
- package/src/components/molecules/button/button.preview.tsx +5 -0
- package/src/components/molecules/button/button.test.js +6 -0
- package/src/components/molecules/failed-to-send/__snapshots__/failed-bubble.test.js.snap +2 -0
- package/src/components/molecules/failed-to-send/failed-bubble.component.d.ts +4 -3
- package/src/components/molecules/failed-to-send/failed-bubble.component.tsx +6 -4
- package/src/components/molecules/failed-to-send/failed-bubble.test.js +56 -0
- package/src/components/molecules/send-bubble/__snapshots__/send-text-bubble.test.js.snap +12 -0
- package/src/components/molecules/send-bubble/send-text-bubble.component.d.ts +4 -3
- package/src/components/molecules/send-bubble/send-text-bubble.component.tsx +17 -6
- package/src/components/molecules/send-bubble/send-text-bubble.test.js +71 -0
- package/src/components/molecules/tag/__snapshots__/tag.test.js.snap +3 -3
- package/src/components/molecules/tag/tag.component.d.ts +3 -2
- package/src/components/molecules/tag/tag.component.tsx +13 -18
- package/src/components/molecules/tag/tag.preview.tsx +61 -6
- package/src/components/molecules/tag/tag.test.js +2 -0
- package/src/components/organisms/day-select/day-select.component.tsx +5 -1
- package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +21 -0
- package/src/components/organisms/text-bubble/text-bubble.component.d.ts +5 -4
- package/src/components/organisms/text-bubble/text-bubble.component.tsx +15 -5
- package/src/components/organisms/text-bubble/text-bubble.preview.tsx +6 -1
- package/src/components/organisms/text-bubble/text-bubble.styles.d.ts +30 -44
- package/src/components/organisms/text-bubble/text-bubble.styles.js +2 -0
- package/src/components/organisms/text-bubble/text-bubble.test.js +7 -0
package/App.tsx
CHANGED
|
@@ -69,6 +69,7 @@ import {BackgroundGradientPreview} from './src/components/atoms/background-gradi
|
|
|
69
69
|
import {PersonInfoCardPreview} from './src/components/organisms/person-info-card/person-info-card.preview';
|
|
70
70
|
import {TimePickerPreview} from './src/components/molecules/time-picker/time-picker.preview';
|
|
71
71
|
import {PopOverActionPreview} from './src/components/templates/popover-action/popover-action.preview';
|
|
72
|
+
import {QuickMessagePreview} from './src/components/atoms/quick-message/quick-message.preview';
|
|
72
73
|
|
|
73
74
|
const Stack = createNativeStackNavigator();
|
|
74
75
|
|
|
@@ -221,6 +222,10 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
|
|
|
221
222
|
title="Quick Filter"
|
|
222
223
|
onPress={() => navigation.push('quick-filter')}
|
|
223
224
|
/>
|
|
225
|
+
<ReactBtn
|
|
226
|
+
title="Quick Message"
|
|
227
|
+
onPress={() => navigation.push('quick-message')}
|
|
228
|
+
/>
|
|
224
229
|
<ReactBtn
|
|
225
230
|
title="Search Input"
|
|
226
231
|
onPress={() => navigation.push('search')}
|
|
@@ -403,6 +408,9 @@ function App() {
|
|
|
403
408
|
<Stack.Screen name="quick-filter">
|
|
404
409
|
{() => <QuickFilterPreview />}
|
|
405
410
|
</Stack.Screen>
|
|
411
|
+
<Stack.Screen name="quick-message">
|
|
412
|
+
{() => <QuickMessagePreview />}
|
|
413
|
+
</Stack.Screen>
|
|
406
414
|
<Stack.Screen name="search">{() => <SearchPreview />}</Stack.Screen>
|
|
407
415
|
<Stack.Screen name="select-link">
|
|
408
416
|
{() => <SelectLinkPreview />}
|
package/package.json
CHANGED
|
@@ -1804,7 +1804,7 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
1804
1804
|
}
|
|
1805
1805
|
>
|
|
1806
1806
|
<View
|
|
1807
|
-
accessibilityLabel="
|
|
1807
|
+
accessibilityLabel=" Woensdag 12 Juli 2023 "
|
|
1808
1808
|
accessibilityRole="button"
|
|
1809
1809
|
accessibilityState={
|
|
1810
1810
|
{
|
|
@@ -1836,10 +1836,6 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
1836
1836
|
style={
|
|
1837
1837
|
{
|
|
1838
1838
|
"alignItems": "center",
|
|
1839
|
-
"borderColor": "#7B93DB",
|
|
1840
|
-
"borderRadius": 21,
|
|
1841
|
-
"borderStyle": "solid",
|
|
1842
|
-
"borderWidth": 1,
|
|
1843
1839
|
"height": 42,
|
|
1844
1840
|
"justifyContent": "center",
|
|
1845
1841
|
"opacity": 1,
|
|
@@ -1859,9 +1855,6 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
1859
1855
|
"lineHeight": 22.4,
|
|
1860
1856
|
"marginTop": 4,
|
|
1861
1857
|
},
|
|
1862
|
-
{
|
|
1863
|
-
"color": "#7B93DB",
|
|
1864
|
-
},
|
|
1865
1858
|
]
|
|
1866
1859
|
}
|
|
1867
1860
|
>
|
|
@@ -2307,7 +2300,7 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
2307
2300
|
}
|
|
2308
2301
|
>
|
|
2309
2302
|
<View
|
|
2310
|
-
accessibilityLabel=" Dinsdag 18 Juli 2023 "
|
|
2303
|
+
accessibilityLabel="today Dinsdag 18 Juli 2023 "
|
|
2311
2304
|
accessibilityRole="button"
|
|
2312
2305
|
accessibilityState={
|
|
2313
2306
|
{
|
|
@@ -2339,6 +2332,10 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
2339
2332
|
style={
|
|
2340
2333
|
{
|
|
2341
2334
|
"alignItems": "center",
|
|
2335
|
+
"borderColor": "#7B93DB",
|
|
2336
|
+
"borderRadius": 21,
|
|
2337
|
+
"borderStyle": "solid",
|
|
2338
|
+
"borderWidth": 1,
|
|
2342
2339
|
"height": 42,
|
|
2343
2340
|
"justifyContent": "center",
|
|
2344
2341
|
"opacity": 1,
|
|
@@ -2358,6 +2355,9 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
2358
2355
|
"lineHeight": 22.4,
|
|
2359
2356
|
"marginTop": 4,
|
|
2360
2357
|
},
|
|
2358
|
+
{
|
|
2359
|
+
"color": "#7B93DB",
|
|
2360
|
+
},
|
|
2361
2361
|
]
|
|
2362
2362
|
}
|
|
2363
2363
|
>
|
|
@@ -5782,8 +5782,7 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
5782
5782
|
}
|
|
5783
5783
|
>
|
|
5784
5784
|
<View
|
|
5785
|
-
accessibilityLabel="
|
|
5786
|
-
accessibilityRole="button"
|
|
5785
|
+
accessibilityLabel=" Woensdag 12 Juli 2023 "
|
|
5787
5786
|
accessibilityState={
|
|
5788
5787
|
{
|
|
5789
5788
|
"busy": undefined,
|
|
@@ -5814,10 +5813,6 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
5814
5813
|
style={
|
|
5815
5814
|
{
|
|
5816
5815
|
"alignItems": "center",
|
|
5817
|
-
"borderColor": "#7B93DB",
|
|
5818
|
-
"borderRadius": 21,
|
|
5819
|
-
"borderStyle": "solid",
|
|
5820
|
-
"borderWidth": 1,
|
|
5821
5816
|
"height": 42,
|
|
5822
5817
|
"justifyContent": "center",
|
|
5823
5818
|
"opacity": 1,
|
|
@@ -5838,7 +5833,7 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
5838
5833
|
"marginTop": 4,
|
|
5839
5834
|
},
|
|
5840
5835
|
{
|
|
5841
|
-
"color": "#
|
|
5836
|
+
"color": "#9AA5B1",
|
|
5842
5837
|
},
|
|
5843
5838
|
]
|
|
5844
5839
|
}
|
|
@@ -6295,7 +6290,8 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
6295
6290
|
}
|
|
6296
6291
|
>
|
|
6297
6292
|
<View
|
|
6298
|
-
accessibilityLabel=" Dinsdag 18 Juli 2023 "
|
|
6293
|
+
accessibilityLabel="today Dinsdag 18 Juli 2023 "
|
|
6294
|
+
accessibilityRole="button"
|
|
6299
6295
|
accessibilityState={
|
|
6300
6296
|
{
|
|
6301
6297
|
"busy": undefined,
|
|
@@ -6326,6 +6322,10 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
6326
6322
|
style={
|
|
6327
6323
|
{
|
|
6328
6324
|
"alignItems": "center",
|
|
6325
|
+
"borderColor": "#7B93DB",
|
|
6326
|
+
"borderRadius": 21,
|
|
6327
|
+
"borderStyle": "solid",
|
|
6328
|
+
"borderWidth": 1,
|
|
6329
6329
|
"height": 42,
|
|
6330
6330
|
"justifyContent": "center",
|
|
6331
6331
|
"opacity": 1,
|
|
@@ -6346,7 +6346,7 @@ exports[`Test for the calendar component renders a calendar where you can select
|
|
|
6346
6346
|
"marginTop": 4,
|
|
6347
6347
|
},
|
|
6348
6348
|
{
|
|
6349
|
-
"color": "#
|
|
6349
|
+
"color": "#7B93DB",
|
|
6350
6350
|
},
|
|
6351
6351
|
]
|
|
6352
6352
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`QuickMessage should render correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessibilityState={
|
|
6
|
+
{
|
|
7
|
+
"busy": undefined,
|
|
8
|
+
"checked": undefined,
|
|
9
|
+
"disabled": undefined,
|
|
10
|
+
"expanded": undefined,
|
|
11
|
+
"selected": undefined,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
accessibilityValue={
|
|
15
|
+
{
|
|
16
|
+
"max": undefined,
|
|
17
|
+
"min": undefined,
|
|
18
|
+
"now": undefined,
|
|
19
|
+
"text": undefined,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
accessible={true}
|
|
23
|
+
collapsable={false}
|
|
24
|
+
focusable={true}
|
|
25
|
+
onBlur={[Function]}
|
|
26
|
+
onClick={[Function]}
|
|
27
|
+
onFocus={[Function]}
|
|
28
|
+
onResponderGrant={[Function]}
|
|
29
|
+
onResponderMove={[Function]}
|
|
30
|
+
onResponderRelease={[Function]}
|
|
31
|
+
onResponderTerminate={[Function]}
|
|
32
|
+
onResponderTerminationRequest={[Function]}
|
|
33
|
+
onStartShouldSetResponder={[Function]}
|
|
34
|
+
style={
|
|
35
|
+
{
|
|
36
|
+
"backgroundColor": "#515F6C",
|
|
37
|
+
"borderBottomLeftRadius": 8,
|
|
38
|
+
"borderBottomRightRadius": 24,
|
|
39
|
+
"borderTopLeftRadius": 24,
|
|
40
|
+
"borderTopRightRadius": 24,
|
|
41
|
+
"paddingBottom": 24,
|
|
42
|
+
"paddingLeft": 24,
|
|
43
|
+
"paddingRight": 24,
|
|
44
|
+
"paddingTop": 24,
|
|
45
|
+
"width": "100%",
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
testID="quick-message-test"
|
|
49
|
+
>
|
|
50
|
+
<Text
|
|
51
|
+
style={
|
|
52
|
+
[
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
"fontFamily": "Montserrat",
|
|
56
|
+
"fontSize": 14,
|
|
57
|
+
"lineHeight": 22.4,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
{
|
|
61
|
+
"color": "#FFFFFF",
|
|
62
|
+
"textAlign": "center",
|
|
63
|
+
"width": "100%",
|
|
64
|
+
},
|
|
65
|
+
undefined,
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
Test message
|
|
70
|
+
</Text>
|
|
71
|
+
</View>
|
|
72
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PressableProps } from 'react-native';
|
|
2
|
+
interface QuickMessageProps extends PressableProps {
|
|
3
|
+
message: string;
|
|
4
|
+
setMessage: (value: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const QuickMessage: ({ message, setMessage, ...props }: QuickMessageProps) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Pressable, PressableProps} from 'react-native';
|
|
2
|
+
import {Paragraph} from '../paragraph-components';
|
|
3
|
+
import {useContext} from 'react';
|
|
4
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
5
|
+
import {Stylesheet} from './quick-message.styles';
|
|
6
|
+
|
|
7
|
+
interface QuickMessageProps extends PressableProps {
|
|
8
|
+
message: string;
|
|
9
|
+
setMessage: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const QuickMessage = ({
|
|
13
|
+
message,
|
|
14
|
+
setMessage,
|
|
15
|
+
...props
|
|
16
|
+
}: QuickMessageProps) => {
|
|
17
|
+
const context = useContext(ThemeCtx);
|
|
18
|
+
const styles = Stylesheet(context);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Pressable
|
|
22
|
+
onPress={() => setMessage(message)}
|
|
23
|
+
{...props}
|
|
24
|
+
style={styles.container}
|
|
25
|
+
testID={'quick-message-test'}
|
|
26
|
+
>
|
|
27
|
+
<Paragraph textAlign={'center'} textColor={context.colors.ui.white}>
|
|
28
|
+
{message}
|
|
29
|
+
</Paragraph>
|
|
30
|
+
</Pressable>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QuickMessagePreview: () => JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {Text, View} from 'react-native';
|
|
2
|
+
import {QuickMessage} from './quick-message.component';
|
|
3
|
+
import {useState} from 'react';
|
|
4
|
+
|
|
5
|
+
export const QuickMessagePreview = () => {
|
|
6
|
+
const [message, setMessage] = useState<string>('');
|
|
7
|
+
return (
|
|
8
|
+
<View
|
|
9
|
+
style={{
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: '100%',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
gap: 32,
|
|
15
|
+
padding: 32,
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
<QuickMessage message={'Test message'} setMessage={setMessage} />
|
|
19
|
+
<QuickMessage
|
|
20
|
+
message={'Option message number 2'}
|
|
21
|
+
setMessage={setMessage}
|
|
22
|
+
/>
|
|
23
|
+
<QuickMessage
|
|
24
|
+
message={
|
|
25
|
+
'Aan het spelen met mijn vriendjes en vriendinnetjes in de speelhoek'
|
|
26
|
+
}
|
|
27
|
+
setMessage={setMessage}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<Text style={{textAlign: 'center'}}>Pressed message: {message}</Text>
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function Stylesheet(context: any): {
|
|
2
|
+
container: {
|
|
3
|
+
width: string;
|
|
4
|
+
backgroundColor: any;
|
|
5
|
+
paddingTop: number;
|
|
6
|
+
paddingBottom: number;
|
|
7
|
+
paddingRight: number;
|
|
8
|
+
paddingLeft: number;
|
|
9
|
+
borderBottomLeftRadius: number;
|
|
10
|
+
borderTopLeftRadius: number;
|
|
11
|
+
borderTopRightRadius: number;
|
|
12
|
+
borderBottomRightRadius: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Scale} from '../../../theme/scale/index';
|
|
3
|
+
|
|
4
|
+
export const Stylesheet = (context) =>
|
|
5
|
+
StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
width: '100%',
|
|
8
|
+
backgroundColor: context.colors.ui.darkgrey,
|
|
9
|
+
paddingTop: Scale.l,
|
|
10
|
+
paddingBottom: Scale.l,
|
|
11
|
+
paddingRight: Scale.l,
|
|
12
|
+
paddingLeft: Scale.l,
|
|
13
|
+
borderBottomLeftRadius: Scale.xs,
|
|
14
|
+
borderTopLeftRadius: Scale.l,
|
|
15
|
+
borderTopRightRadius: Scale.l,
|
|
16
|
+
borderBottomRightRadius: Scale.l,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render, fireEvent} from '@testing-library/react-native';
|
|
3
|
+
import {QuickMessage} from './quick-message.component';
|
|
4
|
+
|
|
5
|
+
describe('QuickMessage', () => {
|
|
6
|
+
it('should render correctly', () => {
|
|
7
|
+
const {toJSON} = render(
|
|
8
|
+
<QuickMessage message="Test message" setMessage={() => {}} />
|
|
9
|
+
);
|
|
10
|
+
expect(toJSON()).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('QuickMessage', () => {
|
|
15
|
+
it('should set the message when pressed', () => {
|
|
16
|
+
const setMessageMock = jest.fn();
|
|
17
|
+
const {getByTestId} = render(
|
|
18
|
+
<QuickMessage message="Test message" setMessage={setMessageMock} />
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const pressable = getByTestId('quick-message-test');
|
|
22
|
+
fireEvent.press(pressable);
|
|
23
|
+
|
|
24
|
+
expect(setMessageMock).toHaveBeenCalledWith('Test message');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -429,6 +429,78 @@ exports[`test button component should render a button component with a solid ico
|
|
|
429
429
|
</View>
|
|
430
430
|
`;
|
|
431
431
|
|
|
432
|
+
exports[`test button component should render a light button component 1`] = `
|
|
433
|
+
<View
|
|
434
|
+
accessibilityState={
|
|
435
|
+
{
|
|
436
|
+
"busy": undefined,
|
|
437
|
+
"checked": undefined,
|
|
438
|
+
"disabled": undefined,
|
|
439
|
+
"expanded": undefined,
|
|
440
|
+
"selected": undefined,
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
accessibilityValue={
|
|
444
|
+
{
|
|
445
|
+
"max": undefined,
|
|
446
|
+
"min": undefined,
|
|
447
|
+
"now": undefined,
|
|
448
|
+
"text": undefined,
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
accessible={true}
|
|
452
|
+
collapsable={false}
|
|
453
|
+
focusable={true}
|
|
454
|
+
onBlur={[Function]}
|
|
455
|
+
onClick={[Function]}
|
|
456
|
+
onFocus={[Function]}
|
|
457
|
+
onResponderGrant={[Function]}
|
|
458
|
+
onResponderMove={[Function]}
|
|
459
|
+
onResponderRelease={[Function]}
|
|
460
|
+
onResponderTerminate={[Function]}
|
|
461
|
+
onResponderTerminationRequest={[Function]}
|
|
462
|
+
onStartShouldSetResponder={[Function]}
|
|
463
|
+
>
|
|
464
|
+
<View
|
|
465
|
+
style={
|
|
466
|
+
{
|
|
467
|
+
"alignItems": "center",
|
|
468
|
+
"backgroundColor": "#FFFFFF",
|
|
469
|
+
"borderRadius": 50,
|
|
470
|
+
"flexDirection": "row",
|
|
471
|
+
"justifyContent": "center",
|
|
472
|
+
"paddingHorizontal": 24,
|
|
473
|
+
"paddingVertical": 12,
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
>
|
|
477
|
+
<View>
|
|
478
|
+
<Text
|
|
479
|
+
style={
|
|
480
|
+
[
|
|
481
|
+
[
|
|
482
|
+
{
|
|
483
|
+
"fontFamily": "SourceSansPro",
|
|
484
|
+
"fontSize": 16,
|
|
485
|
+
"lineHeight": 22.4,
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
{
|
|
489
|
+
"color": "#515F6C",
|
|
490
|
+
"textAlign": "center",
|
|
491
|
+
"width": "100%",
|
|
492
|
+
},
|
|
493
|
+
undefined,
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
>
|
|
497
|
+
Light button
|
|
498
|
+
</Text>
|
|
499
|
+
</View>
|
|
500
|
+
</View>
|
|
501
|
+
</View>
|
|
502
|
+
`;
|
|
503
|
+
|
|
432
504
|
exports[`test button component should render a success button component 1`] = `
|
|
433
505
|
<View
|
|
434
506
|
accessibilityState={
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PressableProps } from 'react-native';
|
|
2
2
|
import { IconNameType, IconStyleType } from '../../../types/icontype.type';
|
|
3
|
-
type ButtonType = 'regular' | 'error' | 'success';
|
|
3
|
+
type ButtonType = 'regular' | 'error' | 'success' | 'light';
|
|
4
4
|
interface ButtonProps extends PressableProps {
|
|
5
5
|
label: string;
|
|
6
6
|
icon?: boolean;
|
|
@@ -8,7 +8,7 @@ import {Heading4} from '../../atoms/heading-components';
|
|
|
8
8
|
import {IconNameType, IconStyleType} from '../../../types/icontype.type';
|
|
9
9
|
import {Icon} from '../../../icons/index';
|
|
10
10
|
|
|
11
|
-
type ButtonType = 'regular' | 'error' | 'success';
|
|
11
|
+
type ButtonType = 'regular' | 'error' | 'success' | 'light';
|
|
12
12
|
|
|
13
13
|
interface ButtonProps extends PressableProps {
|
|
14
14
|
label: string;
|
|
@@ -33,12 +33,17 @@ const Button = ({
|
|
|
33
33
|
const context = useContext(ThemeCtx);
|
|
34
34
|
|
|
35
35
|
let buttonColor;
|
|
36
|
+
let textColor = context.colors.ui.white;
|
|
36
37
|
if (type === 'error') {
|
|
37
38
|
buttonColor = context.colors.ui.error.dark;
|
|
38
39
|
} else if (type === 'success') {
|
|
39
40
|
buttonColor = context.colors.ui.success.dark;
|
|
41
|
+
} else if (type === 'light') {
|
|
42
|
+
buttonColor = context.colors.ui.white;
|
|
43
|
+
textColor = context.colors.ui.darkgrey;
|
|
40
44
|
} else {
|
|
41
45
|
buttonColor = context.colors.main['0'];
|
|
46
|
+
textColor = context.colors.main['9'];
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
const styles = Stylesheet(context, disabled, buttonColor);
|
|
@@ -51,13 +56,7 @@ const Button = ({
|
|
|
51
56
|
<Icon
|
|
52
57
|
style={iconStyle}
|
|
53
58
|
name={iconName}
|
|
54
|
-
color={
|
|
55
|
-
disabled
|
|
56
|
-
? context.colors.ui.darkgrey
|
|
57
|
-
: type === 'regular'
|
|
58
|
-
? context.colors.main['9']
|
|
59
|
-
: context.colors.ui.white
|
|
60
|
-
}
|
|
59
|
+
color={disabled ? context.colors.ui.darkgrey : textColor}
|
|
61
60
|
size={iconSize}
|
|
62
61
|
/>
|
|
63
62
|
</View>
|
|
@@ -65,13 +64,7 @@ const Button = ({
|
|
|
65
64
|
<View>
|
|
66
65
|
<Heading4
|
|
67
66
|
textAlign={'center'}
|
|
68
|
-
textColor={
|
|
69
|
-
disabled
|
|
70
|
-
? context.colors.ui.darkgrey
|
|
71
|
-
: type === 'regular'
|
|
72
|
-
? context.colors.main['9']
|
|
73
|
-
: context.colors.ui.white
|
|
74
|
-
}
|
|
67
|
+
textColor={disabled ? context.colors.ui.darkgrey : textColor}
|
|
75
68
|
>
|
|
76
69
|
{label}
|
|
77
70
|
</Heading4>
|
|
@@ -22,6 +22,11 @@ export const ButtonPreview = ({}: {}) => {
|
|
|
22
22
|
type={'success'}
|
|
23
23
|
onPress={() => console.log('clicked')}
|
|
24
24
|
/>
|
|
25
|
+
<Button
|
|
26
|
+
label="Light button"
|
|
27
|
+
type={'light'}
|
|
28
|
+
onPress={() => console.log('clicked')}
|
|
29
|
+
/>
|
|
25
30
|
<Button
|
|
26
31
|
label="Icon button"
|
|
27
32
|
icon={true}
|
|
@@ -19,6 +19,12 @@ describe('test button component', () => {
|
|
|
19
19
|
.toJSON();
|
|
20
20
|
expect(tree).toMatchSnapshot();
|
|
21
21
|
});
|
|
22
|
+
it('should render a light button component', function () {
|
|
23
|
+
const tree = render
|
|
24
|
+
.create(<Button type={'light'} label="Light button" />)
|
|
25
|
+
.toJSON();
|
|
26
|
+
expect(tree).toMatchSnapshot();
|
|
27
|
+
});
|
|
22
28
|
it('should render a button component that is disabled', () => {
|
|
23
29
|
const tree = render
|
|
24
30
|
.create(<Button label="Button without icon" disabled={true} />)
|
|
@@ -174,6 +174,7 @@ exports[`Failed text bubble test shows a failed to send text bubble that is swip
|
|
|
174
174
|
onResponderTerminate={[Function]}
|
|
175
175
|
onResponderTerminationRequest={[Function]}
|
|
176
176
|
onStartShouldSetResponder={[Function]}
|
|
177
|
+
testID="refresh-button"
|
|
177
178
|
>
|
|
178
179
|
<RNSVGSvgView
|
|
179
180
|
align="xMidYMid"
|
|
@@ -274,6 +275,7 @@ exports[`Failed text bubble test shows a failed to send text bubble that is swip
|
|
|
274
275
|
onResponderTerminate={[Function]}
|
|
275
276
|
onResponderTerminationRequest={[Function]}
|
|
276
277
|
onStartShouldSetResponder={[Function]}
|
|
278
|
+
testID="delete-button"
|
|
277
279
|
>
|
|
278
280
|
<RNSVGSvgView
|
|
279
281
|
align="xMidYMid"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type FailedBubbleProps = {
|
|
2
|
+
id: string;
|
|
2
3
|
text: string;
|
|
3
|
-
onPressRefresh: () => void;
|
|
4
|
-
onPressDelete: () => void;
|
|
4
|
+
onPressRefresh: (id: string) => void;
|
|
5
|
+
onPressDelete: (id: string) => void;
|
|
5
6
|
};
|
|
6
|
-
declare const FailedTextBubble: ({ text, onPressRefresh, onPressDelete, }: FailedBubbleProps) => JSX.Element;
|
|
7
|
+
declare const FailedTextBubble: ({ id, text, onPressRefresh, onPressDelete, }: FailedBubbleProps) => JSX.Element;
|
|
7
8
|
export { FailedTextBubble };
|
|
@@ -10,12 +10,14 @@ import {GestureHandlerRootView, Swipeable} from 'react-native-gesture-handler';
|
|
|
10
10
|
import {SmallText} from '../../atoms/paragraph-components';
|
|
11
11
|
|
|
12
12
|
type FailedBubbleProps = {
|
|
13
|
+
id: string;
|
|
13
14
|
text: string;
|
|
14
|
-
onPressRefresh: () => void;
|
|
15
|
-
onPressDelete: () => void;
|
|
15
|
+
onPressRefresh: (id: string) => void;
|
|
16
|
+
onPressDelete: (id: string) => void;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const FailedTextBubble = ({
|
|
20
|
+
id,
|
|
19
21
|
text,
|
|
20
22
|
onPressRefresh,
|
|
21
23
|
onPressDelete,
|
|
@@ -36,7 +38,7 @@ const FailedTextBubble = ({
|
|
|
36
38
|
return (
|
|
37
39
|
<View style={styles.swipedRow}>
|
|
38
40
|
<Animated.View style={[styles.swipedIcon, {opacity}]}>
|
|
39
|
-
<Pressable onPress={onPressRefresh}>
|
|
41
|
+
<Pressable onPress={() => onPressRefresh(id)} testID="refresh-button">
|
|
40
42
|
<Icon
|
|
41
43
|
style={'regular'}
|
|
42
44
|
name={'refresh'}
|
|
@@ -45,7 +47,7 @@ const FailedTextBubble = ({
|
|
|
45
47
|
</Pressable>
|
|
46
48
|
</Animated.View>
|
|
47
49
|
<Animated.View style={[styles.swipedIcon, {opacity}]}>
|
|
48
|
-
<Pressable onPress={onPressDelete}>
|
|
50
|
+
<Pressable onPress={() => onPressDelete(id)} testID="delete-button">
|
|
49
51
|
<Icon
|
|
50
52
|
style={'regular'}
|
|
51
53
|
name={'trash'}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import {FailedTextBubble} from './failed-bubble.component';
|
|
4
|
+
import {render, fireEvent} from '@testing-library/react-native';
|
|
4
5
|
|
|
5
6
|
describe('Failed text bubble test', () => {
|
|
6
7
|
it('shows a failed to send text bubble that is swipeable with refresh and trash icon, which if we press them we can resend or delete the message', () => {
|
|
7
8
|
const tree = renderer
|
|
8
9
|
.create(
|
|
9
10
|
<FailedTextBubble
|
|
11
|
+
id={'1'}
|
|
10
12
|
text={'Testing our failed bubble'}
|
|
11
13
|
onPressRefresh={() => alert('pressed resend')}
|
|
12
14
|
onPressDelete={() => alert('delete the message')}
|
|
@@ -17,3 +19,57 @@ describe('Failed text bubble test', () => {
|
|
|
17
19
|
expect(tree).toMatchSnapshot();
|
|
18
20
|
});
|
|
19
21
|
});
|
|
22
|
+
|
|
23
|
+
describe('FailedTextBubble', () => {
|
|
24
|
+
const mockId = '123';
|
|
25
|
+
const mockText = 'Failed message';
|
|
26
|
+
const mockOnPressRefresh = jest.fn();
|
|
27
|
+
const mockOnPressDelete = jest.fn();
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should render the component correctly', () => {
|
|
34
|
+
const {getByText} = render(
|
|
35
|
+
<FailedTextBubble
|
|
36
|
+
id={mockId}
|
|
37
|
+
text={mockText}
|
|
38
|
+
onPressRefresh={mockOnPressRefresh}
|
|
39
|
+
onPressDelete={mockOnPressDelete}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(getByText(mockText)).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should call onPressRefresh when the refresh button is pressed', () => {
|
|
47
|
+
const {getByTestId} = render(
|
|
48
|
+
<FailedTextBubble
|
|
49
|
+
id={mockId}
|
|
50
|
+
text={mockText}
|
|
51
|
+
onPressRefresh={mockOnPressRefresh}
|
|
52
|
+
onPressDelete={mockOnPressDelete}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
fireEvent.press(getByTestId('refresh-button'));
|
|
57
|
+
|
|
58
|
+
expect(mockOnPressRefresh).toHaveBeenCalledWith(mockId);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should call onPressDelete when the delete button is pressed', () => {
|
|
62
|
+
const {getByTestId} = render(
|
|
63
|
+
<FailedTextBubble
|
|
64
|
+
id={mockId}
|
|
65
|
+
text={mockText}
|
|
66
|
+
onPressRefresh={mockOnPressRefresh}
|
|
67
|
+
onPressDelete={mockOnPressDelete}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
fireEvent.press(getByTestId('delete-button'));
|
|
72
|
+
|
|
73
|
+
expect(mockOnPressDelete).toHaveBeenCalledWith(mockId);
|
|
74
|
+
});
|
|
75
|
+
});
|