@tactics/toddle-styleguide 1.2.4 → 1.2.5

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 (51) hide show
  1. package/App.tsx +8 -0
  2. package/index.d.ts +2 -1
  3. package/index.tsx +2 -0
  4. package/package.json +2 -2
  5. package/src/components/atoms/backdrop/backdrop.component.d.ts +2 -1
  6. package/src/components/atoms/backdrop/backdrop.component.tsx +8 -2
  7. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
  8. package/src/components/atoms/text-input/text-input.component.d.ts +4 -5
  9. package/src/components/atoms/text-input/text-input.component.tsx +9 -13
  10. package/src/components/atoms/text-input/text-input.preview.tsx +5 -5
  11. package/src/components/atoms/text-input/text-input.test.js +4 -4
  12. package/src/components/molecules/button/__snapshots__/button.test.js.snap +144 -0
  13. package/src/components/molecules/button/button.component.d.ts +6 -4
  14. package/src/components/molecules/button/button.component.tsx +30 -9
  15. package/src/components/molecules/button/button.preview.tsx +16 -1
  16. package/src/components/molecules/button/button.styles.d.ts +13 -16
  17. package/src/components/molecules/button/button.styles.js +2 -4
  18. package/src/components/molecules/button/button.test.js +12 -0
  19. package/src/components/molecules/message-input/__snapshots__/message-input.test.js.snap +4 -0
  20. package/src/components/molecules/message-input/message-input.component.d.ts +4 -6
  21. package/src/components/molecules/message-input/message-input.component.tsx +10 -12
  22. package/src/components/molecules/message-input/message-input.preview.tsx +28 -15
  23. package/src/components/molecules/password-input/password-input.component.d.ts +4 -6
  24. package/src/components/molecules/password-input/password-input.component.tsx +11 -15
  25. package/src/components/molecules/swipe/__snapshots__/swipe.test.js.snap +263 -420
  26. package/src/components/molecules/swipe/swipe.component.d.ts +4 -4
  27. package/src/components/molecules/swipe/swipe.component.tsx +47 -20
  28. package/src/components/molecules/swipe/swipe.preview.tsx +111 -51
  29. package/src/components/molecules/swipe/swipe.styles.d.ts +28 -0
  30. package/src/components/molecules/swipe/swipe.styles.js +32 -0
  31. package/src/components/molecules/swipe/swipe.test.js +1 -1
  32. package/src/components/molecules/tag/__snapshots__/tag.test.js.snap +10 -10
  33. package/src/components/molecules/tag/tag.component.d.ts +3 -8
  34. package/src/components/molecules/tag/tag.component.tsx +7 -13
  35. package/src/components/molecules/tag/tag.preview.tsx +22 -19
  36. package/src/components/molecules/tag/tag.styles.js +4 -2
  37. package/src/components/molecules/tag/tag.test.js +10 -2
  38. package/src/components/molecules/timestamp/__snapshots__/timestamp.test.js.snap +1 -1
  39. package/src/components/molecules/timestamp/timestamp.component.tsx +0 -2
  40. package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +7 -7
  41. package/src/components/templates/modal/modal.component.tsx +0 -1
  42. package/src/components/templates/popover-action/popover-action.component.d.ts +8 -0
  43. package/src/components/templates/popover-action/popover-action.component.tsx +119 -0
  44. package/src/components/templates/popover-action/popover-action.preview.d.ts +1 -0
  45. package/src/components/templates/popover-action/popover-action.preview.tsx +142 -0
  46. package/src/components/templates/popover-action/popover-action.styles.d.ts +26 -0
  47. package/src/components/templates/popover-action/popover-action.styles.js +31 -0
  48. package/src/utilities/toddle-datetime/toddle-datetime.class.d.ts +4 -0
  49. package/src/utilities/toddle-datetime/toddle-datetime.class.tsx +16 -0
  50. package/src/components/molecules/swipe/Swipe.styles.d.ts +0 -7
  51. package/src/components/molecules/swipe/Swipe.styles.js +0 -10
package/App.tsx CHANGED
@@ -68,6 +68,7 @@ import {ToddleDateTimePreview} from './src/utilities/toddle-datetime/toddle-date
68
68
  import {BackgroundGradientPreview} from './src/components/atoms/background-gradient/background-gradient.preview';
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
+ import {PopOverActionPreview} from './src/components/templates/popover-action/popover-action.preview';
71
72
 
