@tactics/toddle-styleguide 1.2.4 → 1.2.6
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/index.d.ts +2 -1
- package/index.tsx +2 -0
- package/package.json +2 -2
- package/src/components/atoms/backdrop/backdrop.component.d.ts +2 -1
- package/src/components/atoms/backdrop/backdrop.component.tsx +8 -2
- package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
- package/src/components/atoms/text-input/text-input.component.d.ts +4 -5
- package/src/components/atoms/text-input/text-input.component.tsx +9 -13
- package/src/components/atoms/text-input/text-input.preview.tsx +5 -5
- package/src/components/atoms/text-input/text-input.test.js +4 -4
- package/src/components/molecules/button/__snapshots__/button.test.js.snap +144 -0
- package/src/components/molecules/button/button.component.d.ts +6 -4
- package/src/components/molecules/button/button.component.tsx +30 -9
- package/src/components/molecules/button/button.preview.tsx +16 -1
- package/src/components/molecules/button/button.styles.d.ts +13 -16
- package/src/components/molecules/button/button.styles.js +2 -4
- package/src/components/molecules/button/button.test.js +12 -0
- package/src/components/molecules/message-input/__snapshots__/message-input.test.js.snap +4 -0
- package/src/components/molecules/message-input/message-input.component.d.ts +4 -6
- package/src/components/molecules/message-input/message-input.component.tsx +10 -12
- package/src/components/molecules/message-input/message-input.preview.tsx +28 -15
- package/src/components/molecules/password-input/password-input.component.d.ts +4 -6
- package/src/components/molecules/password-input/password-input.component.tsx +11 -15
- package/src/components/molecules/swipe/__snapshots__/swipe.test.js.snap +263 -420
- package/src/components/molecules/swipe/swipe.component.d.ts +4 -4
- package/src/components/molecules/swipe/swipe.component.tsx +47 -20
- package/src/components/molecules/swipe/swipe.preview.tsx +111 -51
- package/src/components/molecules/swipe/swipe.styles.d.ts +28 -0
- package/src/components/molecules/swipe/swipe.styles.js +32 -0
- package/src/components/molecules/swipe/swipe.test.js +1 -1
- package/src/components/molecules/tag/__snapshots__/tag.test.js.snap +13 -13
- package/src/components/molecules/tag/tag.component.d.ts +3 -8
- package/src/components/molecules/tag/tag.component.tsx +14 -25
- package/src/components/molecules/tag/tag.preview.tsx +78 -20
- package/src/components/molecules/tag/tag.styles.js +4 -2
- package/src/components/molecules/tag/tag.test.js +12 -2
- package/src/components/molecules/timestamp/__snapshots__/timestamp.test.js.snap +1 -1
- package/src/components/molecules/timestamp/timestamp.component.tsx +0 -2
- package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +7 -7
- package/src/components/templates/modal/modal.component.tsx +0 -1
- package/src/components/templates/popover-action/popover-action.component.d.ts +8 -0
- package/src/components/templates/popover-action/popover-action.component.tsx +119 -0
- package/src/components/templates/popover-action/popover-action.preview.d.ts +1 -0
- package/src/components/templates/popover-action/popover-action.preview.tsx +142 -0
- package/src/components/templates/popover-action/popover-action.styles.d.ts +26 -0
- package/src/components/templates/popover-action/popover-action.styles.js +31 -0
- package/src/utilities/toddle-datetime/toddle-datetime.class.d.ts +4 -0
- package/src/utilities/toddle-datetime/toddle-datetime.class.tsx +16 -0
- package/src/components/molecules/swipe/Swipe.styles.d.ts +0 -7
- package/src/components/molecules/swipe/Swipe.styles.js +0 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
type SwipeProps = {
|
|
3
|
-
children:
|
|
4
|
-
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
onIndexChange?: (index: number) => void;
|
|
5
5
|
};
|
|
6
|
-
declare const Swipe: ({ children,
|
|
6
|
+
declare const Swipe: ({ children, onIndexChange }: SwipeProps) => JSX.Element;
|
|
7
7
|
export { Swipe as Swipe };
|
|
@@ -1,50 +1,77 @@
|
|
|
1
|
-
import React, {Children, useContext} from 'react';
|
|
1
|
+
import React, {Children, ReactNode, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {ThemeCtx} from '../../../context/theme.context';
|
|
3
|
-
import
|
|
4
|
-
import {View} from 'react-native';
|
|
5
|
-
import {Stylesheet} from './Swipe.styles';
|
|
3
|
+
import {Stylesheet} from './swipe.styles';
|
|
6
4
|
import {Icon} from '../../../icons/index';
|
|
5
|
+
import PagerView, {PagerViewOnPageSelectedEvent} from 'react-native-pager-view';
|
|
6
|
+
import {Pressable, View} from 'react-native';
|
|
7
7
|
|
|
8
8
|
type SwipeProps = {
|
|
9
|
-
children:
|
|
10
|
-
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
onIndexChange?: (index: number) => void;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const Swipe = ({children,
|
|
13
|
+
const Swipe = ({children, onIndexChange}: SwipeProps) => {
|
|
14
14
|
const context = useContext(ThemeCtx);
|
|
15
15
|
const styles = Stylesheet();
|
|
16
|
+
const viewPagerRef = useRef<PagerView>(null);
|
|
17
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
18
|
+
|
|
16
19
|
const count = Children.count(children);
|
|
17
20
|
|
|
18
21
|
if (count > 5) {
|
|
19
22
|
console.warn(' for more then 5 child-components, use another way to show');
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
const handlePageSelected = (event: PagerViewOnPageSelectedEvent) => {
|
|
26
|
+
const currentIndex = event.nativeEvent.position;
|
|
27
|
+
setCurrentPage(currentIndex);
|
|
28
|
+
|
|
29
|
+
if (onIndexChange) {
|
|
30
|
+
onIndexChange(currentIndex);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
22
34
|
return (
|
|
23
|
-
<View style={styles.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
<View style={styles.rootContainer}>
|
|
36
|
+
{currentPage !== 0 && (
|
|
37
|
+
<Pressable
|
|
38
|
+
style={styles.leftArrowContainer}
|
|
39
|
+
onPress={() =>
|
|
40
|
+
viewPagerRef.current?.setPage(
|
|
41
|
+
currentPage != 1 ? currentPage - 1 : 0
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
>
|
|
32
45
|
<Icon
|
|
33
46
|
style={'regular'}
|
|
34
47
|
name={'chevron-left'}
|
|
35
48
|
color={context.colors.main['0']}
|
|
36
49
|
/>
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
</Pressable>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{currentPage !== count - 1 && (
|
|
54
|
+
<Pressable
|
|
55
|
+
style={styles.rightArrowContainer}
|
|
56
|
+
onPress={() => viewPagerRef.current?.setPage(currentPage + 1)}
|
|
57
|
+
>
|
|
39
58
|
<Icon
|
|
40
59
|
style={'regular'}
|
|
41
60
|
name={'chevron-right'}
|
|
42
61
|
color={context.colors.main['0']}
|
|
43
62
|
/>
|
|
44
|
-
|
|
63
|
+
</Pressable>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
<PagerView
|
|
67
|
+
ref={viewPagerRef}
|
|
68
|
+
style={styles.swipeContainer}
|
|
69
|
+
initialPage={0}
|
|
70
|
+
collapsable={false}
|
|
71
|
+
onPageSelected={handlePageSelected}
|
|
45
72
|
>
|
|
46
73
|
{children}
|
|
47
|
-
</
|
|
74
|
+
</PagerView>
|
|
48
75
|
</View>
|
|
49
76
|
);
|
|
50
77
|
};
|
|
@@ -1,63 +1,123 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
2
|
import {Swipe} from './swipe.component';
|
|
3
3
|
import {View} from 'react-native';
|
|
4
|
+
import {Heading2} from '../../atoms/heading-components';
|
|
5
|
+
import {Icon} from '../../../icons/index';
|
|
6
|
+
import {TimePicker} from '../time-picker/time-picker.component';
|
|
7
|
+
import {Paragraph} from '../../atoms/paragraph-components';
|
|
4
8
|
import {Button} from '../button/button.component';
|
|
5
|
-
import {Pill} from '../pill/pill.component';
|
|
6
|
-
import {VisualState} from '../../../types/visual-state.enum';
|
|
7
9
|
|
|
8
10
|
export const SwipePreview = ({}: {}) => {
|
|
11
|
+
const [checkInHours, setCheckInHours] = useState('09');
|
|
12
|
+
const [checkInMinutes, setCheckInMinutes] = useState('06');
|
|
13
|
+
|
|
9
14
|
return (
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<Button
|
|
38
|
-
label={'button 2'}
|
|
39
|
-
onPress={() => console.log('button 2 pressed')}
|
|
40
|
-
/>
|
|
15
|
+
<Swipe>
|
|
16
|
+
{/*FIRST CHILD*/}
|
|
17
|
+
<View
|
|
18
|
+
style={{
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
gap: 60,
|
|
21
|
+
}}
|
|
22
|
+
key={1}
|
|
23
|
+
>
|
|
24
|
+
<View style={{gap: 10}}>
|
|
25
|
+
<Heading2 bold={true} textAlign={'center'}>
|
|
26
|
+
Uurregistratie
|
|
27
|
+
</Heading2>
|
|
28
|
+
|
|
29
|
+
<View
|
|
30
|
+
style={{
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
gap: 16,
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<Icon style={'regular'} name={'calendar'} color={'#000000'} />
|
|
38
|
+
<View>
|
|
39
|
+
<Paragraph>17 Jan 2021</Paragraph>
|
|
40
|
+
</View>
|
|
41
|
+
</View>
|
|
41
42
|
</View>
|
|
42
|
-
<
|
|
43
|
-
|
|
43
|
+
<TimePicker
|
|
44
|
+
initialHours={checkInHours}
|
|
45
|
+
initialMinutes={checkInMinutes}
|
|
46
|
+
onChangeHours={setCheckInHours}
|
|
47
|
+
onChangeMinutes={setCheckInMinutes}
|
|
48
|
+
/>
|
|
49
|
+
</View>
|
|
50
|
+
|
|
51
|
+
{/*SECOND CHILD*/}
|
|
52
|
+
|
|
53
|
+
<View
|
|
54
|
+
style={{
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
gap: 60,
|
|
57
|
+
}}
|
|
58
|
+
key={2}
|
|
59
|
+
>
|
|
60
|
+
<View style={{gap: 12}}>
|
|
61
|
+
<Heading2 bold={true} textAlign={'center'}>
|
|
62
|
+
Uurregistratie
|
|
63
|
+
</Heading2>
|
|
64
|
+
|
|
65
|
+
<View
|
|
66
|
+
style={{
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
gap: 16,
|
|
69
|
+
justifyContent: 'center',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<Icon style={'regular'} name={'calendar'} color={'#000000'} />
|
|
74
|
+
<View>
|
|
75
|
+
<Paragraph>17 Jan 2021</Paragraph>
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
44
78
|
</View>
|
|
45
79
|
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
<Button label={'Test button'} onPress={() => console.log('pressed')} />
|
|
81
|
+
</View>
|
|
82
|
+
|
|
83
|
+
{/*THIRD CHILD*/}
|
|
84
|
+
|
|
85
|
+
<View
|
|
86
|
+
style={{
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
gap: 60,
|
|
89
|
+
}}
|
|
90
|
+
key={3}
|
|
91
|
+
>
|
|
92
|
+
<View style={{gap: 12}}>
|
|
93
|
+
<Heading2 bold={true} textAlign={'center'}>
|
|
94
|
+
Uurregistratie
|
|
95
|
+
</Heading2>
|
|
96
|
+
|
|
97
|
+
<View
|
|
98
|
+
style={{
|
|
99
|
+
flexDirection: 'row',
|
|
100
|
+
gap: 16,
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<Icon style={'regular'} name={'calendar'} color={'#000000'} />
|
|
106
|
+
<View>
|
|
107
|
+
<Paragraph>17 Jan 2021</Paragraph>
|
|
108
|
+
</View>
|
|
109
|
+
</View>
|
|
59
110
|
</View>
|
|
60
|
-
|
|
61
|
-
|
|
111
|
+
|
|
112
|
+
<TimePicker
|
|
113
|
+
initialHours={checkInHours}
|
|
114
|
+
initialMinutes={checkInMinutes}
|
|
115
|
+
onChangeHours={setCheckInHours}
|
|
116
|
+
onChangeMinutes={setCheckInMinutes}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<Button label={'Test button'} onPress={() => console.log('pressed')} />
|
|
120
|
+
</View>
|
|
121
|
+
</Swipe>
|
|
62
122
|
);
|
|
63
123
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function Stylesheet(): {
|
|
2
|
+
rootContainer: {
|
|
3
|
+
flex: number;
|
|
4
|
+
};
|
|
5
|
+
leftArrowContainer: {
|
|
6
|
+
alignItems: 'center';
|
|
7
|
+
justifyContent: 'center';
|
|
8
|
+
position: 'absolute';
|
|
9
|
+
zIndex: number;
|
|
10
|
+
top: number;
|
|
11
|
+
left: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
rightArrowContainer: {
|
|
16
|
+
alignItems: 'center';
|
|
17
|
+
justifyContent: 'center';
|
|
18
|
+
position: 'absolute';
|
|
19
|
+
zIndex: number;
|
|
20
|
+
top: number;
|
|
21
|
+
right: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
swipeContainer: {
|
|
26
|
+
flex: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {StyleSheet} from 'react-native';
|
|
3
|
+
import {Scale} from '../../../theme/scale/index';
|
|
4
|
+
export const Stylesheet = () =>
|
|
5
|
+
StyleSheet.create({
|
|
6
|
+
rootContainer: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
},
|
|
9
|
+
leftArrowContainer: {
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
zIndex: 10,
|
|
14
|
+
top: Scale.s,
|
|
15
|
+
left: 0,
|
|
16
|
+
width: 42,
|
|
17
|
+
height: 42,
|
|
18
|
+
},
|
|
19
|
+
rightArrowContainer: {
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
zIndex: 10,
|
|
24
|
+
top: Scale.s,
|
|
25
|
+
right: 0,
|
|
26
|
+
width: 42,
|
|
27
|
+
height: 42,
|
|
28
|
+
},
|
|
29
|
+
swipeContainer: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -5,7 +5,7 @@ import {View} from 'react-native';
|
|
|
5
5
|
import {Button} from '../button/button.component';
|
|
6
6
|
|
|
7
7
|
describe('Test Swipe component', () => {
|
|
8
|
-
it('should render an swipe component with
|
|
8
|
+
it('should render an swipe component with navigation arrows', () => {
|
|
9
9
|
const tree = renderer
|
|
10
10
|
.create(
|
|
11
11
|
<Swipe>
|
|
@@ -36,11 +36,13 @@ exports[`test Tag renders Tag correctly (blue, bold grey text) when isSelected i
|
|
|
36
36
|
style={
|
|
37
37
|
{
|
|
38
38
|
"alignItems": "center",
|
|
39
|
-
"backgroundColor": "#
|
|
39
|
+
"backgroundColor": "#647ACB",
|
|
40
40
|
"borderRadius": 50,
|
|
41
41
|
"justifyContent": "center",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"paddingBottom": 8,
|
|
43
|
+
"paddingLeft": 12,
|
|
44
|
+
"paddingRight": 12,
|
|
45
|
+
"paddingTop": 8,
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
>
|
|
@@ -49,22 +51,20 @@ exports[`test Tag renders Tag correctly (blue, bold grey text) when isSelected i
|
|
|
49
51
|
[
|
|
50
52
|
[
|
|
51
53
|
{
|
|
52
|
-
"fontFamily": "
|
|
54
|
+
"fontFamily": "MontserratBold",
|
|
53
55
|
"fontSize": 13,
|
|
54
56
|
"lineHeight": 20.4,
|
|
55
57
|
},
|
|
56
58
|
],
|
|
57
59
|
{
|
|
58
|
-
"color": "#
|
|
60
|
+
"color": "#E0E8F9",
|
|
59
61
|
"textAlign": "center",
|
|
60
62
|
"width": "100%",
|
|
61
63
|
},
|
|
62
64
|
undefined,
|
|
63
65
|
]
|
|
64
66
|
}
|
|
65
|
-
|
|
66
|
-
Geblokkeerd
|
|
67
|
-
</Text>
|
|
67
|
+
/>
|
|
68
68
|
</View>
|
|
69
69
|
</View>
|
|
70
70
|
`;
|
|
@@ -108,8 +108,10 @@ exports[`test Tag renders Tag correctly (grey, black text) 1`] = `
|
|
|
108
108
|
"backgroundColor": "#E5E8EB",
|
|
109
109
|
"borderRadius": 50,
|
|
110
110
|
"justifyContent": "center",
|
|
111
|
-
"
|
|
112
|
-
"
|
|
111
|
+
"paddingBottom": 8,
|
|
112
|
+
"paddingLeft": 12,
|
|
113
|
+
"paddingRight": 12,
|
|
114
|
+
"paddingTop": 8,
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
>
|
|
@@ -131,9 +133,7 @@ exports[`test Tag renders Tag correctly (grey, black text) 1`] = `
|
|
|
131
133
|
undefined,
|
|
132
134
|
]
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
Geblokkeerd
|
|
136
|
-
</Text>
|
|
136
|
+
/>
|
|
137
137
|
</View>
|
|
138
138
|
</View>
|
|
139
139
|
`;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
export interface TagPressEvent {
|
|
2
|
-
value: string;
|
|
3
|
-
isSelected: boolean;
|
|
4
|
-
}
|
|
5
1
|
type TagProps = {
|
|
6
2
|
value: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onPress: (event: TagPressEvent) => void;
|
|
3
|
+
label: string;
|
|
4
|
+
onPress: (event: string) => void;
|
|
10
5
|
};
|
|
11
|
-
declare const Tag: ({
|
|
6
|
+
declare const Tag: ({ label, onPress, value }: TagProps) => JSX.Element;
|
|
12
7
|
export { Tag as Tag };
|
|
@@ -1,47 +1,36 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {useContext
|
|
2
|
+
import {useContext} from 'react';
|
|
3
3
|
|
|
4
4
|
import {ThemeCtx} from '../../../context/theme.context';
|
|
5
5
|
import {Stylesheet} from './tag.styles';
|
|
6
6
|
import {View, Pressable} from 'react-native';
|
|
7
7
|
import {SmallText} from '../../atoms/paragraph-components';
|
|
8
8
|
|
|
9
|
-
export interface TagPressEvent {
|
|
10
|
-
value: string;
|
|
11
|
-
isSelected: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
type TagProps = {
|
|
15
10
|
value: string;
|
|
16
|
-
|
|
17
|
-
isSelected
|
|
18
|
-
|
|
11
|
+
label: string;
|
|
12
|
+
onPress: (value: string, isSelected: boolean) => void;
|
|
13
|
+
isSelected: boolean;
|
|
19
14
|
};
|
|
20
15
|
|
|
21
|
-
const Tag = ({
|
|
16
|
+
const Tag = ({label, onPress, value, isSelected}: TagProps) => {
|
|
22
17
|
const context = useContext(ThemeCtx);
|
|
23
|
-
const
|
|
24
|
-
const styles = Stylesheet(context, isSelectedTag);
|
|
18
|
+
const styles = Stylesheet(context, isSelected);
|
|
25
19
|
|
|
26
20
|
const onClicked = () => {
|
|
27
|
-
|
|
28
|
-
onPress({value, isSelected: !isSelectedTag});
|
|
21
|
+
onPress(value, !isSelected);
|
|
29
22
|
};
|
|
30
23
|
|
|
31
24
|
return (
|
|
32
25
|
<Pressable onPress={onClicked}>
|
|
33
26
|
<View style={styles.container}>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</SmallText>
|
|
42
|
-
) : (
|
|
43
|
-
<SmallText textAlign={'center'}>{text}</SmallText>
|
|
44
|
-
)}
|
|
27
|
+
<SmallText
|
|
28
|
+
bold={isSelected}
|
|
29
|
+
textAlign={'center'}
|
|
30
|
+
textColor={isSelected ? context.colors.main[9] : undefined}
|
|
31
|
+
>
|
|
32
|
+
{label}
|
|
33
|
+
</SmallText>
|
|
45
34
|
</View>
|
|
46
35
|
</Pressable>
|
|
47
36
|
);
|
|
@@ -1,27 +1,85 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
2
|
import {Tag} from './tag.component';
|
|
3
|
-
import {View} from 'react-native';
|
|
3
|
+
import {View, Text} from 'react-native';
|
|
4
4
|
|
|
5
5
|
export const TagPreview = ({}: {}) => {
|
|
6
|
+
const [singleTag, setSingleTag] = useState('');
|
|
7
|
+
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
|
8
|
+
|
|
9
|
+
const handleSingleTagPress = (value: string) => {
|
|
10
|
+
setSingleTag(value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const handleTagPress = (value: string, isSelected: boolean) => {
|
|
14
|
+
if (isSelected) {
|
|
15
|
+
setSelectedTags([...selectedTags, value]);
|
|
16
|
+
} else {
|
|
17
|
+
setSelectedTags(selectedTags.filter((tag) => tag !== value));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
return (
|
|
7
|
-
<View
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
<View
|
|
23
|
+
style={{
|
|
24
|
+
width: '100%',
|
|
25
|
+
height: '100%',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
gap: 12,
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<Text>Select single tag</Text>
|
|
32
|
+
<View>
|
|
33
|
+
<Tag
|
|
34
|
+
value={'Option 1'}
|
|
35
|
+
label={'Option 1'}
|
|
36
|
+
onPress={handleSingleTagPress}
|
|
37
|
+
isSelected={singleTag === 'Option 1'}
|
|
38
|
+
/>
|
|
39
|
+
</View>
|
|
40
|
+
<View>
|
|
41
|
+
<Tag
|
|
42
|
+
value={'Option 2'}
|
|
43
|
+
label={'Option 2'}
|
|
44
|
+
onPress={handleSingleTagPress}
|
|
45
|
+
isSelected={singleTag === 'Option 2'}
|
|
46
|
+
/>
|
|
47
|
+
</View>
|
|
48
|
+
<View>
|
|
49
|
+
<Tag
|
|
50
|
+
value={'Option 3'}
|
|
51
|
+
label={'Option 3'}
|
|
52
|
+
onPress={handleSingleTagPress}
|
|
53
|
+
isSelected={singleTag === 'Option 3'}
|
|
54
|
+
/>
|
|
55
|
+
</View>
|
|
56
|
+
<Text style={{marginBottom: 16}}>Selected tag: {singleTag}</Text>
|
|
57
|
+
<Text>Select multiple tags</Text>
|
|
58
|
+
<View>
|
|
59
|
+
<Tag
|
|
60
|
+
value={'Algemeen'}
|
|
61
|
+
label={'Algemeen'}
|
|
62
|
+
onPress={handleTagPress}
|
|
63
|
+
isSelected={selectedTags.includes('Algemeen')}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
<View>
|
|
67
|
+
<Tag
|
|
68
|
+
value={'Gezondheid'}
|
|
69
|
+
label={'Gezondheid'}
|
|
70
|
+
onPress={handleTagPress}
|
|
71
|
+
isSelected={selectedTags.includes('Gezondheid')}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
<View>
|
|
75
|
+
<Tag
|
|
76
|
+
value={'Activiteit'}
|
|
77
|
+
label={'Activiteit'}
|
|
78
|
+
onPress={handleTagPress}
|
|
79
|
+
isSelected={selectedTags.includes('Activiteit')}
|
|
80
|
+
/>
|
|
81
|
+
</View>
|
|
82
|
+
<Text>Selected tags: {selectedTags.join(', ')}</Text>
|
|
25
83
|
</View>
|
|
26
84
|
);
|
|
27
85
|
};
|
|
@@ -8,8 +8,10 @@ export const Stylesheet = (context, isSelected) =>
|
|
|
8
8
|
borderRadius: 50,
|
|
9
9
|
alignItems: 'center',
|
|
10
10
|
justifyContent: 'center',
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
paddingLeft: Scale.s,
|
|
12
|
+
paddingTop: Scale.xs,
|
|
13
|
+
paddingRight: Scale.s,
|
|
14
|
+
paddingBottom: Scale.xs,
|
|
13
15
|
backgroundColor: isSelected
|
|
14
16
|
? context.colors.main[5]
|
|
15
17
|
: context.colors.ui.lightgrey,
|
|
@@ -6,7 +6,12 @@ describe('test Tag', () => {
|
|
|
6
6
|
it('renders Tag correctly (grey, black text)', () => {
|
|
7
7
|
const tree = renderer
|
|
8
8
|
.create(
|
|
9
|
-
<Tag
|
|
9
|
+
<Tag
|
|
10
|
+
value={'Geblokkeerd'}
|
|
11
|
+
text={'Geblokkeerd'}
|
|
12
|
+
onPress={(value) => console.log(value)}
|
|
13
|
+
isSelected={false}
|
|
14
|
+
/>
|
|
10
15
|
)
|
|
11
16
|
.toJSON();
|
|
12
17
|
|
|
@@ -15,7 +20,12 @@ describe('test Tag', () => {
|
|
|
15
20
|
it('renders Tag correctly (blue, bold grey text) when isSelected is true', () => {
|
|
16
21
|
const tree = renderer
|
|
17
22
|
.create(
|
|
18
|
-
<Tag
|
|
23
|
+
<Tag
|
|
24
|
+
value={'Test2'}
|
|
25
|
+
text={'Tag2'}
|
|
26
|
+
onPress={(value) => console.log(value)}
|
|
27
|
+
isSelected={true}
|
|
28
|
+
/>
|
|
19
29
|
)
|
|
20
30
|
.toJSON();
|
|
21
31
|
|
|
@@ -15,8 +15,6 @@ export const Timestamp = ({sent}: TimestampProps) => {
|
|
|
15
15
|
|
|
16
16
|
const timestampToStringHandler = (timestamp: ToddleDateTime) => {
|
|
17
17
|
return timestamp.toLocaleString({
|
|
18
|
-
day: 'numeric',
|
|
19
|
-
month: 'short',
|
|
20
18
|
hourCycle: 'h24',
|
|
21
19
|
hour: 'numeric',
|
|
22
20
|
minute: '2-digit',
|