@tactics/toddle-styleguide 0.0.1
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/.expo-shared/assets.json +4 -0
- package/.github/workflows/run-tests.yml +16 -0
- package/.prettierrc.js +9 -0
- package/.yarnrc.yml +1 -0
- package/App.tsx +221 -0
- package/app.json +33 -0
- package/assets/adaptive-icon.png +0 -0
- package/assets/components/avatar/baby.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/fonts/montserrat/bold.ttf +0 -0
- package/assets/fonts/montserrat/regular.ttf +0 -0
- package/assets/fonts/source-sans-pro/bold.ttf +0 -0
- package/assets/fonts/source-sans-pro/regular.ttf +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +6 -0
- package/jest.config.js +22 -0
- package/package.json +53 -0
- package/src/components/atoms/avatar/__snapshots__/avatar.test.js.snap +85 -0
- package/src/components/atoms/avatar/avatar.component.tsx +35 -0
- package/src/components/atoms/avatar/avatar.preview.tsx +38 -0
- package/src/components/atoms/avatar/avatar.styles.js +55 -0
- package/src/components/atoms/avatar/avatar.test.js +22 -0
- package/src/components/atoms/button/__snapshots__/button.test.js.snap +307 -0
- package/src/components/atoms/button/button.component.tsx +27 -0
- package/src/components/atoms/button/button.preview.tsx +34 -0
- package/src/components/atoms/button/button.styles.js +25 -0
- package/src/components/atoms/button/button.test.js +35 -0
- package/src/components/atoms/cancel-link/__snapshots__/cancel-link.test.js.snap +89 -0
- package/src/components/atoms/cancel-link/cancel-link.component.tsx +24 -0
- package/src/components/atoms/cancel-link/cancel-link.preview.tsx +20 -0
- package/src/components/atoms/cancel-link/cancel-link.styles.js +20 -0
- package/src/components/atoms/cancel-link/cancel-link.test.js +28 -0
- package/src/components/atoms/check-switch/__snapshots__/check-switch.test.js.snap +67 -0
- package/src/components/atoms/check-switch/check-switch.component.tsx +46 -0
- package/src/components/atoms/check-switch/check-switch.preview.tsx +31 -0
- package/src/components/atoms/check-switch/check-switch.styles.js +36 -0
- package/src/components/atoms/check-switch/check-switch.test.js +13 -0
- package/src/components/atoms/checkbox/__snapshots__/checkbox.test.js.snap +120 -0
- package/src/components/atoms/checkbox/checkbox.component.tsx +26 -0
- package/src/components/atoms/checkbox/checkbox.preview.tsx +46 -0
- package/src/components/atoms/checkbox/checkbox.styles.js +35 -0
- package/src/components/atoms/checkbox/checkbox.test.js +30 -0
- package/src/components/atoms/child-list-item/__snapshots__/child-list-item.test.js.snap +635 -0
- package/src/components/atoms/child-list-item/child-list-item.component.tsx +81 -0
- package/src/components/atoms/child-list-item/child-list-item.preview.tsx +65 -0
- package/src/components/atoms/child-list-item/child-list-item.styles.js +82 -0
- package/src/components/atoms/child-list-item/child-list-item.test.js +73 -0
- package/src/components/atoms/contact-item/__snapshots__/contact-item.test.js.snap +321 -0
- package/src/components/atoms/contact-item/contact-item.component.tsx +61 -0
- package/src/components/atoms/contact-item/contact-item.preview.tsx +30 -0
- package/src/components/atoms/contact-item/contact-item.styles.js +26 -0
- package/src/components/atoms/contact-item/contact-item.test.js +20 -0
- package/src/components/atoms/filter-tab/__snapshots__/filter-tab.test.js.snap +415 -0
- package/src/components/atoms/filter-tab/filter-tab.component.tsx +93 -0
- package/src/components/atoms/filter-tab/filter-tab.preview.tsx +37 -0
- package/src/components/atoms/filter-tab/filter-tab.styles.js +64 -0
- package/src/components/atoms/filter-tab/filter-tab.test.js +38 -0
- package/src/components/atoms/form-actions/__snapshots__/form-action.test.js.snap +176 -0
- package/src/components/atoms/form-actions/form-action.component.tsx +25 -0
- package/src/components/atoms/form-actions/form-action.preview.tsx +29 -0
- package/src/components/atoms/form-actions/form-action.styles.js +19 -0
- package/src/components/atoms/form-actions/form-action.test.js +32 -0
- package/src/components/atoms/image-bubble/__snapshots__/image-bubble.test.js.snap +67 -0
- package/src/components/atoms/image-bubble/image-bubble.component.tsx +25 -0
- package/src/components/atoms/image-bubble/image-bubble.preview.tsx +19 -0
- package/src/components/atoms/image-bubble/image-bubble.styles.js +31 -0
- package/src/components/atoms/image-bubble/image-bubble.test.js +20 -0
- package/src/components/atoms/info/__snapshots__/info.test.js.snap +43 -0
- package/src/components/atoms/info/info.component.tsx +22 -0
- package/src/components/atoms/info/info.preview.tsx +20 -0
- package/src/components/atoms/info/info.styles.js +25 -0
- package/src/components/atoms/info/info.test.js +18 -0
- package/src/components/atoms/pill/__snapshots__/pill.test.js.snap +141 -0
- package/src/components/atoms/pill/pill.component.tsx +23 -0
- package/src/components/atoms/pill/pill.preview.tsx +21 -0
- package/src/components/atoms/pill/pill.styles.js +32 -0
- package/src/components/atoms/pill/pill.test.js +34 -0
- package/src/components/atoms/popover/components/backdrop/backdrop.component.tsx +40 -0
- package/src/components/atoms/popover/components/backdrop/backdrop.styles.js +15 -0
- package/src/components/atoms/popover/components/foreground/foreground.component.tsx +17 -0
- package/src/components/atoms/popover/components/foreground/foreground.styles.js +17 -0
- package/src/components/atoms/popover/components/index.js +5 -0
- package/src/components/atoms/popover/components/modal/close/close.component.tsx +21 -0
- package/src/components/atoms/popover/components/modal/close/close.styles.js +13 -0
- package/src/components/atoms/popover/components/modal/heading/heading.component.tsx +22 -0
- package/src/components/atoms/popover/components/modal/heading/heading.styles.js +24 -0
- package/src/components/atoms/popover/components/modal/modal.component.tsx +87 -0
- package/src/components/atoms/popover/components/modal/modal.styles.js +23 -0
- package/src/components/atoms/popover/components/modal/scroll-content/scroll-content.component.tsx +18 -0
- package/src/components/atoms/popover/components/modal/scroll-content/scroll-content.styles.js +10 -0
- package/src/components/atoms/popover/popover.component.tsx +60 -0
- package/src/components/atoms/popover/popover.preview.tsx +135 -0
- package/src/components/atoms/popover/popover.styles.js +12 -0
- package/src/components/atoms/popover-heading/__snapshots__/popover_heading.test.js.snap +35 -0
- package/src/components/atoms/popover-heading/popover-heading.component.tsx +22 -0
- package/src/components/atoms/popover-heading/popover-heading.preview.tsx +18 -0
- package/src/components/atoms/popover-heading/popover-heading.styles.js +19 -0
- package/src/components/atoms/popover-heading/popover_heading.test.js +11 -0
- package/src/components/atoms/pressable-icon/__snapshots__/pressable-icon.test.js.snap +364 -0
- package/src/components/atoms/pressable-icon/pressable-icon.component.tsx +48 -0
- package/src/components/atoms/pressable-icon/pressable-icon.preview.tsx +37 -0
- package/src/components/atoms/pressable-icon/pressable-icon.styles.js +25 -0
- package/src/components/atoms/pressable-icon/pressable-icon.test.js +47 -0
- package/src/components/atoms/quick-filter/__snapshots__/quick-filter.test.js.snap +465 -0
- package/src/components/atoms/quick-filter/quick-filter.component.tsx +32 -0
- package/src/components/atoms/quick-filter/quick-filter.prevriew.tsx +46 -0
- package/src/components/atoms/quick-filter/quick-filter.styles.js +68 -0
- package/src/components/atoms/quick-filter/quick-filter.test.js +127 -0
- package/src/components/atoms/select-list-item/__snapshots__/select-list-item.test.js.snap +391 -0
- package/src/components/atoms/select-list-item/select-list-item-preview.tsx +31 -0
- package/src/components/atoms/select-list-item/select-list-item.test.js +38 -0
- package/src/components/atoms/select-list-item/select-list.component-item.tsx +52 -0
- package/src/components/atoms/select-list-item/select-list.styles-item.js +40 -0
- package/src/components/atoms/snackbar/__snapshots__/snackbar.test.js.snap +493 -0
- package/src/components/atoms/snackbar/snackbar.component.tsx +28 -0
- package/src/components/atoms/snackbar/snackbar.preview.tsx +33 -0
- package/src/components/atoms/snackbar/snackbar.styles.js +82 -0
- package/src/components/atoms/snackbar/snackbar.test.js +35 -0
- package/src/components/atoms/tag/__snapshots__/tag.test.js.snap +87 -0
- package/src/components/atoms/tag/tag.component.tsx +37 -0
- package/src/components/atoms/tag/tag.preview.tsx +27 -0
- package/src/components/atoms/tag/tag.styles.js +22 -0
- package/src/components/atoms/tag/tag.test.js +24 -0
- package/src/components/atoms/text-bubble/__snapshots__/text-bubble.test.js.snap +337 -0
- package/src/components/atoms/text-bubble/text-bubble.component.tsx +32 -0
- package/src/components/atoms/text-bubble/text-bubble.preview.tsx +27 -0
- package/src/components/atoms/text-bubble/text-bubble.styles.js +64 -0
- package/src/components/atoms/text-bubble/text-bubble.test.js +84 -0
- package/src/components/atoms/text-input/__snapshots__/text-input.test.js.snap +68 -0
- package/src/components/atoms/text-input/text-input.component.tsx +32 -0
- package/src/components/atoms/text-input/text-input.preview.tsx +24 -0
- package/src/components/atoms/text-input/text-input.styles.js +26 -0
- package/src/components/atoms/text-input/text-input.test.js +32 -0
- package/src/components/atoms/time-tracker/__snapshots__/time-tracker.test.js.snap +206 -0
- package/src/components/atoms/time-tracker/time-tracker.component.tsx +24 -0
- package/src/components/atoms/time-tracker/time-tracker.preview.tsx +15 -0
- package/src/components/atoms/time-tracker/time-tracker.styles.js +36 -0
- package/src/components/atoms/time-tracker/time-tracker.test.js +37 -0
- package/src/components/atoms/wide-button/__snapshots__/wide-button.test.js.snap +92 -0
- package/src/components/atoms/wide-button/wide-button.component.tsx +23 -0
- package/src/components/atoms/wide-button/wide-button.preview.tsx +18 -0
- package/src/components/atoms/wide-button/wide-button.styles.js +22 -0
- package/src/components/atoms/wide-button/wide-button.test.js +16 -0
- package/src/context/theme.context.ts +49 -0
- package/src/gradients/main/main.gradient.tsx +20 -0
- package/src/gradients/main/main.styles.js +11 -0
- package/src/icons/__snapshots__/icons.test.js.snap +2588 -0
- package/src/icons/icons.test.js +245 -0
- package/src/icons/index.tsx +7 -0
- package/src/icons/outline/calendar/calendar.icon.tsx +20 -0
- package/src/icons/outline/chat/chat.icon.tsx +20 -0
- package/src/icons/outline/chat-alt/chat-alt.icon.tsx +20 -0
- package/src/icons/outline/check-circle/check-circle.icon.tsx +20 -0
- package/src/icons/outline/chevron-left/chevron-left.icon.tsx +20 -0
- package/src/icons/outline/chevron-right/chevron-right.icon.tsx +20 -0
- package/src/icons/outline/clock/clock.icon.tsx +20 -0
- package/src/icons/outline/cloud-download/cloud-download.icon.tsx +20 -0
- package/src/icons/outline/cross/cross.icon.tsx +20 -0
- package/src/icons/outline/currency-euro/currency-euro.icon.tsx +20 -0
- package/src/icons/outline/document-text/document-text.icon.tsx +20 -0
- package/src/icons/outline/exclamation/exclamation.icon.tsx +20 -0
- package/src/icons/outline/exclamation-circle/exclamation-circle.icon.tsx +20 -0
- package/src/icons/outline/eye/eye.icon.tsx +27 -0
- package/src/icons/outline/filter/filter.icon.tsx +59 -0
- package/src/icons/outline/information-circle/information-circle.icon.tsx +20 -0
- package/src/icons/outline/logout/logout.icon.tsx +20 -0
- package/src/icons/outline/mail/mail.icon.tsx +20 -0
- package/src/icons/outline/mail-open/mail-open.icon.tsx +20 -0
- package/src/icons/outline/menu/menu.icon.tsx +20 -0
- package/src/icons/outline/minus-sm/minus-sm.icon.tsx +20 -0
- package/src/icons/outline/office-building/office-building.icon.tsx +20 -0
- package/src/icons/outline/outline-default.preview.tsx +99 -0
- package/src/icons/outline/outline-grey.preview.tsx +100 -0
- package/src/icons/outline/outline-white.preview.tsx +100 -0
- package/src/icons/outline/outline.tsx +81 -0
- package/src/icons/outline/paper-airplane/paper-airplane.icon.tsx +20 -0
- package/src/icons/outline/paperclip/paperclip.icon.tsx +20 -0
- package/src/icons/outline/pencil/pencil.icon.tsx +20 -0
- package/src/icons/outline/phone/phone.icon.tsx +20 -0
- package/src/icons/outline/plus/plus.icon.tsx +20 -0
- package/src/icons/outline/plus-sm/plus-sm.icon.tsx +20 -0
- package/src/icons/outline/qrcode/qrcode.icon.tsx +17 -0
- package/src/icons/outline/refresh/refresh.icon.tsx +20 -0
- package/src/icons/outline/search/search.icon.tsx +20 -0
- package/src/icons/outline/selector/selector.icon.tsx +20 -0
- package/src/icons/outline/sm-view-grid-add/sm-view-grid-add.icon.tsx +20 -0
- package/src/icons/outline/status-online/status-online.icon.tsx +20 -0
- package/src/icons/outline/thumb-up/thumb-up.icon.tsx +20 -0
- package/src/icons/outline/trash/trash.icon.tsx +20 -0
- package/src/icons/outline/user/user.icon.tsx +27 -0
- package/src/icons/outline/user-group/user-group.icon.tsx +20 -0
- package/src/icons/outline/users/users.icon.tsx +20 -0
- package/src/icons/solid/chat-alt/chat-alt-solid.icon.tsx +20 -0
- package/src/icons/solid/clock/clock-solid.icon.tsx +20 -0
- package/src/icons/solid/information-circle/information-circle-solid.icon.tsx +20 -0
- package/src/icons/solid/pencil/pencil-solid.icon.tsx +22 -0
- package/src/icons/solid/phone/phone-solid.icon.tsx +18 -0
- package/src/icons/solid/refresh/refresh-solid.icon.tsx +20 -0
- package/src/icons/solid/solid.preview.tsx +73 -0
- package/src/icons/solid/solid.tsx +19 -0
- package/src/icons/solid/status-online/status-online-solid.icon.tsx +24 -0
- package/src/icons/solid/trash/trash-solid.icon.tsx +20 -0
- package/src/models/hex-color.model.ts +25 -0
- package/src/models/hex-color.test.js +20 -0
- package/src/models/initials.model.ts +32 -0
- package/src/models/initials.test.js +23 -0
- package/src/theme/font/font.ts +72 -0
- package/src/theme/font/index.ts +4 -0
- package/src/theme/font/load-fonts.ts +10 -0
- package/src/theme/provider/index.ts +4 -0
- package/src/theme/provider/parent.theme.ts +45 -0
- package/src/theme/provider/staff-member.theme.ts +45 -0
- package/src/theme/scale/index.ts +14 -0
- package/src/types/bubble-alignment.enum.ts +4 -0
- package/src/types/icontype.type.ts +3 -0
- package/src/types/keyboard-types.enum.ts +9 -0
- package/src/types/size.enum.ts +5 -0
- package/src/types/visual-state.enum.ts +6 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, {useContext, useRef} from 'react';
|
|
2
|
+
import {View, Animated, Pressable, Easing} from 'react-native';
|
|
3
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
4
|
+
import {Stylesheet} from './check-switch.styles';
|
|
5
|
+
|
|
6
|
+
type CheckProps = {
|
|
7
|
+
value: boolean;
|
|
8
|
+
onToggle: () => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Check = ({value, onToggle}: CheckProps) => {
|
|
12
|
+
const context = useContext(ThemeCtx);
|
|
13
|
+
const styles = Stylesheet(context, value);
|
|
14
|
+
|
|
15
|
+
const positionButton = useRef(new Animated.Value(0)).current;
|
|
16
|
+
|
|
17
|
+
const toggle = positionButton.interpolate({
|
|
18
|
+
inputRange: [0, 1],
|
|
19
|
+
outputRange: [0, 27],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
Animated.timing(positionButton, {
|
|
23
|
+
toValue: value ? 1 : 0,
|
|
24
|
+
duration: 200,
|
|
25
|
+
easing: Easing.linear,
|
|
26
|
+
useNativeDriver: true,
|
|
27
|
+
}).start();
|
|
28
|
+
|
|
29
|
+
const animatedStyle = {
|
|
30
|
+
transform: [
|
|
31
|
+
{
|
|
32
|
+
translateX: toggle,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={styles.container}>
|
|
39
|
+
<Pressable onPress={onToggle}>
|
|
40
|
+
<View style={styles.toggleContainer}>
|
|
41
|
+
<Animated.View style={[styles.thumbStyle, animatedStyle]} />
|
|
42
|
+
</View>
|
|
43
|
+
</Pressable>
|
|
44
|
+
</View>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import {Text} from 'react-native';
|
|
3
|
+
import {Check} from './check-switch.component';
|
|
4
|
+
const {View} = require('react-native');
|
|
5
|
+
|
|
6
|
+
export const CheckPreview = ({}: {}) => {
|
|
7
|
+
const [enabledMusic, setMusic] = useState(false);
|
|
8
|
+
const toggleMusic = () => setMusic((previousState) => !previousState);
|
|
9
|
+
|
|
10
|
+
const [enabled, setEnabled] = useState(false);
|
|
11
|
+
const toggleSwitch = () => setEnabled((previousState) => !previousState);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<View
|
|
15
|
+
style={{
|
|
16
|
+
flex: 1,
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<View>
|
|
22
|
+
<Text>Music {enabledMusic ? 'On' : 'Off'}</Text>
|
|
23
|
+
<Check value={enabledMusic} onToggle={toggleMusic} />
|
|
24
|
+
</View>
|
|
25
|
+
<View>
|
|
26
|
+
<Text>Switch {enabled ? 'On' : 'Off'}</Text>
|
|
27
|
+
<Check value={enabled} onToggle={toggleSwitch} />
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Scale} from '../../../theme/scale';
|
|
3
|
+
|
|
4
|
+
export const Stylesheet = (context, value) =>
|
|
5
|
+
StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
},
|
|
11
|
+
toggleContainer: {
|
|
12
|
+
width: 65,
|
|
13
|
+
height: 36,
|
|
14
|
+
paddingLeft: Scale.xxs,
|
|
15
|
+
paddingRight: Scale.xxs,
|
|
16
|
+
borderRadius: 18,
|
|
17
|
+
backgroundColor: value
|
|
18
|
+
? context.colors.main['5']
|
|
19
|
+
: context.colors.ui.lightgrey,
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
},
|
|
22
|
+
thumbStyle: {
|
|
23
|
+
width: 30,
|
|
24
|
+
height: 30,
|
|
25
|
+
backgroundColor: context.colors.ui.white,
|
|
26
|
+
borderRadius: 50,
|
|
27
|
+
shadowColor: context.colors.ui.black,
|
|
28
|
+
shadowOpacity: 0.8,
|
|
29
|
+
shadowOffset: {
|
|
30
|
+
width: 0,
|
|
31
|
+
height: 2,
|
|
32
|
+
},
|
|
33
|
+
shadowRadius: 2,
|
|
34
|
+
elevation: 4,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import {Check} from './check-switch.component';
|
|
4
|
+
|
|
5
|
+
describe('test check switch', () => {
|
|
6
|
+
it('should render a check switch component', () => {
|
|
7
|
+
const tree = renderer
|
|
8
|
+
.create(<Check value={true} onToggle={() => console.log('test')} />)
|
|
9
|
+
.toJSON();
|
|
10
|
+
|
|
11
|
+
expect(tree).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Checkbox component test renders a checkbox with a "notenallergie" label that is checked 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
collapsable={false}
|
|
7
|
+
focusable={true}
|
|
8
|
+
onBlur={[Function]}
|
|
9
|
+
onClick={[Function]}
|
|
10
|
+
onFocus={[Function]}
|
|
11
|
+
onResponderGrant={[Function]}
|
|
12
|
+
onResponderMove={[Function]}
|
|
13
|
+
onResponderRelease={[Function]}
|
|
14
|
+
onResponderTerminate={[Function]}
|
|
15
|
+
onResponderTerminationRequest={[Function]}
|
|
16
|
+
onStartShouldSetResponder={[Function]}
|
|
17
|
+
style={
|
|
18
|
+
{
|
|
19
|
+
"alignItems": "center",
|
|
20
|
+
"flexDirection": "row",
|
|
21
|
+
"justifyContent": "center",
|
|
22
|
+
"paddingBottom": 8,
|
|
23
|
+
"paddingLeft": 8,
|
|
24
|
+
"paddingRight": 8,
|
|
25
|
+
"paddingTop": 8,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
<View
|
|
30
|
+
style={
|
|
31
|
+
{
|
|
32
|
+
"alignItems": "center",
|
|
33
|
+
"backgroundColor": "#E5E8EB",
|
|
34
|
+
"borderRadius": 4,
|
|
35
|
+
"height": 16,
|
|
36
|
+
"justifyContent": "center",
|
|
37
|
+
"marginRight": 8,
|
|
38
|
+
"width": 16,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
<View
|
|
43
|
+
style={
|
|
44
|
+
{
|
|
45
|
+
"backgroundColor": "#647ACB",
|
|
46
|
+
"borderRadius": 4,
|
|
47
|
+
"height": 12,
|
|
48
|
+
"width": 12,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
<Text
|
|
54
|
+
style={
|
|
55
|
+
{
|
|
56
|
+
"color": "#1F2933",
|
|
57
|
+
"fontFamily": "Montserrat",
|
|
58
|
+
"fontSize": 13,
|
|
59
|
+
"lineHeight": 20.4,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
>
|
|
63
|
+
notenallergie
|
|
64
|
+
</Text>
|
|
65
|
+
</View>
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
exports[`Checkbox component test renders a checkbox with a "suiker" label that is not checked 1`] = `
|
|
69
|
+
<View
|
|
70
|
+
accessible={true}
|
|
71
|
+
collapsable={false}
|
|
72
|
+
focusable={true}
|
|
73
|
+
onBlur={[Function]}
|
|
74
|
+
onClick={[Function]}
|
|
75
|
+
onFocus={[Function]}
|
|
76
|
+
onResponderGrant={[Function]}
|
|
77
|
+
onResponderMove={[Function]}
|
|
78
|
+
onResponderRelease={[Function]}
|
|
79
|
+
onResponderTerminate={[Function]}
|
|
80
|
+
onResponderTerminationRequest={[Function]}
|
|
81
|
+
onStartShouldSetResponder={[Function]}
|
|
82
|
+
style={
|
|
83
|
+
{
|
|
84
|
+
"alignItems": "center",
|
|
85
|
+
"flexDirection": "row",
|
|
86
|
+
"justifyContent": "center",
|
|
87
|
+
"paddingBottom": 8,
|
|
88
|
+
"paddingLeft": 8,
|
|
89
|
+
"paddingRight": 8,
|
|
90
|
+
"paddingTop": 8,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
>
|
|
94
|
+
<View
|
|
95
|
+
style={
|
|
96
|
+
{
|
|
97
|
+
"alignItems": "center",
|
|
98
|
+
"backgroundColor": "#E5E8EB",
|
|
99
|
+
"borderRadius": 4,
|
|
100
|
+
"height": 16,
|
|
101
|
+
"justifyContent": "center",
|
|
102
|
+
"marginRight": 8,
|
|
103
|
+
"width": 16,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
<Text
|
|
108
|
+
style={
|
|
109
|
+
{
|
|
110
|
+
"color": "#1F2933",
|
|
111
|
+
"fontFamily": "Montserrat",
|
|
112
|
+
"fontSize": 13,
|
|
113
|
+
"lineHeight": 20.4,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
>
|
|
117
|
+
suiker
|
|
118
|
+
</Text>
|
|
119
|
+
</View>
|
|
120
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, {useContext} from 'react';
|
|
2
|
+
import {Pressable, Text, View} from 'react-native';
|
|
3
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
4
|
+
import {Stylesheet} from './checkbox.styles';
|
|
5
|
+
|
|
6
|
+
type CheckboxProps = {
|
|
7
|
+
value: boolean;
|
|
8
|
+
onValueChange: () => void;
|
|
9
|
+
label: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Checkbox = ({value, onValueChange, label}: CheckboxProps) => {
|
|
13
|
+
const context = useContext(ThemeCtx);
|
|
14
|
+
const styles = Stylesheet(context);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Pressable style={styles.element} onPress={onValueChange}>
|
|
18
|
+
<View style={styles.input}>
|
|
19
|
+
{value ? <View style={styles.check} /> : null}
|
|
20
|
+
</View>
|
|
21
|
+
<Text style={styles.label}>{label}</Text>
|
|
22
|
+
</Pressable>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export {Checkbox as Checkbox};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import {Checkbox} from './checkbox.component';
|
|
3
|
+
const {View} = require('react-native');
|
|
4
|
+
|
|
5
|
+
export const CheckboxPreview = ({}: {}) => {
|
|
6
|
+
const [notenallergie, setNotenallergie] = useState(false);
|
|
7
|
+
const [melkproducten, setMelkproducten] = useState(false);
|
|
8
|
+
const [eieren, setEieren] = useState(false);
|
|
9
|
+
const [vlees, setVlees] = useState(false);
|
|
10
|
+
const [suiker, setSuiker] = useState(false);
|
|
11
|
+
return (
|
|
12
|
+
<View
|
|
13
|
+
style={{
|
|
14
|
+
flex: 1,
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
<Checkbox
|
|
20
|
+
value={notenallergie}
|
|
21
|
+
onValueChange={() => setNotenallergie((prev) => !prev)}
|
|
22
|
+
label={'notenallergie'}
|
|
23
|
+
/>
|
|
24
|
+
<Checkbox
|
|
25
|
+
value={melkproducten}
|
|
26
|
+
onValueChange={() => setMelkproducten((prev) => !prev)}
|
|
27
|
+
label={'melkproducten'}
|
|
28
|
+
/>
|
|
29
|
+
<Checkbox
|
|
30
|
+
value={eieren}
|
|
31
|
+
onValueChange={() => setEieren((prev) => !prev)}
|
|
32
|
+
label={'eieren'}
|
|
33
|
+
/>
|
|
34
|
+
<Checkbox
|
|
35
|
+
value={vlees}
|
|
36
|
+
onValueChange={() => setVlees((prev) => !prev)}
|
|
37
|
+
label={'vlees'}
|
|
38
|
+
/>
|
|
39
|
+
<Checkbox
|
|
40
|
+
value={suiker}
|
|
41
|
+
onValueChange={() => setSuiker((prev) => !prev)}
|
|
42
|
+
label={'suiker'}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Font} from '../../../theme/font';
|
|
3
|
+
import {Scale} from '../../../theme/scale';
|
|
4
|
+
|
|
5
|
+
export const Stylesheet = (context) =>
|
|
6
|
+
StyleSheet.create({
|
|
7
|
+
element: {
|
|
8
|
+
paddingTop: Scale.xs,
|
|
9
|
+
paddingBottom: Scale.xs,
|
|
10
|
+
paddingLeft: Scale.xs,
|
|
11
|
+
paddingRight: Scale.xs,
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
},
|
|
16
|
+
input: {
|
|
17
|
+
width: 16, //Scale.m,
|
|
18
|
+
height: 16, //Scale.m,
|
|
19
|
+
backgroundColor: context.colors.ui.lightgrey,
|
|
20
|
+
borderRadius: 4,
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
marginRight: Scale.xs,
|
|
24
|
+
},
|
|
25
|
+
check: {
|
|
26
|
+
width: 12, //Scale.s,
|
|
27
|
+
height: 12, //Scale.s,
|
|
28
|
+
backgroundColor: context.colors.main['5'],
|
|
29
|
+
borderRadius: 4,
|
|
30
|
+
},
|
|
31
|
+
label: {
|
|
32
|
+
...Font.small,
|
|
33
|
+
color: context.colors.ui.black,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import render from 'react-test-renderer';
|
|
3
|
+
import {Checkbox} from './checkbox.component';
|
|
4
|
+
|
|
5
|
+
describe('Checkbox component test', () => {
|
|
6
|
+
it('renders a checkbox with a "suiker" label that is not checked', function () {
|
|
7
|
+
const tree = render
|
|
8
|
+
.create(
|
|
9
|
+
<Checkbox
|
|
10
|
+
label={'suiker'}
|
|
11
|
+
value={false}
|
|
12
|
+
onValueChange={() => console.log('suiker checkbox')}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
.toJSON();
|
|
16
|
+
expect(tree).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
it('renders a checkbox with a "notenallergie" label that is checked', function () {
|
|
19
|
+
const tree = render
|
|
20
|
+
.create(
|
|
21
|
+
<Checkbox
|
|
22
|
+
label={'notenallergie'}
|
|
23
|
+
value={true}
|
|
24
|
+
onValueChange={() => console.log('notenallergie checked checkbox')}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
.toJSON();
|
|
28
|
+
expect(tree).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|