@tactics/toddle-styleguide 1.1.2 → 1.1.4

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 (27) hide show
  1. package/App.tsx +11 -0
  2. package/index.d.ts +3 -1
  3. package/index.tsx +6 -0
  4. package/package.json +1 -1
  5. package/src/components/atoms/background-gradient/__snapshots__/background-gradient.test.js.snap +36 -0
  6. package/src/components/atoms/background-gradient/background-gradient.component.d.ts +1 -0
  7. package/src/components/atoms/background-gradient/background-gradient.component.tsx +19 -0
  8. package/src/components/atoms/background-gradient/background-gradient.preview.d.ts +1 -0
  9. package/src/components/atoms/background-gradient/background-gradient.preview.tsx +77 -0
  10. package/src/components/atoms/background-gradient/background-gradient.styles.d.ts +8 -0
  11. package/src/components/atoms/background-gradient/background-gradient.styles.js +11 -0
  12. package/src/components/atoms/background-gradient/background-gradient.test.js +10 -0
  13. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
  14. package/src/components/molecules/contact-role/__snapshots__/contact-role.test.js.snap +4 -4
  15. package/src/components/molecules/contact-role/contact-role.component.tsx +2 -2
  16. package/src/components/molecules/time-tracker/time-tracker.component.d.ts +2 -1
  17. package/src/components/molecules/time-tracker/time-tracker.component.tsx +21 -11
  18. package/src/components/organisms/child-list-item/child-list-item.component.d.ts +2 -1
  19. package/src/components/organisms/child-list-item/child-list-item.component.tsx +67 -61
  20. package/src/components/organisms/day-select/day-select.component.tsx +2 -2
  21. package/src/context/theme.context.d.ts +4 -1
  22. package/src/context/theme.context.ts +4 -1
  23. package/src/gradients/main/main.gradient.tsx +1 -1
  24. package/src/theme/provider/staff-member.theme.d.ts +4 -1
  25. package/src/theme/provider/staff-member.theme.ts +4 -1
  26. package/src/theme/responsive/index.d.ts +2 -0
  27. package/src/theme/responsive/index.ts +17 -0
package/App.tsx CHANGED
@@ -65,6 +65,7 @@ import {ModalPreview} from './src/components/templates/modal/modal.preview';
65
65
  import {LoadingIndicatorPreview} from './src/components/organisms/loading-indicator/loading-indicator.preview';
66
66
  import {WaveBackgroundPreview} from './src/components/molecules/wave-background/wave.preview';
67
67
  import {ToddleDateTimePreview} from './src/utilities/toddle-datetime/toddle-datetime.preview';
68
+ import {BackgroundGradientPreview} from './src/components/atoms/background-gradient/background-gradient.preview';
68
69
 
69
70
  const Stack = createNativeStackNavigator();
70
71
 
@@ -250,6 +251,10 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
250
251
  title="Toddle DateTime"
251
252
  onPress={() => navigation.push('toddle-datetime')}
252
253
  />
254
+ <ReactBtn
255
+ title="Gradient background"
256
+ onPress={() => navigation.push('background-gradient')}
257
+ />
253
258
  </ScrollView>
254
259
  );
255
260
  };
@@ -410,6 +415,12 @@ function App() {
410
415
  <Stack.Screen name="toddle-datetime" options={{headerShown: false}}>
411
416
  {() => <ToddleDateTimePreview />}
412
417
  </Stack.Screen>
418
+ <Stack.Screen
419
+ name="background-gradient"
420
+ options={{headerShown: false}}
421
+ >
422
+ {() => <BackgroundGradientPreview />}
423
+ </Stack.Screen>
413
424
  </Stack.Navigator>
414
425
  </NavigationContainer>
415
426
  </ThemeCtx.Provider>
package/index.d.ts CHANGED
@@ -50,6 +50,7 @@ import { LanguageButton } from './src/components/molecules/language-button/langu
50
50
  import { Modal } from './src/components/templates/modal/modal.component';
51
51
  import { LoadingIndicator } from './src/components/organisms/loading-indicator/loading-indicator.component';
52
52
  import { WaveBackground } from './src/components/molecules/wave-background/wave.component';
53
+ import { BackgroundGradient } from './src/components/atoms/background-gradient/background-gradient.component';
53
54
  import { BubbleAlignment } from './src/types/bubble-alignment.enum';
54
55
  import { KeyBoardTypes } from './src/types/keyboard-types.enum';
55
56
  import { Size } from './src/types/size.enum';
@@ -58,4 +59,5 @@ import { Initials } from './src/models/initials.model';
58
59
  import { ToddleDateTime } from './src/utilities/toddle-datetime/toddle-datetime.class';
59
60
  import { ThemeCtx } from './src/context/theme.context';
60
61
  import { Scale } from './src/theme/scale/index';
61
- export { Initials, BubbleAlignment, KeyBoardTypes, Size, Scale, 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, };
62
+ import CreateResponsiveStyle from './src/theme/responsive/index';
63
+ 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, };
package/index.tsx CHANGED
@@ -68,6 +68,7 @@ import {LanguageButton} from './src/components/molecules/language-button/languag
68
68
  import {Modal} from './src/components/templates/modal/modal.component';
