@tactics/toddle-styleguide 1.2.6 → 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.
Files changed (33) hide show
  1. package/App.tsx +8 -0
  2. package/package.json +1 -1
  3. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
  4. package/src/components/atoms/quick-message/__snapshots__/quick-message.test.js.snap +72 -0
  5. package/src/components/atoms/quick-message/quick-message.component.d.ts +7 -0
  6. package/src/components/atoms/quick-message/quick-message.component.tsx +32 -0
  7. package/src/components/atoms/quick-message/quick-message.preview.d.ts +1 -0
  8. package/src/components/atoms/quick-message/quick-message.preview.tsx +33 -0
  9. package/src/components/atoms/quick-message/quick-message.styles.d.ts +14 -0
  10. package/src/components/atoms/quick-message/quick-message.styles.js +18 -0
  11. package/src/components/atoms/quick-message/quick-message.test.js +26 -0
  12. package/src/components/molecules/button/__snapshots__/button.test.js.snap +72 -0
  13. package/src/components/molecules/button/button.component.d.ts +1 -1
  14. package/src/components/molecules/button/button.component.tsx +8 -15
  15. package/src/components/molecules/button/button.preview.tsx +5 -0
  16. package/src/components/molecules/button/button.test.js +6 -0
  17. package/src/components/molecules/failed-to-send/__snapshots__/failed-bubble.test.js.snap +2 -0
  18. package/src/components/molecules/failed-to-send/failed-bubble.component.d.ts +4 -3
  19. package/src/components/molecules/failed-to-send/failed-bubble.component.tsx +6 -4
  20. package/src/components/molecules/failed-to-send/failed-bubble.test.js +56 -0
  21. package/src/components/molecules/send-bubble/__snapshots__/send-text-bubble.test.js.snap +12 -0
  22. package/src/components/molecules/send-bubble/send-text-bubble.component.d.ts +4 -3
  23. package/src/components/molecules/send-bubble/send-text-bubble.component.tsx +17 -6
  24. package/src/components/molecules/send-bubble/send-text-bubble.test.js +71 -0
  25. package/src/components/molecules/tag/tag.component.d.ts +3 -2
  26. package/src/components/organisms/day-select/day-select.component.tsx +5 -1
  27. package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +21 -0
  28. package/src/components/organisms/text-bubble/text-bubble.component.d.ts +5 -4
  29. package/src/components/organisms/text-bubble/text-bubble.component.tsx +15 -5
  30. package/src/components/organisms/text-bubble/text-bubble.preview.tsx +6 -1
  31. package/src/components/organisms/text-bubble/text-bubble.styles.d.ts +30 -44
  32. package/src/components/organisms/text-bubble/text-bubble.styles.js +2 -0
  33. package/src/components/organisms/text-bubble/text-bubble.test.js +7 -0