72
73
  const Stack = createNativeStackNavigator();
73
74
 
@@ -208,6 +209,10 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
208
209
  />
209
210
  <ReactBtn title="Pill" onPress={() => navigation.push('pill')} />
210
211
  <ReactBtn title="Popover" onPress={() => navigation.push('popover')} />
212
+ <ReactBtn
213
+ title="Popover Action"
214
+ onPress={() => navigation.push('popover-action')}
215
+ />
211
216
  <ReactBtn
212
217
  title="Pressable Icon"
213
218
  onPress={() => navigation.push('pressable-icon')}
@@ -389,6 +394,9 @@ function App() {
389
394
  <Stack.Screen name="popover" options={{headerShown: false}}>
390
395
  {() => <PopoverPreview />}
391
396
  </Stack.Screen>
397
+ <Stack.Screen name="popover-action" options={{headerShown: false}}>
398
+ {() => <PopOverActionPreview />}
399
+ </Stack.Screen>
392
400
  <Stack.Screen name="pressable-icon">
393
401
  {() => <PressableIconPreview />}
394
402
  </Stack.Screen>
package/index.d.ts CHANGED
@@ -53,6 +53,7 @@ import { WaveBackground } from './src/components/molecules/wave-background/wave.
53
53
  import { BackgroundGradient } from './src/components/atoms/background-gradient/background-gradient.component';
54
54
  import { PersonInfoCard } from './src/components/organisms/person-info-card/person-info-card.component';
55
55
  import { TimePicker } from './src/components/molecules/time-picker/time-picker.component';
56
+ import { PopOverAction } from './src/components/templates/popover-action/popover-action.component';
56
57
  import { BubbleAlignment } from './src/types/bubble-alignment.enum';
57
58
  import { KeyBoardTypes } from './src/types/keyboard-types.enum';
58
59
  import { Size } from './src/types/size.enum';
@@ -62,4 +63,4 @@ import { ToddleDateTime } from './src/utilities/toddle-datetime/toddle-datetime.
62
63
  import { ThemeCtx } from './src/context/theme.context';
63
64
  import { Scale } from './src/theme/scale/index';
64
65
  import CreateResponsiveStyle from './src/theme/responsive/index';
65
- export { Initials, BubbleAlignment, KeyBoardTypes, Size, Scale, CreateResponsiveStyle, VisualState, ThemeCtx, ToddleDateTime, Avatar, Button, CancelLink, Check, Checkbox, ChildListItem, ContactItem, FilterTab, SplitContainer, ImageBubble, Info, Pill, Popover, PressableIcon, QuickFilter, Search, SelectListItem, Snackbar, Tag, TextBubble, TextInput, TimeTracker, WideButton, Icon, Calendar, IncrementInput, Swipe, Logo, DaySelect, BlockedMessage, DepartmentLogo, ContactRole, TimeLine, SelectPicker, CalendarSelect, DateInput, FilterRange, Footer, DefaultSelect, PasswordInput, MessageInput, Heading1, Heading2, Heading3, Heading4, AllCapsHeading, Paragraph, SmallText, TinyText, SelectLink, MyChildListItem, MoreInfoButton, LanguageButton, Modal, LoadingIndicator, WaveBackground, BackgroundGradient, PersonInfoCard, TimePicker, };
66
+ export { Initials, BubbleAlignment, KeyBoardTypes, Size, Scale, CreateResponsiveStyle, VisualState, ThemeCtx, ToddleDateTime, Avatar, Button, CancelLink, Check, Checkbox, ChildListItem, ContactItem, FilterTab, SplitContainer, ImageBubble, Info, Pill, Popover, PressableIcon, QuickFilter, Search, SelectListItem, Snackbar, Tag, TextBubble, TextInput, TimeTracker, WideButton, Icon, Calendar, IncrementInput, Swipe, Logo, DaySelect, BlockedMessage, DepartmentLogo, ContactRole, TimeLine, SelectPicker, CalendarSelect, DateInput, FilterRange, Footer, DefaultSelect, PasswordInput, MessageInput, Heading1, Heading2, Heading3, Heading4, AllCapsHeading, Paragraph, SmallText, TinyText, SelectLink, MyChildListItem, MoreInfoButton, LanguageButton, Modal, LoadingIndicator, WaveBackground, BackgroundGradient, PersonInfoCard, TimePicker, PopOverAction, };
package/index.tsx CHANGED
@@ -71,6 +71,7 @@ import {WaveBackground} from './src/components/molecules/wave-background/wave.co
71
71
  import {BackgroundGradient} from './src/components/atoms/background-gradient/background-gradient.component';
72
72
  import {PersonInfoCard} from './src/components/organisms/person-info-card/person-info-card.component';
73
73
  import {TimePicker} from './src/components/molecules/time-picker/time-picker.component';
74
+ import {PopOverAction} from './src/components/templates/popover-action/popover-action.component';
74
75
 
75
76
  // Exports of enums
76
77
  import {BubbleAlignment} from './src/types/bubble-alignment.enum';
@@ -162,4 +163,5 @@ export {
162
163
  BackgroundGradient,
163
164
  PersonInfoCard,
164
165
  TimePicker,
166
+ PopOverAction,
165
167
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -48,13 +48,13 @@
48
48
  "react-native-calendar-strip": "^2.2.6",
49
49
  "react-native-calendars": "^1.1299.0",
50
50
  "react-native-gesture-handler": "~2.9.0",
51
+ "react-native-pager-view": "6.1.2",
51
52
  "react-native-picker-select": "^8.0.4",
52
53
  "react-native-reanimated": "~2.14.4",
53
54
  "react-native-safe-area-context": "4.5.0",
54
55
  "react-native-screens": "~3.20.0",
55
56
  "react-native-svg": "13.4.0",
56
57
  "react-native-swipe-gestures": "^1.0.5",
57
- "react-native-swiper": "^1.6.0",
58
58
  "react-native-web": "~0.18.10",
59
59
  "react-native-wheel-picker-expo": "^0.5.4",
60
60
  "react-test-renderer": "^18.2.0"
@@ -1,5 +1,6 @@
1
1
  type PopoverBackdropProps = {
2
2
  isVisible: boolean;
3
+ touchBackDrop?: (value: boolean) => void;
3
4
  };
4
- declare const Backdrop: ({ isVisible }: PopoverBackdropProps) => JSX.Element;
5
+ declare const Backdrop: ({ isVisible, touchBackDrop }: PopoverBackdropProps) => JSX.Element;
5
6
  export { Backdrop as Backdrop };
@@ -7,9 +7,10 @@ import {Stylesheet} from './backdrop.styles';
7
7
 
8
8
  type PopoverBackdropProps = {
9
9
  isVisible: boolean;
10
+ touchBackDrop?: (value: boolean) => void;
10
11
  };
11
12
 
12
- const Backdrop = ({isVisible}: PopoverBackdropProps) => {
13
+ const Backdrop = ({isVisible, touchBackDrop}: PopoverBackdropProps) => {
13
14
  const context = useContext(ThemeCtx);
14
15
  const opacity = useMemo(() => new Animated.Value(0), []);
15
16
 
@@ -37,6 +38,11 @@ const Backdrop = ({isVisible}: PopoverBackdropProps) => {
37
38
  close();
38
39
  }
39
40
 
40
- return <Animated.View style={[styles.element, {opacity: opacity}]} />;
41
+ return (
42
+ <Animated.View
43
+ onTouchStart={() => (touchBackDrop ? touchBackDrop(false) : null)}
44
+ style={[styles.element, {opacity: opacity}]}
45
+ />
46
+ );
41
47
  };
42
48
  export {Backdrop as Backdrop};
@@ -1389,7 +1389,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1389
1389
  }
1390
1390
  >
1391
1391
  <View
1392
- accessibilityLabel="today Vrijdag 7 Juli 2023 "
1392
+ accessibilityLabel=" Vrijdag 7 Juli 2023 "
1393
1393
  accessibilityRole="button"
1394
1394
  accessibilityState={
1395
1395
  {
@@ -1421,10 +1421,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1421
1421
  style={
1422
1422
  {
1423
1423
  "alignItems": "center",
1424
- "borderColor": "#7B93DB",
1425
- "borderRadius": 21,
1426
- "borderStyle": "solid",
1427
- "borderWidth": 1,
1428
1424
  "height": 42,
1429
1425
  "justifyContent": "center",
1430
1426
  "opacity": 1,
@@ -1444,9 +1440,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1444
1440
  "lineHeight": 22.4,
1445
1441
  "marginTop": 4,
1446
1442
  },
1447
- {
1448
- "color": "#7B93DB",
1449
- },
1450
1443
  ]
1451
1444
  }
1452
1445
  >
@@ -1811,7 +1804,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1811
1804
  }
1812
1805
  >
1813
1806
  <View
1814
- accessibilityLabel=" Woensdag 12 Juli 2023 "
1807
+ accessibilityLabel="today Woensdag 12 Juli 2023 "
1815
1808
  accessibilityRole="button"
1816
1809
  accessibilityState={
1817
1810
  {
@@ -1843,6 +1836,10 @@ exports[`Test for the calendar component renders a calendar where you can select
1843
1836
  style={
1844
1837
  {
1845
1838
  "alignItems": "center",
1839
+ "borderColor": "#7B93DB",
1840
+ "borderRadius": 21,
1841
+ "borderStyle": "solid",
1842
+ "borderWidth": 1,
1846
1843
  "height": 42,
1847
1844
  "justifyContent": "center",
1848
1845
  "opacity": 1,
@@ -1862,6 +1859,9 @@ exports[`Test for the calendar component renders a calendar where you can select
1862
1859
  "lineHeight": 22.4,
1863
1860
  "marginTop": 4,
1864
1861
  },
1862
+ {
1863
+ "color": "#7B93DB",
1864
+ },
1865
1865
  ]
1866
1866
  }
1867
1867
  >
@@ -5357,8 +5357,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5357
5357
  }
5358
5358
  >
5359
5359
  <View
5360
- accessibilityLabel="today Vrijdag 7 Juli 2023 "
5361
- accessibilityRole="button"
5360
+ accessibilityLabel=" Vrijdag 7 Juli 2023 "
5362
5361
  accessibilityState={
5363
5362
  {
5364
5363
  "busy": undefined,
@@ -5389,10 +5388,6 @@ exports[`Test for the calendar component renders a calendar where you can select
5389
5388
  style={
5390
5389
  {
5391
5390
  "alignItems": "center",
5392
- "borderColor": "#7B93DB",
5393
- "borderRadius": 21,
5394
- "borderStyle": "solid",
5395
- "borderWidth": 1,
5396
5391
  "height": 42,
5397
5392
  "justifyContent": "center",
5398
5393
  "opacity": 1,
@@ -5413,7 +5408,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5413
5408
  "marginTop": 4,
5414
5409
  },
5415
5410
  {
5416
- "color": "#7B93DB",
5411
+ "color": "#9AA5B1",
5417
5412
  },
5418
5413
  ]
5419
5414
  }
@@ -5787,7 +5782,8 @@ exports[`Test for the calendar component renders a calendar where you can select
5787
5782
  }
5788
5783
  >
5789
5784
  <View
5790
- accessibilityLabel=" Woensdag 12 Juli 2023 "
5785
+ accessibilityLabel="today Woensdag 12 Juli 2023 "
5786
+ accessibilityRole="button"
5791
5787
  accessibilityState={
5792
5788
  {
5793
5789
  "busy": undefined,
@@ -5818,6 +5814,10 @@ exports[`Test for the calendar component renders a calendar where you can select
5818
5814
  style={
5819
5815
  {
5820
5816
  "alignItems": "center",
5817
+ "borderColor": "#7B93DB",
5818
+ "borderRadius": 21,
5819
+ "borderStyle": "solid",
5820
+ "borderWidth": 1,
5821
5821
  "height": 42,
5822
5822
  "justifyContent": "center",
5823
5823
  "opacity": 1,
@@ -5838,7 +5838,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5838
5838
  "marginTop": 4,
5839
5839
  },
5840
5840
  {
5841
- "color": "#9AA5B1",
5841
+ "color": "#7B93DB",
5842
5842
  },
5843
5843
  ]
5844
5844
  }
@@ -1,9 +1,8 @@
1
+ import { TextInputProps as NativeTextInputProps } from 'react-native';
1
2
  import { KeyBoardTypes } from '../../../types/keyboard-types.enum';
2
- type TextInputProps = {
3
- placeholder?: string;
4
- onchangeText?: (text: string) => void;
3
+ interface TextInputProps extends NativeTextInputProps {
5
4
  keyboardType: KeyBoardTypes;
6
5
  border?: boolean;
7
- };
8
- declare const TextInput: ({ placeholder, onchangeText, keyboardType, border, }: TextInputProps) => JSX.Element;
6
+ }
7
+ declare const TextInput: ({ keyboardType, border, ...props }: TextInputProps) => JSX.Element;
9
8
  export { TextInput as TextInput };
@@ -1,35 +1,31 @@
1
1
  import * as React from 'react';
2
2
  import {useContext} from 'react';
3
3
 
4
- import {View, TextInput as NativeTextInput} from 'react-native';
4
+ import {
5
+ View,
6
+ TextInput as NativeTextInput,
7
+ TextInputProps as NativeTextInputProps,
8
+ } from 'react-native';
5
9
  import {ThemeCtx} from '../../../context/theme.context';
6
10
  import {Stylesheet} from './text-input.styles';
7
11
  import {KeyBoardTypes} from '../../../types/keyboard-types.enum';
8
12
 
9
- type TextInputProps = {
10
- placeholder?: string;
11
- onchangeText?: (text: string) => void;
13
+ interface TextInputProps extends NativeTextInputProps {
12
14
  keyboardType: KeyBoardTypes;
13
15
  border?: boolean;
14
- };
16
+ }
15
17
 
16
- const TextInput = ({
17
- placeholder,
18
- onchangeText,
19
- keyboardType,
20
- border,
21
- }: TextInputProps) => {
18
+ const TextInput = ({keyboardType, border, ...props}: TextInputProps) => {
22
19
  const context = useContext(ThemeCtx);
23
20
  const styles = Stylesheet(context, border);
24
21
 
25
22
  return (
26
23
  <View style={styles.container}>
27
24
  <NativeTextInput
28
- placeholder={placeholder}
29
25
  placeholderTextColor={context.colors.ui.grey}
30
26
  style={styles.input}
31
- onChangeText={onchangeText}
32
27
  keyboardType={keyboardType}
28
+ {...props}
33
29
  />
34
30
  </View>
35
31
  );
@@ -7,33 +7,33 @@ export const TextInputPreview = ({} = {}) => {
7
7
  return (
8
8
  <SafeAreaView style={{flex: 1, justifyContent: 'space-around'}}>
9
9
  <TextInput
10
- onchangeText={(text: string) =>
10
+ onChangeText={(text: string) =>
11
11
  console.log('text is changed to: ' + text)
12
12
  }
13
13
  keyboardType={KeyBoardTypes.DECIMAL_PAD}
14
14
  />
15
15
  <TextInput
16
16
  placeholder={'placeholder text'}
17
- onchangeText={(text: string) =>
17
+ onChangeText={(text: string) =>
18
18
  console.log('text is changed to: ' + text)
19
19
  }
20
20
  keyboardType={KeyBoardTypes.DEFAULT}
21
21
  />
22
22
  <TextInput
23
- onchangeText={(text: string) =>
23
+ onChangeText={(text: string) =>
24
24
  console.log('text is changed to: ' + text)
25
25
  }
26
26
  keyboardType={KeyBoardTypes.EMAIL_ADDRESS}
27
27
  />
28
28
  <TextInput
29
29
  keyboardType={KeyBoardTypes.DEFAULT}
30
- onchangeText={(text: string) => console.log('text: ' + text)}
30
+ onChangeText={(text: string) => console.log('text: ' + text)}
31
31
  placeholder={'with border'}
32
32
  border={true}
33
33
  />
34
34
  <TextInput
35
35
  keyboardType={KeyBoardTypes.DEFAULT}
36
- onchangeText={(text: string) => console.log('text: ' + text)}
36
+ onChangeText={(text: string) => console.log('text: ' + text)}
37
37
  border={true}
38
38
  />
39
39
  </SafeAreaView>
@@ -10,7 +10,7 @@ describe('test input texts', () => {
10
10
  <TextInput
11
11
  keyboardType={KeyBoardTypes.DEFAULT}
12
12
  placeholder="dummy placeholder"
13
- onchangeText={() => console.log('text changed')}
13
+ onChangeText={() => console.log('text changed')}
14
14
  />
15
15
  )
16
16
  .toJSON();
@@ -22,7 +22,7 @@ describe('test input texts', () => {
22
22
  .create(
23
23
  <TextInput
24
24
  keyboardType={KeyBoardTypes.EMAIL_ADDRESS}
25
- onchangeText={() => console.log('text changed')}
25
+ onChangeText={() => console.log('text changed')}
26
26
  />
27
27
  )
28
28
  .toJSON();
@@ -34,7 +34,7 @@ describe('test input texts', () => {
34
34
  .create(
35
35
  <TextInput
36
36
  keyboardType={KeyBoardTypes.EMAIL_ADDRESS}
37
- onchangeText={() => console.log('text changed')}
37
+ onChangeText={() => console.log('text changed')}
38
38
  border={true}
39
39
  />
40
40
  )
@@ -47,7 +47,7 @@ describe('test input texts', () => {
47
47
  .create(
48
48
  <TextInput
49
49
  keyboardType={KeyBoardTypes.EMAIL_ADDRESS}
50
- onchangeText={() => console.log('text changed')}
50
+ onChangeText={() => console.log('text changed')}
51
51
  border={true}
52
52
  placeholder={'Text input field with a border'}
53
53
  />
@@ -428,3 +428,147 @@ exports[`test button component should render a button component with a solid ico
428
428
  </View>
429
429
  </View>
430
430
  `;
431
+
432
+ exports[`test button component should render a success 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": "#67C14E",
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": "#FFFFFF",
490
+ "textAlign": "center",
491
+ "width": "100%",
492
+ },
493
+ undefined,
494
+ ]
495
+ }
496
+ >
497
+ Success button
498
+ </Text>
499
+ </View>
500
+ </View>
501
+ </View>
502
+ `;
503
+
504
+ exports[`test button component should render an error button component 1`] = `
505
+ <View
506
+ accessibilityState={
507
+ {
508
+ "busy": undefined,
509
+ "checked": undefined,
510
+ "disabled": undefined,
511
+ "expanded": undefined,
512
+ "selected": undefined,
513
+ }
514
+ }
515
+ accessibilityValue={
516
+ {
517
+ "max": undefined,
518
+ "min": undefined,
519
+ "now": undefined,
520
+ "text": undefined,
521
+ }
522
+ }
523
+ accessible={true}
524
+ collapsable={false}
525
+ focusable={true}
526
+ onBlur={[Function]}
527
+ onClick={[Function]}
528
+ onFocus={[Function]}
529
+ onResponderGrant={[Function]}
530
+ onResponderMove={[Function]}
531
+ onResponderRelease={[Function]}
532
+ onResponderTerminate={[Function]}
533
+ onResponderTerminationRequest={[Function]}
534
+ onStartShouldSetResponder={[Function]}
535
+ >
536
+ <View
537
+ style={
538
+ {
539
+ "alignItems": "center",
540
+ "backgroundColor": "#D25E5E",
541
+ "borderRadius": 50,
542
+ "flexDirection": "row",
543
+ "justifyContent": "center",
544
+ "paddingHorizontal": 24,
545
+ "paddingVertical": 12,
546
+ }
547
+ }
548
+ >
549
+ <View>
550
+ <Text
551
+ style={
552
+ [
553
+ [
554
+ {
555
+ "fontFamily": "SourceSansPro",
556
+ "fontSize": 16,
557
+ "lineHeight": 22.4,
558
+ },
559
+ ],
560
+ {
561
+ "color": "#FFFFFF",
562
+ "textAlign": "center",
563
+ "width": "100%",
564
+ },
565
+ undefined,
566
+ ]
567
+ }
568
+ >
569
+ Error button
570
+ </Text>
571
+ </View>
572
+ </View>
573
+ </View>
574
+ `;
@@ -1,12 +1,14 @@
1
+ import { PressableProps } from 'react-native';
1
2
  import { IconNameType, IconStyleType } from '../../../types/icontype.type';
2
- type ButtonProps = {
3
+ type ButtonType = 'regular' | 'error' | 'success';
4
+ interface ButtonProps extends PressableProps {
3
5
  label: string;
4
6
  icon?: boolean;
5
7
  iconStyle?: IconStyleType;
6
8
  iconName?: IconNameType;
7
9
  iconSize?: number;
8
10
  disabled?: boolean;
9
- onPress?: () => void;
10
- };
11
- declare const Button: ({ label, icon, iconStyle, iconName, iconSize, disabled, onPress, }: ButtonProps) => JSX.Element;
11
+ type?: ButtonType;
12
+ }
13
+ declare const Button: ({ label, icon, iconStyle, iconName, iconSize, disabled, type, ...props }: ButtonProps) => JSX.Element;
12
14
  export { Button as Button };
@@ -1,22 +1,24 @@
1
1
  import * as React from 'react';
2
2
  import {useContext} from 'react';
3
3
 
4
- import {Pressable, View} from 'react-native';
4
+ import {Pressable, PressableProps, View} from 'react-native';
5
5
  import {ThemeCtx} from '../../../context/theme.context';
6
6
  import {Stylesheet} from './button.styles';
7
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 ButtonProps = {
11
+ type ButtonType = 'regular' | 'error' | 'success';
12
+
13
+ interface ButtonProps extends PressableProps {
12
14
  label: string;
13
15
  icon?: boolean;
14
16
  iconStyle?: IconStyleType;
15
17
  iconName?: IconNameType;
16
18
  iconSize?: number;
17
19
  disabled?: boolean;
18
- onPress?: () => void;
19
- };
20
+ type?: ButtonType;
21
+ }
20
22
 
21
23
  const Button = ({
22
24
  label,
@@ -25,13 +27,24 @@ const Button = ({
25
27
  iconName = 'calendar',
26
28
  iconSize,
27
29
  disabled,
28
- onPress,
30
+ type = 'regular',
31
+ ...props
29
32
  }: ButtonProps) => {
30
33
  const context = useContext(ThemeCtx);
31
- const styles = Stylesheet(context, disabled);
34
+
35
+ let buttonColor;
36
+ if (type === 'error') {
37
+ buttonColor = context.colors.ui.error.dark;
38
+ } else if (type === 'success') {
39
+ buttonColor = context.colors.ui.success.dark;
40
+ } else {
41
+ buttonColor = context.colors.main['0'];
42
+ }
43
+
44
+ const styles = Stylesheet(context, disabled, buttonColor);
32
45
 
33
46
  return (
34
- <Pressable disabled={disabled} onPress={onPress}>
47
+ <Pressable disabled={disabled} {...props}>
35
48
  <View style={styles.container}>
36
49
  {icon ? (
37
50
  <View style={styles.iconGap}>
@@ -39,7 +52,11 @@ const Button = ({
39
52
  style={iconStyle}
40
53
  name={iconName}
41
54
  color={
42
- disabled ? context.colors.ui.darkgrey : context.colors.main['9']
55
+ disabled
56
+ ? context.colors.ui.darkgrey
57
+ : type === 'regular'
58
+ ? context.colors.main['9']
59
+ : context.colors.ui.white
43
60
  }
44
61
  size={iconSize}
45
62
  />
@@ -49,7 +66,11 @@ const Button = ({
49
66
  <Heading4
50
67
  textAlign={'center'}
51
68
  textColor={
52
- disabled ? context.colors.ui.darkgrey : context.colors.main['9']
69
+ disabled
70
+ ? context.colors.ui.darkgrey
71
+ : type === 'regular'
72
+ ? context.colors.main['9']
73
+ : context.colors.ui.white
53
74
  }
54
75
  >
55
76
  {label}
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import {Button} from './button.component';
3
- import {Icon} from '../../../icons/index';
4
3
  const {View} = require('react-native');
5
4
 
6
5
  export const ButtonPreview = ({}: {}) => {
@@ -13,6 +12,16 @@ export const ButtonPreview = ({}: {}) => {
13
12
  }}
14
13
  >
15
14
  <Button label="Default button" onPress={() => console.log('clicked')} />
15
+ <Button
16
+ label="Error button"
17
+ type={'error'}
18
+ onPress={() => console.log('clicked')}
19
+ />
20
+ <Button
21
+ label="Success button"
22
+ type={'success'}
23
+ onPress={() => console.log('clicked')}
24
+ />
16
25
  <Button
17
26
  label="Icon button"
18
27
  icon={true}
@@ -24,6 +33,12 @@ export const ButtonPreview = ({}: {}) => {
24
33
  disabled={true}
25
34
  onPress={() => console.log('clicked')}
26
35
  />
36
+ <Button
37
+ label="Success disabled"
38
+ type={'success'}
39
+ disabled={true}
40
+ onPress={() => console.log('clicked')}
41
+ />
27
42
  <Button
28
43
  label="Disabled Icon button"
29
44
  disabled={true}