69
69
  import {LoadingIndicator} from './src/components/organisms/loading-indicator/loading-indicator.component';
70
70
  import {WaveBackground} from './src/components/molecules/wave-background/wave.component';
71
+ import {BackgroundGradient} from './src/components/atoms/background-gradient/background-gradient.component';
71
72
 
72
73
  // Exports of enums
73
74
  import {BubbleAlignment} from './src/types/bubble-alignment.enum';
@@ -87,12 +88,16 @@ import {ThemeCtx} from './src/context/theme.context';
87
88
  //Export of Theme
88
89
  import {Scale} from './src/theme/scale/index';
89
90
 
91
+ // Export of responsive style
92
+ import CreateResponsiveStyle from './src/theme/responsive/index';
93
+
90
94
  export {
91
95
  Initials,
92
96
  BubbleAlignment,
93
97
  KeyBoardTypes,
94
98
  Size,
95
99
  Scale,
100
+ CreateResponsiveStyle,
96
101
  VisualState,
97
102
  ThemeCtx,
98
103
  ToddleDateTime,
@@ -152,4 +157,5 @@ export {
152
157
  Modal,
153
158
  LoadingIndicator,
154
159
  WaveBackground,
160
+ BackgroundGradient,
155
161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -0,0 +1,36 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`test gradient background should render a gradient background 1`] = `
4
+ <ViewManagerAdapter_ExpoLinearGradient
5
+ proxiedProperties={
6
+ {
7
+ "colors": [
8
+ 4281681564,
9
+ 4284775115,
10
+ 4284775115,
11
+ ],
12
+ "endPoint": [
13
+ 0.9,
14
+ 0.9,
15
+ ],
16
+ "locations": [
17
+ 0,
18
+ 0.55,
19
+ 1,
20
+ ],
21
+ "startPoint": [
22
+ 0.1,
23
+ 0.1,
24
+ ],
25
+ }
26
+ }
27
+ style={
28
+ {
29
+ "height": "100%",
30
+ "position": "absolute",
31
+ "width": "100%",
32
+ "zIndex": -1,
33
+ }
34
+ }
35
+ />
36
+ `;
@@ -0,0 +1 @@
1
+ export declare const BackgroundGradient: () => JSX.Element;
@@ -0,0 +1,19 @@
1
+ import React, {useContext} from 'react';
2
+ import {ThemeCtx} from '../../../context/theme.context';
3
+ import {LinearGradient} from 'expo-linear-gradient';
4
+ import {Stylesheet} from './background-gradient.styles';
5
+
6
+ export const BackgroundGradient = () => {
7
+ const Context = useContext(ThemeCtx);
8
+ const styles = Stylesheet();
9
+
10
+ return (
11
+ <LinearGradient
12
+ start={{x: 0.1, y: 0.1}}
13
+ end={{x: 0.9, y: 0.9}}
14
+ locations={[0, 0.55, 1]}
15
+ colors={Context.colors.gradient['1']}
16
+ style={styles.rootContainer}
17
+ />
18
+ );
19
+ };
@@ -0,0 +1 @@
1
+ export declare const BackgroundGradientPreview: ({}: {}) => JSX.Element;
@@ -0,0 +1,77 @@
1
+ import React, {useContext, useState} from 'react';
2
+ import {SafeAreaView, View, Platform, StatusBar} from 'react-native';
3
+ import {Logo} from '../logo/logo.component';
4
+ import {ThemeCtx} from '../../../context/theme.context';
5
+ import {Heading1, Heading4} from '../heading-components';
6
+ import {Paragraph} from '../paragraph-components';
7
+ import {SelectPicker} from '../../molecules/select-picker/select-picker.component';
8
+ import {BackgroundGradient} from './background-gradient.component';
9
+
10
+ export const BackgroundGradientPreview = ({}: {}) => {
11
+ const regions = [
12
+ {value: 'Leuven', label: 'Leuven'},
13
+ {value: 'Brussel', label: 'Brussel'},
14
+ {value: 'Antwerpen', label: 'Antwerpen'},
15
+ ];
16
+ const [selectedRegion, setSelectedRegion] = useState('');
17
+ const Context = useContext(ThemeCtx);
18
+ return (
19
+ <SafeAreaView
20
+ style={{
21
+ flex: 1,
22
+ }}
23
+ >
24
+ <BackgroundGradient />
25
+ <View
26
+ style={{
27
+ width: '100%',
28
+ height: '100%',
29
+ paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
30
+ paddingLeft: 16,
31
+ paddingRight: 16,
32
+ }}
33
+ >
34
+ <View
35
+ style={{
36
+ marginTop: 16 * 3.5,
37
+ marginBottom: 16 * 5.5,
38
+ alignItems: 'center',
39
+ }}
40
+ >
41
+ <Logo big={true} colorIsWhite={true} />
42
+ </View>
43
+
44
+ <View>
45
+ <Heading1
46
+ bold={true}
47
+ textColor={Context.colors.ui.white}
48
+ textAlign={'left'}
49
+ addStyle={{marginBottom: 64}}
50
+ >
51
+ Welkom,
52
+ </Heading1>
53
+ <Heading4
54
+ bold={true}
55
+ textColor={Context.colors.ui.white}
56
+ addStyle={{marginBottom: 8}}
57
+ >
58
+ Regio
59
+ </Heading4>
60
+ <Paragraph
61
+ textColor={Context.colors.ui.white}
62
+ addStyle={{marginBottom: 16}}
63
+ >
64
+ Deze krijgt u toegestuurd van het kinderdagverblijf bij de start van
65
+ uw opvangtraject.
66
+ </Paragraph>
67
+ <SelectPicker
68
+ placeholder={'Choose your region'}
69
+ data={regions}
70
+ onChange={setSelectedRegion}
71
+ defaultValue={selectedRegion}
72
+ />
73
+ </View>
74
+ </View>
75
+ </SafeAreaView>
76
+ );
77
+ };
@@ -0,0 +1,8 @@
1
+ export function Stylesheet(): {
2
+ rootContainer: {
3
+ width: string;
4
+ height: string;
5
+ position: 'absolute';
6
+ zIndex: number;
7
+ };
8
+ };
@@ -0,0 +1,11 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ export const Stylesheet = () =>
4
+ StyleSheet.create({
5
+ rootContainer: {
6
+ width: '100%',
7
+ height: '100%',
8
+ position: 'absolute',
9
+ zIndex: -1,
10
+ },
11
+ });
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import render from 'react-test-renderer';
3
+ import {BackgroundGradient} from './background-gradient.component';
4
+
5
+ describe('test gradient background', () => {
6
+ it('should render a gradient background', () => {
7
+ const tree = render.create(<BackgroundGradient />).toJSON();
8
+ expect(tree).toMatchSnapshot();
9
+ });
10
+ });
@@ -1960,7 +1960,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1960
1960
  }