@@ -110,6 +110,7 @@ exports[`Failed text bubble test shows a DEFAULT RECEIVED text bubble that is sw
110
110
  onResponderTerminate={[Function]}
111
111
  onResponderTerminationRequest={[Function]}
112
112
  onStartShouldSetResponder={[Function]}
113
+ testID="edit-button"
113
114
  >
114
115
  <RNSVGSvgView
115
116
  align="xMidYMid"
@@ -210,6 +211,7 @@ exports[`Failed text bubble test shows a DEFAULT RECEIVED text bubble that is sw
210
211
  onResponderTerminate={[Function]}
211
212
  onResponderTerminationRequest={[Function]}
212
213
  onStartShouldSetResponder={[Function]}
214
+ testID="delete-button"
213
215
  >
214
216
  <RNSVGSvgView
215
217
  align="xMidYMid"
@@ -440,6 +442,7 @@ exports[`Failed text bubble test shows a DEFAULT SENT text bubble that is swipea
440
442
  onResponderTerminate={[Function]}
441
443
  onResponderTerminationRequest={[Function]}
442
444
  onStartShouldSetResponder={[Function]}
445
+ testID="edit-button"
443
446
  >
444
447
  <RNSVGSvgView
445
448
  align="xMidYMid"
@@ -540,6 +543,7 @@ exports[`Failed text bubble test shows a DEFAULT SENT text bubble that is swipea
540
543
  onResponderTerminate={[Function]}
541
544
  onResponderTerminationRequest={[Function]}
542
545
  onStartShouldSetResponder={[Function]}
546
+ testID="delete-button"
543
547
  >
544
548
  <RNSVGSvgView
545
549
  align="xMidYMid"
@@ -770,6 +774,7 @@ exports[`Failed text bubble test shows a WARNING RECEIVED text bubble that is sw
770
774
  onResponderTerminate={[Function]}
771
775
  onResponderTerminationRequest={[Function]}
772
776
  onStartShouldSetResponder={[Function]}
777
+ testID="edit-button"
773
778
  >
774
779
  <RNSVGSvgView
775
780
  align="xMidYMid"
@@ -870,6 +875,7 @@ exports[`Failed text bubble test shows a WARNING RECEIVED text bubble that is sw
870
875
  onResponderTerminate={[Function]}
871
876
  onResponderTerminationRequest={[Function]}
872
877
  onStartShouldSetResponder={[Function]}
878
+ testID="delete-button"
873
879
  >
874
880
  <RNSVGSvgView
875
881
  align="xMidYMid"
@@ -1100,6 +1106,7 @@ exports[`Failed text bubble test shows a WARNING SENT text bubble that is swipea
1100
1106
  onResponderTerminate={[Function]}
1101
1107
  onResponderTerminationRequest={[Function]}
1102
1108
  onStartShouldSetResponder={[Function]}
1109
+ testID="edit-button"
1103
1110
  >
1104
1111
  <RNSVGSvgView
1105
1112
  align="xMidYMid"
@@ -1200,6 +1207,7 @@ exports[`Failed text bubble test shows a WARNING SENT text bubble that is swipea
1200
1207
  onResponderTerminate={[Function]}
1201
1208
  onResponderTerminationRequest={[Function]}
1202
1209
  onStartShouldSetResponder={[Function]}
1210
+ testID="delete-button"
1203
1211
  >
1204
1212
  <RNSVGSvgView
1205
1213
  align="xMidYMid"
@@ -1430,6 +1438,7 @@ exports[`Failed text bubble test shows an ERROR RECEIVED text bubble that is swi
1430
1438
  onResponderTerminate={[Function]}
1431
1439
  onResponderTerminationRequest={[Function]}
1432
1440
  onStartShouldSetResponder={[Function]}
1441
+ testID="edit-button"
1433
1442
  >
1434
1443
  <RNSVGSvgView
1435
1444
  align="xMidYMid"
@@ -1530,6 +1539,7 @@ exports[`Failed text bubble test shows an ERROR RECEIVED text bubble that is swi
1530
1539
  onResponderTerminate={[Function]}
1531
1540
  onResponderTerminationRequest={[Function]}
1532
1541
  onStartShouldSetResponder={[Function]}
1542
+ testID="delete-button"
1533
1543
  >
1534
1544
  <RNSVGSvgView
1535
1545
  align="xMidYMid"
@@ -1760,6 +1770,7 @@ exports[`Failed text bubble test shows an ERROR SENT text bubble that is swipeab
1760
1770
  onResponderTerminate={[Function]}
1761
1771
  onResponderTerminationRequest={[Function]}
1762
1772
  onStartShouldSetResponder={[Function]}
1773
+ testID="edit-button"
1763
1774
  >
1764
1775
  <RNSVGSvgView
1765
1776
  align="xMidYMid"
@@ -1860,6 +1871,7 @@ exports[`Failed text bubble test shows an ERROR SENT text bubble that is swipeab
1860
1871
  onResponderTerminate={[Function]}
1861
1872
  onResponderTerminationRequest={[Function]}
1862
1873
  onStartShouldSetResponder={[Function]}
1874
+ testID="delete-button"
1863
1875
  >
1864
1876
  <RNSVGSvgView
1865
1877
  align="xMidYMid"
@@ -1,11 +1,12 @@
1
1
  import { BubbleAlignment } from '../../../types/bubble-alignment.enum';
2
2
  import { VisualState } from '../../../types/visual-state.enum';
3
3
  type FailedBubbleProps = {
4
+ id: string;
4
5
  text: string;
5
6
  visualState: VisualState;
6
7
  bubbleAlignment: BubbleAlignment;
7
- onPressEdit: () => void;
8
- onPressDelete: () => void;
8
+ onPressEdit: (id: string) => void;
9
+ onPressDelete: (id: string) => void;
9
10
  };
10
- declare const SendTextBubble: ({ text, visualState, bubbleAlignment, onPressEdit, onPressDelete, }: FailedBubbleProps) => JSX.Element;
11
+ declare const SendTextBubble: ({ id, text, visualState, bubbleAlignment, onPressEdit, onPressDelete, }: FailedBubbleProps) => JSX.Element;
11
12
  export { SendTextBubble };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {useContext} from 'react';
2
+ import {useContext, useEffect, useRef} from 'react';
3
3
 
4
4
  import {Animated, Pressable, View} from 'react-native';
5
5
  import {ThemeCtx} from '../../../context/theme.context';
@@ -12,14 +12,16 @@ import {VisualState} from '../../../types/visual-state.enum';
12
12
  import {SmallText} from '../../atoms/paragraph-components';
13
13
 
14
14
  type FailedBubbleProps = {
15
+ id: string;
15
16
  text: string;
16
17
  visualState: VisualState;
17
18
  bubbleAlignment: BubbleAlignment;
18
- onPressEdit: () => void;
19
- onPressDelete: () => void;
19
+ onPressEdit: (id: string) => void;
20
+ onPressDelete: (id: string) => void;
20
21
  };
21
22
 
22
23
  const SendTextBubble = ({
24
+ id,
23
25
  text,
24
26
  visualState,
25
27
  bubbleAlignment,
@@ -29,6 +31,12 @@ const SendTextBubble = ({
29
31
  const context = useContext(ThemeCtx);
30
32
  const styles = Stylesheet(context, visualState, bubbleAlignment);
31
33
 
34
+ const swipeableRef = useRef<Swipeable>(null);
35
+
36
+ useEffect(() => {
37
+ swipeableRef.current?.close();
38
+ }, [text]);
39
+
32
40
  function iconColorCheck() {
33
41
  return visualState === VisualState.DEFAULT
34
42
  ? context.colors.main['0']
@@ -59,12 +67,12 @@ const SendTextBubble = ({
59
67
  return (
60
68
  <View style={styles.swipedRow}>
61
69
  <Animated.View style={[styles.swipedIcon, {opacity}]}>
62
- <Pressable onPress={onPressEdit}>
70
+ <Pressable onPress={() => onPressEdit(id)} testID="edit-button">
63
71
  <Icon style={'regular'} name={'pencil'} color={iconColorCheck()} />
64
72
  </Pressable>
65
73
  </Animated.View>
66
74
  <Animated.View style={[styles.swipedIcon, {opacity}]}>
67
- <Pressable onPress={onPressDelete}>
75
+ <Pressable onPress={() => onPressDelete(id)} testID="delete-button">
68
76
  <Icon style={'regular'} name={'trash'} color={iconColorCheck()} />
69
77
  </Pressable>
70
78
  </Animated.View>
@@ -75,7 +83,10 @@ const SendTextBubble = ({
75
83
  return (
76
84
  <GestureHandlerRootView>
77
85
  <View style={styles.textBubbleContainer}>
78
- <Swipeable renderRightActions={RenderEditDeleteAction}>
86
+ <Swipeable
87
+ ref={swipeableRef}
88
+ renderRightActions={RenderEditDeleteAction}
89
+ >
79
90
  <SmallText
80
91
  textColor={textColorCheck(visualState)}
81
92
  addStyle={styles.text}
@@ -1,12 +1,16 @@
1
1
  import React from 'react';
2
2
  import renderer from 'react-test-renderer';
3
3
  import {SendTextBubble} from './send-text-bubble.component';
4
+ import {fireEvent, render} from '@testing-library/react-native';
5
+ import {VisualState} from '../../../types/visual-state.enum';
6
+ import {BubbleAlignment} from '../../../types/bubble-alignment.enum';
4
7
 
5
8
  describe('Failed text bubble test', () => {
6
9
  it('shows a DEFAULT SENT text bubble that is swipeable with edit and trash icon, which if we press them we can edit or delete the message', () => {
7
10
  const tree = renderer
8
11
  .create(
9
12
  <SendTextBubble
13
+ id={'1'}
10
14
  text={'This is a test'}
11
15
  visualState="DEFAULT"
12
16
  bubbleAlignment="SENT"
@@ -22,6 +26,7 @@ describe('Failed text bubble test', () => {
22
26
  const tree = renderer
23
27
  .create(
24
28
  <SendTextBubble
29
+ id={'2'}
25
30
  text={'This is a test'}
26
31
  visualState="DEFAULT"
27
32
  bubbleAlignment="RECEIVE"
@@ -37,6 +42,7 @@ describe('Failed text bubble test', () => {
37
42
  const tree = renderer
38
43
  .create(
39
44
  <SendTextBubble
45
+ id={'3'}
40
46
  text={'This is a test'}
41
47
  visualState="WARNING"
42
48
  bubbleAlignment="SENT"
@@ -52,6 +58,7 @@ describe('Failed text bubble test', () => {
52
58
  const tree = renderer
53
59
  .create(
54
60
  <SendTextBubble
61
+ id={'4'}
55
62
  text={'This is a test'}
56
63
  visualState="WARNING"
57
64
  bubbleAlignment="RECEIVE"
@@ -67,6 +74,7 @@ describe('Failed text bubble test', () => {
67
74
  const tree = renderer
68
75
  .create(
69
76
  <SendTextBubble
77
+ id={'4'}
70
78
  text={'This is a test'}
71
79
  visualState="ERROR"
72
80
  bubbleAlignment="SENT"
@@ -82,6 +90,7 @@ describe('Failed text bubble test', () => {
82
90
  const tree = renderer
83
91
  .create(
84
92
  <SendTextBubble
93
+ id={'5'}
85
94
  text={'This is a test'}
86
95
  visualState="ERROR"
87
96
  bubbleAlignment="RECEIVE"
@@ -94,3 +103,65 @@ describe('Failed text bubble test', () => {
94
103
  expect(tree).toMatchSnapshot();
95
104
  });
96
105
  });
106
+
107
+ describe('SendTextBubble', () => {
108
+ const mockId = '123';
109
+ const mockText = 'Hello, world!';
110
+ const mockVisualState = VisualState.DEFAULT;
111
+ const mockBubbleAlignment = BubbleAlignment.SENT;
112
+ const mockOnPressEdit = jest.fn();
113
+ const mockOnPressDelete = jest.fn();
114
+
115
+ afterEach(() => {
116
+ jest.clearAllMocks();
117
+ });
118
+
119
+ it('should render the component correctly', () => {
120
+ const {getByText} = render(
121
+ <SendTextBubble
122
+ id={mockId}
123
+ text={mockText}
124
+ visualState={mockVisualState}
125
+ bubbleAlignment={mockBubbleAlignment}
126
+ onPressEdit={mockOnPressEdit}
127
+ onPressDelete={mockOnPressDelete}
128
+ />
129
+ );
130
+
131
+ expect(getByText(mockText)).toBeDefined();
132
+ });
133
+
134
+ it('should call onPressEdit when the edit button is pressed', () => {
135
+ const {getByTestId} = render(
136
+ <SendTextBubble
137
+ id={mockId}
138
+ text={mockText}
139
+ visualState={mockVisualState}
140
+ bubbleAlignment={mockBubbleAlignment}
141
+ onPressEdit={mockOnPressEdit}
142
+ onPressDelete={mockOnPressDelete}
143
+ />
144
+ );
145
+
146
+ fireEvent.press(getByTestId('edit-button'));
147
+
148
+ expect(mockOnPressEdit).toHaveBeenCalledWith(mockId);
149
+ });
150
+
151
+ it('should call onPressDelete when the delete button is pressed', () => {
152
+ const {getByTestId} = render(
153
+ <SendTextBubble
154
+ id={mockId}
155
+ text={mockText}
156
+ visualState={mockVisualState}
157
+ bubbleAlignment={mockBubbleAlignment}
158
+ onPressEdit={mockOnPressEdit}
159
+ onPressDelete={mockOnPressDelete}
160
+ />
161
+ );
162
+
163
+ fireEvent.press(getByTestId('delete-button'));
164
+
165
+ expect(mockOnPressDelete).toHaveBeenCalledWith(mockId);
166
+ });
167
+ });
@@ -1,7 +1,8 @@
1
1
  type TagProps = {
2
2
  value: string;
3
3
  label: string;
4
- onPress: (event: string) => void;
4
+ onPress: (value: string, isSelected: boolean) => void;
5
+ isSelected: boolean;
5
6
  };
6
- declare const Tag: ({ label, onPress, value }: TagProps) => JSX.Element;
7
+ declare const Tag: ({ label, onPress, value, isSelected }: TagProps) => JSX.Element;
7
8
  export { Tag as Tag };
@@ -1,4 +1,4 @@
1
- import React, {useContext, useState} from 'react';
1
+ import React, {useContext, useEffect, useState} from 'react';
2
2
  import {
3
3
  Directions,
4
4
  Gesture,
@@ -34,6 +34,10 @@ const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
34
34
  createWeekDays(startDate.startOf('week'))
35
35
  );
36
36
 
37
+ useEffect(() => {
38
+ setWeekData(createWeekDays(startDate.startOf('week')));
39
+ }, [startDate]);
40
+
37
41
  const onSwipeLeft = () => {
38
42
  let firstDayOfWeek = weekData.shift();
39
43
  if (!firstDayOfWeek) return;
@@ -15,6 +15,7 @@ exports[`test text-bubble given the bubbleAlignment is SENT return a text-bubble
15
15
  [
16
16
  {
17
17
  "maxWidth": "80%",
18
+ "minWidth": "50%",
18
19
  },
19
20
  {
20
21
  "alignSelf": "flex-end",
@@ -131,6 +132,7 @@ exports[`test text-bubble given the bubbleAlignment is SENT return a text-bubble
131
132
  onResponderTerminate={[Function]}
132
133
  onResponderTerminationRequest={[Function]}
133
134
  onStartShouldSetResponder={[Function]}
135
+ testID="edit-button"
134
136
  >
135
137
  <RNSVGSvgView
136
138
  align="xMidYMid"
@@ -231,6 +233,7 @@ exports[`test text-bubble given the bubbleAlignment is SENT return a text-bubble
231
233
  onResponderTerminate={[Function]}
232
234
  onResponderTerminationRequest={[Function]}
233
235
  onStartShouldSetResponder={[Function]}
236
+ testID="delete-button"
234
237
  >
235
238
  <RNSVGSvgView
236
239
  align="xMidYMid"
@@ -404,6 +407,7 @@ exports[`test text-bubble given the visualState is DEFAULT return a light-blue c
404
407
  [
405
408
  {
406
409
  "maxWidth": "80%",
410
+ "minWidth": "50%",
407
411
  },
408
412
  {
409
413
  "alignSelf": "flex-end",
@@ -520,6 +524,7 @@ exports[`test text-bubble given the visualState is DEFAULT return a light-blue c
520
524
  onResponderTerminate={[Function]}
521
525
  onResponderTerminationRequest={[Function]}
522
526
  onStartShouldSetResponder={[Function]}
527
+ testID="edit-button"
523
528
  >
524
529
  <RNSVGSvgView
525
530
  align="xMidYMid"
@@ -620,6 +625,7 @@ exports[`test text-bubble given the visualState is DEFAULT return a light-blue c
620
625
  onResponderTerminate={[Function]}
621
626
  onResponderTerminationRequest={[Function]}
622
627
  onStartShouldSetResponder={[Function]}
628
+ testID="delete-button"
623
629
  >
624
630
  <RNSVGSvgView
625
631
  align="xMidYMid"
@@ -793,6 +799,7 @@ exports[`test text-bubble given the visualState is ERROR return a red colored te
793
799
  [
794
800
  {
795
801
  "maxWidth": "80%",
802
+ "minWidth": "50%",
796
803
  },
797
804
  {
798
805
  "alignSelf": "flex-end",
@@ -909,6 +916,7 @@ exports[`test text-bubble given the visualState is ERROR return a red colored te
909
916
  onResponderTerminate={[Function]}
910
917
  onResponderTerminationRequest={[Function]}
911
918
  onStartShouldSetResponder={[Function]}
919
+ testID="edit-button"
912
920
  >
913
921
  <RNSVGSvgView
914
922
  align="xMidYMid"
@@ -1009,6 +1017,7 @@ exports[`test text-bubble given the visualState is ERROR return a red colored te
1009
1017
  onResponderTerminate={[Function]}
1010
1018
  onResponderTerminationRequest={[Function]}
1011
1019
  onStartShouldSetResponder={[Function]}
1020
+ testID="delete-button"
1012
1021
  >
1013
1022
  <RNSVGSvgView
1014
1023
  align="xMidYMid"
@@ -1182,6 +1191,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a text-bubble
1182
1191
  [
1183
1192
  {
1184
1193
  "maxWidth": "80%",
1194
+ "minWidth": "50%",
1185
1195
  },
1186
1196
  false,
1187
1197
  ]
@@ -1296,6 +1306,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a text-bubble
1296
1306
  onResponderTerminate={[Function]}
1297
1307
  onResponderTerminationRequest={[Function]}
1298
1308
  onStartShouldSetResponder={[Function]}
1309
+ testID="edit-button"
1299
1310
  >
1300
1311
  <RNSVGSvgView
1301
1312
  align="xMidYMid"
@@ -1396,6 +1407,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a text-bubble
1396
1407
  onResponderTerminate={[Function]}
1397
1408
  onResponderTerminationRequest={[Function]}
1398
1409
  onStartShouldSetResponder={[Function]}
1410
+ testID="delete-button"
1399
1411
  >
1400
1412
  <RNSVGSvgView
1401
1413
  align="xMidYMid"
@@ -1567,6 +1579,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a textBubble w
1567
1579
  [
1568
1580
  {
1569
1581
  "maxWidth": "80%",
1582
+ "minWidth": "50%",
1570
1583
  },
1571
1584
  false,
1572
1585
  ]
@@ -1681,6 +1694,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a textBubble w
1681
1694
  onResponderTerminate={[Function]}
1682
1695
  onResponderTerminationRequest={[Function]}
1683
1696
  onStartShouldSetResponder={[Function]}
1697
+ testID="edit-button"
1684
1698
  >
1685
1699
  <RNSVGSvgView
1686
1700
  align="xMidYMid"
@@ -1781,6 +1795,7 @@ exports[`test text-bubble given the visualState is RECEIVE return a textBubble w
1781
1795
  onResponderTerminate={[Function]}
1782
1796
  onResponderTerminationRequest={[Function]}
1783
1797
  onStartShouldSetResponder={[Function]}
1798
+ testID="delete-button"
1784
1799
  >
1785
1800
  <RNSVGSvgView
1786
1801
  align="xMidYMid"
@@ -1952,6 +1967,7 @@ exports[`test text-bubble given the visualState is WARNING return an orange colo
1952
1967
  [
1953
1968
  {
1954
1969
  "maxWidth": "80%",
1970
+ "minWidth": "50%",
1955
1971
  },
1956
1972
  {
1957
1973
  "alignSelf": "flex-end",
@@ -2068,6 +2084,7 @@ exports[`test text-bubble given the visualState is WARNING return an orange colo
2068
2084
  onResponderTerminate={[Function]}
2069
2085
  onResponderTerminationRequest={[Function]}
2070
2086
  onStartShouldSetResponder={[Function]}
2087
+ testID="edit-button"
2071
2088
  >
2072
2089
  <RNSVGSvgView
2073
2090
  align="xMidYMid"
@@ -2168,6 +2185,7 @@ exports[`test text-bubble given the visualState is WARNING return an orange colo
2168
2185
  onResponderTerminate={[Function]}
2169
2186
  onResponderTerminationRequest={[Function]}
2170
2187
  onStartShouldSetResponder={[Function]}
2188
+ testID="delete-button"
2171
2189
  >
2172
2190
  <RNSVGSvgView
2173
2191
  align="xMidYMid"
@@ -2341,6 +2359,7 @@ exports[`test text-bubble return a text bubble, that will be send, but does not
2341
2359
  [
2342
2360
  {
2343
2361
  "maxWidth": "80%",
2362
+ "minWidth": "50%",
2344
2363
  },
2345
2364
  {
2346
2365
  "alignSelf": "flex-end",
@@ -2521,6 +2540,7 @@ exports[`test text-bubble return a text bubble, that will be send, but does not
2521
2540
  onResponderTerminate={[Function]}
2522
2541
  onResponderTerminationRequest={[Function]}
2523
2542
  onStartShouldSetResponder={[Function]}
2543
+ testID="refresh-button"
2524
2544
  >
2525
2545
  <RNSVGSvgView
2526
2546
  align="xMidYMid"
@@ -2621,6 +2641,7 @@ exports[`test text-bubble return a text bubble, that will be send, but does not
2621
2641
  onResponderTerminate={[Function]}
2622
2642
  onResponderTerminationRequest={[Function]}
2623
2643
  onStartShouldSetResponder={[Function]}
2644
+ testID="delete-button"
2624
2645
  >
2625
2646
  <RNSVGSvgView
2626
2647
  align="xMidYMid"
@@ -2,14 +2,15 @@ import { VisualState } from '../../../types/visual-state.enum';
2
2
  import { BubbleAlignment } from '../../../types/bubble-alignment.enum';
3
3
  import { ToddleDateTime } from '../../../utilities/toddle-datetime/toddle-datetime.class';
4
4
  type TextBubbleProps = {
5
+ id: string;
5
6
  text: string;
6
7
  visualState: VisualState;
7
8
  bubbleAlignment: BubbleAlignment;
8
9
  timestamp: ToddleDateTime;
9
10
  send: boolean;
10
- onFail: () => void;
11
- onEdit: () => void;
12
- onDelete: () => void;
11
+ onFail: (id: string) => void;
12
+ onEdit: (id: string) => void;
13
+ onDelete: (id: string) => void;
13
14
  };
14
- declare const TextBubble: ({ text, visualState, bubbleAlignment, timestamp, send, onFail, onEdit, onDelete, }: TextBubbleProps) => JSX.Element;
15
+ declare const TextBubble: ({ id, text, visualState, bubbleAlignment, timestamp, send, onFail, onEdit, onDelete, }: TextBubbleProps) => JSX.Element;
15
16
  export { TextBubble as TextBubble };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {useContext} from 'react';
2
+ import {useContext, useEffect, useState} from 'react';
3
3
 
4
4
  import {View} from 'react-native';
5
5
  import {ThemeCtx} from '../../../context/theme.context';
@@ -13,17 +13,19 @@ import {FailedTextBubble} from '../../molecules/failed-to-send/failed-bubble.com
13
13
  import {SendTextBubble} from '../../molecules/send-bubble/send-text-bubble.component';
14
14
 
15
15
  type TextBubbleProps = {
16
+ id: string;
16
17
  text: string;
17
18
  visualState: VisualState;
18
19
  bubbleAlignment: BubbleAlignment;
19
20
  timestamp: ToddleDateTime;
20
21
  send: boolean;
21
- onFail: () => void;
22
- onEdit: () => void;
23
- onDelete: () => void;
22
+ onFail: (id: string) => void;
23
+ onEdit: (id: string) => void;
24
+ onDelete: (id: string) => void;
24
25
  };
25
26
 
26
27
  const TextBubble = ({
28
+ id,
27
29
  text,
28
30
  visualState,
29
31
  bubbleAlignment,
@@ -36,13 +38,20 @@ const TextBubble = ({
36
38
  const context = useContext(ThemeCtx);
37
39
  const styles = Stylesheet(context, bubbleAlignment);
38
40
 
41
+ const [internalVisualState, setInternalVisualState] = useState(visualState);
42
+
43
+ useEffect(() => {
44
+ setInternalVisualState(visualState);
45
+ }, [visualState]);
46
+
39
47
  return (
40
48
  <View style={styles.rootContainer}>
41
49
  {send ? (
42
50
  <View style={styles.textBubbleRootContainer}>
43
51
  <SendTextBubble
52
+ id={id}
44
53
  text={text}
45
- visualState={visualState}
54
+ visualState={internalVisualState}
46
55
  bubbleAlignment={bubbleAlignment}
47
56
  onPressEdit={onEdit}
48
57
  onPressDelete={onDelete}
@@ -51,6 +60,7 @@ const TextBubble = ({
51
60
  ) : (
52
61
  <View style={styles.failedBubbleRootContainer}>
53
62
  <FailedTextBubble
63
+ id={id}
54
64
  text={text}
55
65
  onPressRefresh={onFail}
56
66
  onPressDelete={onDelete}
@@ -12,13 +12,13 @@ export const TextBubblePreview = ({}: {}) => {
12
12
  return (
13
13
  <View
14
14
  style={{
15
- flex: 1,
16
15
  justifyContent: 'flex-start',
17
16
  alignItems: 'stretch',
18
17
  padding: 16,
19
18
  }}
20
19
  >
21
20
  <TextBubble
21
+ id={'1'}
22
22
  text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam suscipit velit in nibh varius, quis accumsan tellus maximus."
23
23
  bubbleAlignment={BubbleAlignment.SENT}
24
24
  visualState={VisualState.DEFAULT}
@@ -29,6 +29,7 @@ export const TextBubblePreview = ({}: {}) => {
29
29
  onDelete={() => alert('Delete the message')}
30
30
  />
31
31
  <TextBubble
32
+ id={'2'}
32
33
  text="Test."
33
34
  bubbleAlignment={BubbleAlignment.RECEIVE}
34
35
  visualState={VisualState.WARNING}
@@ -39,6 +40,7 @@ export const TextBubblePreview = ({}: {}) => {
39
40
  onDelete={() => alert('Delete the message')}
40
41
  />
41
42
  <TextBubble
43
+ id={'3'}
42
44
  text={`"I don't like sand... it's rough, and course, and irritating, and it gets everywhere."`}
43
45
  bubbleAlignment={BubbleAlignment.RECEIVE}
44
46
  visualState={VisualState.DEFAULT}
@@ -49,6 +51,7 @@ export const TextBubblePreview = ({}: {}) => {
49
51
  onDelete={() => alert('Delete the message')}
50
52
  />
51
53
  <TextBubble
54
+ id={'4'}
52
55
  text="Error!"
53
56
  bubbleAlignment={BubbleAlignment.SENT}
54
57
  visualState={VisualState.ERROR}
@@ -59,6 +62,7 @@ export const TextBubblePreview = ({}: {}) => {
59
62
  onDelete={() => alert('Delete the message')}
60
63
  />
61
64
  <TextBubble
65
+ id={'5'}
62
66
  text="Niet verzonden! Probeer het opnieuw aub! Swipe en refresh!"
63
67
  bubbleAlignment={BubbleAlignment.SENT}
64
68
  visualState={VisualState.ERROR}
@@ -69,6 +73,7 @@ export const TextBubblePreview = ({}: {}) => {
69
73
  onDelete={() => alert('Delete the message')}
70
74
  />
71
75
  <TextBubble
76
+ id={'6'}
72
77
  text="We hebben uw betaling van vorige maand nog niet ontvangen!"
73
78
  bubbleAlignment={BubbleAlignment.RECEIVE}
74
79
  visualState={VisualState.ERROR}