1961
1961
  >
1962
1962
  <View
1963
- accessibilityLabel="today Vrijdag 17 Maart 2023 "
1963
+ accessibilityLabel=" Vrijdag 17 Maart 2023 "
1964
1964
  accessibilityRole="button"
1965
1965
  accessibilityState={
1966
1966
  {
@@ -1992,10 +1992,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1992
1992
  style={
1993
1993
  {
1994
1994
  "alignItems": "center",
1995
- "borderColor": "#7B93DB",
1996
- "borderRadius": 21,
1997
- "borderStyle": "solid",
1998
- "borderWidth": 1,
1999
1995
  "height": 42,
2000
1996
  "justifyContent": "center",
2001
1997
  "opacity": 1,
@@ -2015,9 +2011,6 @@ exports[`Test for the calendar component renders a calendar where you can select
2015
2011
  "lineHeight": 22.4,
2016
2012
  "marginTop": 4,
2017
2013
  },
2018
- {
2019
- "color": "#7B93DB",
2020
- },
2021
2014
  ]
2022
2015
  }
2023
2016
  >
@@ -2797,7 +2790,7 @@ exports[`Test for the calendar component renders a calendar where you can select
2797
2790
  }
2798
2791
  >
2799
2792
  <View
2800
- accessibilityLabel=" Maandag 27 Maart 2023 "
2793
+ accessibilityLabel="today Maandag 27 Maart 2023 "
2801
2794
  accessibilityRole="button"
2802
2795
  accessibilityState={
2803
2796
  {
@@ -2829,6 +2822,10 @@ exports[`Test for the calendar component renders a calendar where you can select
2829
2822
  style={
2830
2823
  {
2831
2824
  "alignItems": "center",
2825
+ "borderColor": "#7B93DB",
2826
+ "borderRadius": 21,
2827
+ "borderStyle": "solid",
2828
+ "borderWidth": 1,
2832
2829
  "height": 42,
2833
2830
  "justifyContent": "center",
2834
2831
  "opacity": 1,
@@ -2848,6 +2845,9 @@ exports[`Test for the calendar component renders a calendar where you can select
2848
2845
  "lineHeight": 22.4,
2849
2846
  "marginTop": 4,
2850
2847
  },
2848
+ {
2849
+ "color": "#7B93DB",
2850
+ },
2851
2851
  ]
2852
2852
  }
2853
2853
  >
@@ -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 17 Maart 2023 "
5361
- accessibilityRole="button"
5360
+ accessibilityLabel=" Vrijdag 17 Maart 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
  }
@@ -6212,7 +6207,8 @@ exports[`Test for the calendar component renders a calendar where you can select
6212
6207
  }
6213
6208
  >
6214
6209
  <View
6215
- accessibilityLabel=" Maandag 27 Maart 2023 "
6210
+ accessibilityLabel="today Maandag 27 Maart 2023 "
6211
+ accessibilityRole="button"
6216
6212
  accessibilityState={
6217
6213
  {
6218
6214
  "busy": undefined,
@@ -6243,6 +6239,10 @@ exports[`Test for the calendar component renders a calendar where you can select
6243
6239
  style={
6244
6240
  {
6245
6241
  "alignItems": "center",
6242
+ "borderColor": "#7B93DB",
6243
+ "borderRadius": 21,
6244
+ "borderStyle": "solid",
6245
+ "borderWidth": 1,
6246
6246
  "height": 42,
6247
6247
  "justifyContent": "center",
6248
6248
  "opacity": 1,
@@ -6263,7 +6263,7 @@ exports[`Test for the calendar component renders a calendar where you can select
6263
6263
  "marginTop": 4,
6264
6264
  },
6265
6265
  {
6266
- "color": "#9AA5B1",
6266
+ "color": "#7B93DB",
6267
6267
  },
6268
6268
  ]
6269
6269
  }
@@ -21,7 +21,7 @@ exports[`Contact role component test renders a contact who is the father 1`] = `
21
21
  ],
22
22
  {
23
23
  "color": "#1F2933",
24
- "textAlign": undefined,
24
+ "textAlign": "center",
25
25
  "width": "100%",
26
26
  },
27
27
  {
@@ -44,7 +44,7 @@ exports[`Contact role component test renders a contact who is the father 1`] = `
44
44
  ],
45
45
  {
46
46
  "color": "#1F2933",
47
- "textAlign": undefined,
47
+ "textAlign": "center",
48
48
  "width": "100%",
49
49
  },
50
50
  undefined,
@@ -77,7 +77,7 @@ exports[`Contact role component test renders a contact who is the sister 1`] = `
77
77
  ],
78
78
  {
79
79
  "color": "#1F2933",
80
- "textAlign": undefined,
80
+ "textAlign": "center",
81
81
  "width": "100%",
82
82
  },
83
83
  {
@@ -100,7 +100,7 @@ exports[`Contact role component test renders a contact who is the sister 1`] = `
100
100
  ],
101
101
  {
102
102
  "color": "#1F2933",
103
- "textAlign": undefined,
103
+ "textAlign": "center",
104
104
  "width": "100%",
105
105
  },
106
106
  undefined,
@@ -14,10 +14,10 @@ export const ContactRole = ({name, role}: ContactRoleProps) => {
14
14
 
15
15
  return (
16
16
  <View style={styles.container}>
17
- <Heading2 bold={true} addStyle={styles.name}>
17
+ <Heading2 bold={true} textAlign={'center'} addStyle={styles.name}>
18
18
  {name}
19
19
  </Heading2>
20
- <SmallText>{role}</SmallText>
20
+ <SmallText textAlign={'center'}>{role}</SmallText>
21
21
  </View>
22
22
  );
23
23
  };
@@ -1,8 +1,9 @@
1
+ import * as React from 'react';
1
2
  import { VisualState } from '../../../types/visual-state.enum';
2
3
  type TimeTrackerProps = {
3
4
  text: string;
4
5
  textColor?: string;
5
6
  visualState: VisualState;
6
7
  };
7
- declare const TimeTracker: ({ text, visualState, textColor }: TimeTrackerProps) => JSX.Element;
8
+ declare const TimeTracker: React.MemoExoticComponent<({ text, visualState, textColor }: TimeTrackerProps) => JSX.Element>;
8
9
  export { TimeTracker as TimeTracker };
@@ -13,18 +13,28 @@ type TimeTrackerProps = {
13
13
  visualState: VisualState;
14
14
  };
15
15
 
16
- const TimeTracker = ({text, visualState, textColor}: TimeTrackerProps) => {
17
- const context = useContext(ThemeCtx);
18
- const styles = Stylesheet(context, visualState);
16
+ const TimeTracker = React.memo(
17
+ ({text, visualState, textColor}: TimeTrackerProps) => {
18
+ const context = useContext(ThemeCtx);
19
+ const styles = Stylesheet(context, visualState);
19
20
 
20
- return (
21
- <View style={styles.container}>
22
- <View style={styles.bal} />
23
- <View>
24
- <TinyText textColor={textColor}>{text}</TinyText>
21
+ return (
22
+ <View style={styles.container}>
23
+ <View style={styles.bal} />
24
+ <View>
25
+ <TinyText textColor={textColor}>{text}</TinyText>
26
+ </View>
25
27
  </View>
26
- </View>
27
- );
28
- };
28
+ );
29
+ },
30
+ (prevProps, nextProps) => {
31
+ //Compare props and return true if the component should update
32
+ return (
33
+ prevProps.text !== nextProps.text ||
34
+ prevProps.visualState !== nextProps.visualState ||
35
+ prevProps.textColor !== nextProps.textColor
36
+ );
37
+ }
38
+ );
29
39
 
30
40
  export {TimeTracker as TimeTracker};
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { ImageSourcePropType } from 'react-native';
2
3
  import { Initials } from '../../../models/initials.model';
3
4
  import { VisualState } from '../../../types/visual-state.enum';
@@ -14,5 +15,5 @@ type ChildListItemProps = {
14
15
  textTimeTracker: string;
15
16
  visualStateTimeTracker: VisualState;
16
17
  };
17
- declare const ChildListItem: ({ id, name, department, selectable, isSelected, onPressArrow, onPressText, onSelect, sourceAvatar, textTimeTracker, visualStateTimeTracker, }: ChildListItemProps) => JSX.Element;
18
+ declare const ChildListItem: React.MemoExoticComponent<({ id, name, department, selectable, isSelected, onPressArrow, onPressText, onSelect, sourceAvatar, textTimeTracker, visualStateTimeTracker, }: ChildListItemProps) => JSX.Element>;
18
19
  export { ChildListItem as ChildListItem };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {useContext} from 'react';
2
+ import {useCallback, useContext, useMemo} from 'react';
3
3
 
4
4
  import {ThemeCtx} from '../../../context/theme.context';
5
5
  import {ImageSourcePropType, Pressable, View} from 'react-native';
@@ -27,65 +27,71 @@ type ChildListItemProps = {
27
27
  visualStateTimeTracker: VisualState;
28
28
  };
29
29
 
30
- const ChildListItem = ({
31
- id,
32
- name,
33
- department,
34
- selectable,
35
- isSelected,
36
- onPressArrow,
37
- onPressText,
38
- onSelect,
39
- sourceAvatar,
40
- textTimeTracker,
41
- visualStateTimeTracker,
42
- }: ChildListItemProps) => {
43
- const context = useContext(ThemeCtx);
44
- const styles = Stylesheet(isSelected, context);
30
+ const ChildListItem = React.memo(
31
+ ({
32
+ id,
33
+ name,
34
+ department,
35
+ selectable,
36
+ isSelected,
37
+ onPressArrow,
38
+ onPressText,
39
+ onSelect,
40
+ sourceAvatar,
41
+ textTimeTracker,
42
+ visualStateTimeTracker,
43
+ }: ChildListItemProps) => {
44
+ const context = useContext(ThemeCtx);
45
+ const styles = Stylesheet(isSelected, context);
45
46
 
46
- const onPressSelectable = () => {
47
- selectable ? onSelect(id) : onPressText(id);
48
- };
47
+ const onPressSelectable = useCallback(() => {
48
+ selectable ? onSelect(id) : onPressText(id);
49
+ }, [id, onPressText, onSelect, selectable]);
49
50
 
50
- return (
51
- <View style={styles.container}>
52
- <Pressable onPress={onPressSelectable} style={styles.innerContainer}>
53
- <Avatar source={sourceAvatar} size={Size.MEDIUM} />
54
- <View style={styles.pressableText}>
55
- <View style={styles.trackerContainer}>
56
- <TimeTracker
57
- text={textTimeTracker}
58
- visualState={visualStateTimeTracker}
59
- textColor={
60
- isSelected ? context.colors.ui.white : context.colors.ui.black
61
- }
62
- />
63
- </View>
64
- <View>
65
- <Heading2
66
- bold={true}
67
- numberOfLines={1}
68
- ellipsizeMode={'tail'}
69
- textColor={
70
- isSelected ? context.colors.ui.white : context.colors.ui.black
71
- }
72
- >
73
- {name}
74
- </Heading2>
75
- <SmallText
76
- textColor={
77
- isSelected ? context.colors.ui.white : context.colors.ui.black
78
- }
79
- >
80
- {department}
81
- </SmallText>
51
+ const onPressArrowCallback = useCallback(() => {
52
+ onPressArrow(id);
53
+ }, [id, onPressArrow]);
54
+
55
+ const textColor = useMemo(() => {
56
+ return isSelected ? context.colors.ui.white : context.colors.ui.black;
57
+ }, [isSelected]);
58
+
59
+ return (
60
+ <View style={styles.container}>
61
+ <Pressable onPress={onPressSelectable} style={styles.innerContainer}>
62
+ <Avatar source={sourceAvatar} size={Size.MEDIUM} />
63
+ <View style={styles.pressableText}>
64
+ <View style={styles.trackerContainer}>
65
+ <TimeTracker
66
+ text={textTimeTracker}
67
+ visualState={visualStateTimeTracker}
68
+ textColor={textColor}
69
+ />
70
+ </View>
71
+ <View>
72
+ <Heading2
73
+ bold={true}
74
+ numberOfLines={1}
75
+ ellipsizeMode={'tail'}
76
+ textColor={
77
+ isSelected ? context.colors.ui.white : context.colors.ui.black
78
+ }
79
+ >
80
+ {name}
81
+ </Heading2>
82
+ <SmallText
83
+ textColor={
84
+ isSelected ? context.colors.ui.white : context.colors.ui.black
85
+ }
86
+ >
87
+ {department}
88
+ </SmallText>
89
+ </View>
82
90
  </View>
83
- </View>
84
- </Pressable>
85
- <>
86
- {!selectable ? (
91
+ </Pressable>
92
+ {!selectable && (
87
93
  <Pressable
88
- onPress={() => onPressArrow(id)}
94
+ onPress={onPressArrowCallback}
89
95
  style={styles.iconContainer}
90
96
  >
91
97
  <Icon
@@ -95,9 +101,9 @@ const ChildListItem = ({
95
101
  color={context.colors.ui.black}
96
102
  />
97
103
  </Pressable>
98
- ) : null}
99
- </>
100
- </View>
101
- );
102
- };
104
+ )}
105
+ </View>
106
+ );
107
+ }
108
+ );
103
109
  export {ChildListItem as ChildListItem};
@@ -67,8 +67,8 @@ const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
67
67
  });
68
68
 
69
69
  const composedGesture = Gesture.Simultaneous(
70
- flingLeftGesture,
71
- flingRightGesture
70
+ flingLeftGesture.runOnJS(true),
71
+ flingRightGesture.runOnJS(true)
72
72
  );
73
73
 
74
74
  return (
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  interface ThemeInterface {
3
3
  colors: {
4
- gradient: Array<string>;
4
+ gradient: {
5
+ 1: string[];
6
+ 0: string[];
7
+ };
5
8
  main: {
6
9
  9: string;
7
10
  8: string;
@@ -3,7 +3,10 @@ import {StaffMemberTheme} from '../theme/provider';
3
3
 
4
4
  interface ThemeInterface {
5
5
  colors: {
6
- gradient: Array<string>;
6
+ gradient: {
7
+ 1: string[];
8
+ 0: string[];
9
+ };
7
10
  main: {
8
11
  9: string;
9
12
  8: string;
@@ -18,7 +18,7 @@ export const MainGradient = ({isActive = true}: MainGradientProps) => {
18
18
  start={{x: 0.1, y: 0.1}}
19
19
  end={{x: 0.9, y: 0.9}}
20
20
  locations={[0, 0.55, 1]}
21
- colors={Context.colors.gradient}
21
+ colors={Context.colors.gradient['0']}
22
22
  style={styles.container}
23
23
  />
24
24
  ) : (
@@ -1,6 +1,9 @@
1
1
  export declare const StaffMemberTheme: {
2
2
  colors: {
3
- gradient: string[];
3
+ gradient: {
4
+ 1: string[];
5
+ 0: string[];
6
+ };
4
7
  main: {
5
8
  9: string;
6
9
  8: string;
@@ -2,7 +2,10 @@ import {Colors} from '@tactics/kinderopvang-branding';
2
2
 
3
3
  export const StaffMemberTheme = {
4
4
  colors: {
5
- gradient: [Colors.secondary[2], Colors.secondary[5], Colors.tertiary[4]],
5
+ gradient: {
6
+ 1: [Colors.secondary[2], Colors.secondary[5], Colors.secondary[5]],
7
+ 0: [Colors.secondary[2], Colors.secondary[5], Colors.tertiary[4]],
8
+ },
6
9
  main: {
7
10
  9: Colors.secondary[9],
8
11
  8: Colors.secondary[8],
@@ -0,0 +1,2 @@
1
+ import { ScaledSize, StyleProp, StyleSheet } from 'react-native';
2
+ export default function CreateResponsiveStyle<T, U extends Partial<T>>(mobileStyles: StyleSheet.NamedStyles<T>, tabletStyles: StyleSheet.NamedStyles<U>): (layout: ScaledSize) => (style: keyof T) => StyleProp<any>;
@@ -0,0 +1,17 @@
1
+ import {ScaledSize, StyleProp, StyleSheet} from 'react-native';
2
+
3
+ export default function CreateResponsiveStyle<T, U extends Partial<T>>(
4
+ mobileStyles: StyleSheet.NamedStyles<T>,
5
+ tabletStyles: StyleSheet.NamedStyles<U>
6
+ ) {
7
+ const mobile = StyleSheet.create<StyleSheet.NamedStyles<T>>(mobileStyles);
8
+ const tablet = StyleSheet.create<StyleSheet.NamedStyles<U>>(tabletStyles);
9
+
10
+ // Return a function that combines wraps web and mobile styles
11
+ return (layout: ScaledSize) =>
12
+ (style: keyof T): StyleProp<any> => {
13
+ if (layout.width > 768 && tablet.hasOwnProperty(style)) {
14
+ return StyleSheet.compose(mobile[style], tablet[style]);
15
+ } else return mobile[style];
16
+ };
17
+ }