@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.
Files changed (220) hide show
  1. package/.expo-shared/assets.json +4 -0
  2. package/.github/workflows/run-tests.yml +16 -0
  3. package/.prettierrc.js +9 -0
  4. package/.yarnrc.yml +1 -0
  5. package/App.tsx +221 -0
  6. package/app.json +33 -0
  7. package/assets/adaptive-icon.png +0 -0
  8. package/assets/components/avatar/baby.png +0 -0
  9. package/assets/favicon.png +0 -0
  10. package/assets/fonts/montserrat/bold.ttf +0 -0
  11. package/assets/fonts/montserrat/regular.ttf +0 -0
  12. package/assets/fonts/source-sans-pro/bold.ttf +0 -0
  13. package/assets/fonts/source-sans-pro/regular.ttf +0 -0
  14. package/assets/icon.png +0 -0
  15. package/assets/splash.png +0 -0
  16. package/babel.config.js +6 -0
  17. package/jest.config.js +22 -0
  18. package/package.json +53 -0
  19. package/src/components/atoms/avatar/__snapshots__/avatar.test.js.snap +85 -0
  20. package/src/components/atoms/avatar/avatar.component.tsx +35 -0
  21. package/src/components/atoms/avatar/avatar.preview.tsx +38 -0
  22. package/src/components/atoms/avatar/avatar.styles.js +55 -0
  23. package/src/components/atoms/avatar/avatar.test.js +22 -0
  24. package/src/components/atoms/button/__snapshots__/button.test.js.snap +307 -0
  25. package/src/components/atoms/button/button.component.tsx +27 -0
  26. package/src/components/atoms/button/button.preview.tsx +34 -0
  27. package/src/components/atoms/button/button.styles.js +25 -0
  28. package/src/components/atoms/button/button.test.js +35 -0
  29. package/src/components/atoms/cancel-link/__snapshots__/cancel-link.test.js.snap +89 -0
  30. package/src/components/atoms/cancel-link/cancel-link.component.tsx +24 -0
  31. package/src/components/atoms/cancel-link/cancel-link.preview.tsx +20 -0
  32. package/src/components/atoms/cancel-link/cancel-link.styles.js +20 -0
  33. package/src/components/atoms/cancel-link/cancel-link.test.js +28 -0
  34. package/src/components/atoms/check-switch/__snapshots__/check-switch.test.js.snap +67 -0
  35. package/src/components/atoms/check-switch/check-switch.component.tsx +46 -0
  36. package/src/components/atoms/check-switch/check-switch.preview.tsx +31 -0
  37. package/src/components/atoms/check-switch/check-switch.styles.js +36 -0
  38. package/src/components/atoms/check-switch/check-switch.test.js +13 -0
  39. package/src/components/atoms/checkbox/__snapshots__/checkbox.test.js.snap +120 -0
  40. package/src/components/atoms/checkbox/checkbox.component.tsx +26 -0
  41. package/src/components/atoms/checkbox/checkbox.preview.tsx +46 -0
  42. package/src/components/atoms/checkbox/checkbox.styles.js +35 -0
  43. package/src/components/atoms/checkbox/checkbox.test.js +30 -0
  44. package/src/components/atoms/child-list-item/__snapshots__/child-list-item.test.js.snap +635 -0
  45. package/src/components/atoms/child-list-item/child-list-item.component.tsx +81 -0
  46. package/src/components/atoms/child-list-item/child-list-item.preview.tsx +65 -0
  47. package/src/components/atoms/child-list-item/child-list-item.styles.js +82 -0
  48. package/src/components/atoms/child-list-item/child-list-item.test.js +73 -0
  49. package/src/components/atoms/contact-item/__snapshots__/contact-item.test.js.snap +321 -0
  50. package/src/components/atoms/contact-item/contact-item.component.tsx +61 -0
  51. package/src/components/atoms/contact-item/contact-item.preview.tsx +30 -0
  52. package/src/components/atoms/contact-item/contact-item.styles.js +26 -0
  53. package/src/components/atoms/contact-item/contact-item.test.js +20 -0
  54. package/src/components/atoms/filter-tab/__snapshots__/filter-tab.test.js.snap +415 -0
  55. package/src/components/atoms/filter-tab/filter-tab.component.tsx +93 -0
  56. package/src/components/atoms/filter-tab/filter-tab.preview.tsx +37 -0
  57. package/src/components/atoms/filter-tab/filter-tab.styles.js +64 -0
  58. package/src/components/atoms/filter-tab/filter-tab.test.js +38 -0
  59. package/src/components/atoms/form-actions/__snapshots__/form-action.test.js.snap +176 -0
  60. package/src/components/atoms/form-actions/form-action.component.tsx +25 -0
  61. package/src/components/atoms/form-actions/form-action.preview.tsx +29 -0
  62. package/src/components/atoms/form-actions/form-action.styles.js +19 -0
  63. package/src/components/atoms/form-actions/form-action.test.js +32 -0
  64. package/src/components/atoms/image-bubble/__snapshots__/image-bubble.test.js.snap +67 -0
  65. package/src/components/atoms/image-bubble/image-bubble.component.tsx +25 -0
  66. package/src/components/atoms/image-bubble/image-bubble.preview.tsx +19 -0
  67. package/src/components/atoms/image-bubble/image-bubble.styles.js +31 -0
  68. package/src/components/atoms/image-bubble/image-bubble.test.js +20 -0
  69. package/src/components/atoms/info/__snapshots__/info.test.js.snap +43 -0
  70. package/src/components/atoms/info/info.component.tsx +22 -0
  71. package/src/components/atoms/info/info.preview.tsx +20 -0
  72. package/src/components/atoms/info/info.styles.js +25 -0
  73. package/src/components/atoms/info/info.test.js +18 -0
  74. package/src/components/atoms/pill/__snapshots__/pill.test.js.snap +141 -0
  75. package/src/components/atoms/pill/pill.component.tsx +23 -0
  76. package/src/components/atoms/pill/pill.preview.tsx +21 -0
  77. package/src/components/atoms/pill/pill.styles.js +32 -0
  78. package/src/components/atoms/pill/pill.test.js +34 -0
  79. package/src/components/atoms/popover/components/backdrop/backdrop.component.tsx +40 -0
  80. package/src/components/atoms/popover/components/backdrop/backdrop.styles.js +15 -0
  81. package/src/components/atoms/popover/components/foreground/foreground.component.tsx +17 -0
  82. package/src/components/atoms/popover/components/foreground/foreground.styles.js +17 -0
  83. package/src/components/atoms/popover/components/index.js +5 -0
  84. package/src/components/atoms/popover/components/modal/close/close.component.tsx +21 -0
  85. package/src/components/atoms/popover/components/modal/close/close.styles.js +13 -0
  86. package/src/components/atoms/popover/components/modal/heading/heading.component.tsx +22 -0
  87. package/src/components/atoms/popover/components/modal/heading/heading.styles.js +24 -0
  88. package/src/components/atoms/popover/components/modal/modal.component.tsx +87 -0
  89. package/src/components/atoms/popover/components/modal/modal.styles.js +23 -0
  90. package/src/components/atoms/popover/components/modal/scroll-content/scroll-content.component.tsx +18 -0
  91. package/src/components/atoms/popover/components/modal/scroll-content/scroll-content.styles.js +10 -0
  92. package/src/components/atoms/popover/popover.component.tsx +60 -0
  93. package/src/components/atoms/popover/popover.preview.tsx +135 -0
  94. package/src/components/atoms/popover/popover.styles.js +12 -0
  95. package/src/components/atoms/popover-heading/__snapshots__/popover_heading.test.js.snap +35 -0
  96. package/src/components/atoms/popover-heading/popover-heading.component.tsx +22 -0
  97. package/src/components/atoms/popover-heading/popover-heading.preview.tsx +18 -0
  98. package/src/components/atoms/popover-heading/popover-heading.styles.js +19 -0
  99. package/src/components/atoms/popover-heading/popover_heading.test.js +11 -0
  100. package/src/components/atoms/pressable-icon/__snapshots__/pressable-icon.test.js.snap +364 -0
  101. package/src/components/atoms/pressable-icon/pressable-icon.component.tsx +48 -0
  102. package/src/components/atoms/pressable-icon/pressable-icon.preview.tsx +37 -0
  103. package/src/components/atoms/pressable-icon/pressable-icon.styles.js +25 -0
  104. package/src/components/atoms/pressable-icon/pressable-icon.test.js +47 -0
  105. package/src/components/atoms/quick-filter/__snapshots__/quick-filter.test.js.snap +465 -0
  106. package/src/components/atoms/quick-filter/quick-filter.component.tsx +32 -0
  107. package/src/components/atoms/quick-filter/quick-filter.prevriew.tsx +46 -0
  108. package/src/components/atoms/quick-filter/quick-filter.styles.js +68 -0
  109. package/src/components/atoms/quick-filter/quick-filter.test.js +127 -0
  110. package/src/components/atoms/select-list-item/__snapshots__/select-list-item.test.js.snap +391 -0
  111. package/src/components/atoms/select-list-item/select-list-item-preview.tsx +31 -0
  112. package/src/components/atoms/select-list-item/select-list-item.test.js +38 -0
  113. package/src/components/atoms/select-list-item/select-list.component-item.tsx +52 -0
  114. package/src/components/atoms/select-list-item/select-list.styles-item.js +40 -0
  115. package/src/components/atoms/snackbar/__snapshots__/snackbar.test.js.snap +493 -0
  116. package/src/components/atoms/snackbar/snackbar.component.tsx +28 -0
  117. package/src/components/atoms/snackbar/snackbar.preview.tsx +33 -0
  118. package/src/components/atoms/snackbar/snackbar.styles.js +82 -0
  119. package/src/components/atoms/snackbar/snackbar.test.js +35 -0
  120. package/src/components/atoms/tag/__snapshots__/tag.test.js.snap +87 -0
  121. package/src/components/atoms/tag/tag.component.tsx +37 -0
  122. package/src/components/atoms/tag/tag.preview.tsx +27 -0
  123. package/src/components/atoms/tag/tag.styles.js +22 -0
  124. package/src/components/atoms/tag/tag.test.js +24 -0
  125. package/src/components/atoms/text-bubble/__snapshots__/text-bubble.test.js.snap +337 -0
  126. package/src/components/atoms/text-bubble/text-bubble.component.tsx +32 -0
  127. package/src/components/atoms/text-bubble/text-bubble.preview.tsx +27 -0
  128. package/src/components/atoms/text-bubble/text-bubble.styles.js +64 -0
  129. package/src/components/atoms/text-bubble/text-bubble.test.js +84 -0
  130. package/src/components/atoms/text-input/__snapshots__/text-input.test.js.snap +68 -0
  131. package/src/components/atoms/text-input/text-input.component.tsx +32 -0
  132. package/src/components/atoms/text-input/text-input.preview.tsx +24 -0
  133. package/src/components/atoms/text-input/text-input.styles.js +26 -0
  134. package/src/components/atoms/text-input/text-input.test.js +32 -0
  135. package/src/components/atoms/time-tracker/__snapshots__/time-tracker.test.js.snap +206 -0
  136. package/src/components/atoms/time-tracker/time-tracker.component.tsx +24 -0
  137. package/src/components/atoms/time-tracker/time-tracker.preview.tsx +15 -0
  138. package/src/components/atoms/time-tracker/time-tracker.styles.js +36 -0
  139. package/src/components/atoms/time-tracker/time-tracker.test.js +37 -0
  140. package/src/components/atoms/wide-button/__snapshots__/wide-button.test.js.snap +92 -0
  141. package/src/components/atoms/wide-button/wide-button.component.tsx +23 -0
  142. package/src/components/atoms/wide-button/wide-button.preview.tsx +18 -0
  143. package/src/components/atoms/wide-button/wide-button.styles.js +22 -0
  144. package/src/components/atoms/wide-button/wide-button.test.js +16 -0
  145. package/src/context/theme.context.ts +49 -0
  146. package/src/gradients/main/main.gradient.tsx +20 -0
  147. package/src/gradients/main/main.styles.js +11 -0
  148. package/src/icons/__snapshots__/icons.test.js.snap +2588 -0
  149. package/src/icons/icons.test.js +245 -0
  150. package/src/icons/index.tsx +7 -0
  151. package/src/icons/outline/calendar/calendar.icon.tsx +20 -0
  152. package/src/icons/outline/chat/chat.icon.tsx +20 -0
  153. package/src/icons/outline/chat-alt/chat-alt.icon.tsx +20 -0
  154. package/src/icons/outline/check-circle/check-circle.icon.tsx +20 -0
  155. package/src/icons/outline/chevron-left/chevron-left.icon.tsx +20 -0
  156. package/src/icons/outline/chevron-right/chevron-right.icon.tsx +20 -0
  157. package/src/icons/outline/clock/clock.icon.tsx +20 -0
  158. package/src/icons/outline/cloud-download/cloud-download.icon.tsx +20 -0
  159. package/src/icons/outline/cross/cross.icon.tsx +20 -0
  160. package/src/icons/outline/currency-euro/currency-euro.icon.tsx +20 -0
  161. package/src/icons/outline/document-text/document-text.icon.tsx +20 -0
  162. package/src/icons/outline/exclamation/exclamation.icon.tsx +20 -0
  163. package/src/icons/outline/exclamation-circle/exclamation-circle.icon.tsx +20 -0
  164. package/src/icons/outline/eye/eye.icon.tsx +27 -0
  165. package/src/icons/outline/filter/filter.icon.tsx +59 -0
  166. package/src/icons/outline/information-circle/information-circle.icon.tsx +20 -0
  167. package/src/icons/outline/logout/logout.icon.tsx +20 -0
  168. package/src/icons/outline/mail/mail.icon.tsx +20 -0
  169. package/src/icons/outline/mail-open/mail-open.icon.tsx +20 -0
  170. package/src/icons/outline/menu/menu.icon.tsx +20 -0
  171. package/src/icons/outline/minus-sm/minus-sm.icon.tsx +20 -0
  172. package/src/icons/outline/office-building/office-building.icon.tsx +20 -0
  173. package/src/icons/outline/outline-default.preview.tsx +99 -0
  174. package/src/icons/outline/outline-grey.preview.tsx +100 -0
  175. package/src/icons/outline/outline-white.preview.tsx +100 -0
  176. package/src/icons/outline/outline.tsx +81 -0
  177. package/src/icons/outline/paper-airplane/paper-airplane.icon.tsx +20 -0
  178. package/src/icons/outline/paperclip/paperclip.icon.tsx +20 -0
  179. package/src/icons/outline/pencil/pencil.icon.tsx +20 -0
  180. package/src/icons/outline/phone/phone.icon.tsx +20 -0
  181. package/src/icons/outline/plus/plus.icon.tsx +20 -0
  182. package/src/icons/outline/plus-sm/plus-sm.icon.tsx +20 -0
  183. package/src/icons/outline/qrcode/qrcode.icon.tsx +17 -0
  184. package/src/icons/outline/refresh/refresh.icon.tsx +20 -0
  185. package/src/icons/outline/search/search.icon.tsx +20 -0
  186. package/src/icons/outline/selector/selector.icon.tsx +20 -0
  187. package/src/icons/outline/sm-view-grid-add/sm-view-grid-add.icon.tsx +20 -0
  188. package/src/icons/outline/status-online/status-online.icon.tsx +20 -0
  189. package/src/icons/outline/thumb-up/thumb-up.icon.tsx +20 -0
  190. package/src/icons/outline/trash/trash.icon.tsx +20 -0
  191. package/src/icons/outline/user/user.icon.tsx +27 -0
  192. package/src/icons/outline/user-group/user-group.icon.tsx +20 -0
  193. package/src/icons/outline/users/users.icon.tsx +20 -0
  194. package/src/icons/solid/chat-alt/chat-alt-solid.icon.tsx +20 -0
  195. package/src/icons/solid/clock/clock-solid.icon.tsx +20 -0
  196. package/src/icons/solid/information-circle/information-circle-solid.icon.tsx +20 -0
  197. package/src/icons/solid/pencil/pencil-solid.icon.tsx +22 -0
  198. package/src/icons/solid/phone/phone-solid.icon.tsx +18 -0
  199. package/src/icons/solid/refresh/refresh-solid.icon.tsx +20 -0
  200. package/src/icons/solid/solid.preview.tsx +73 -0
  201. package/src/icons/solid/solid.tsx +19 -0
  202. package/src/icons/solid/status-online/status-online-solid.icon.tsx +24 -0
  203. package/src/icons/solid/trash/trash-solid.icon.tsx +20 -0
  204. package/src/models/hex-color.model.ts +25 -0
  205. package/src/models/hex-color.test.js +20 -0
  206. package/src/models/initials.model.ts +32 -0
  207. package/src/models/initials.test.js +23 -0
  208. package/src/theme/font/font.ts +72 -0
  209. package/src/theme/font/index.ts +4 -0
  210. package/src/theme/font/load-fonts.ts +10 -0
  211. package/src/theme/provider/index.ts +4 -0
  212. package/src/theme/provider/parent.theme.ts +45 -0
  213. package/src/theme/provider/staff-member.theme.ts +45 -0
  214. package/src/theme/scale/index.ts +14 -0
  215. package/src/types/bubble-alignment.enum.ts +4 -0
  216. package/src/types/icontype.type.ts +3 -0
  217. package/src/types/keyboard-types.enum.ts +9 -0
  218. package/src/types/size.enum.ts +5 -0
  219. package/src/types/visual-state.enum.ts +6 -0
  220. package/tsconfig.json +7 -0
@@ -0,0 +1,141 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`test pill given the visual state is DEFAULT return a blue/purple colored pill 1`] = `
4
+ <View
5
+ style={
6
+ [
7
+ {
8
+ "alignItems": "center",
9
+ "borderRadius": 50,
10
+ "justifyContent": "center",
11
+ "paddingHorizontal": 8,
12
+ "paddingVertical": 4,
13
+ },
14
+ {
15
+ "backgroundColor": "#647ACB",
16
+ },
17
+ false,
18
+ false,
19
+ false,
20
+ ]
21
+ }
22
+ >
23
+ <Text
24
+ style={
25
+ {
26
+ "color": "#FFFFFF",
27
+ "fontFamily": "MontserratBold",
28
+ "fontSize": 11,
29
+ "lineHeight": 17.9,
30
+ }
31
+ }
32
+ >
33
+ Default
34
+ </Text>
35
+ </View>
36
+ `;
37
+
38
+ exports[`test pill given the visual state is Error return a red colored pill 1`] = `
39
+ <View
40
+ style={
41
+ [
42
+ {
43
+ "alignItems": "center",
44
+ "borderRadius": 50,
45
+ "justifyContent": "center",
46
+ "paddingHorizontal": 8,
47
+ "paddingVertical": 4,
48
+ },
49
+ false,
50
+ false,
51
+ false,
52
+ {
53
+ "backgroundColor": "#F16868",
54
+ },
55
+ ]
56
+ }
57
+ >
58
+ <Text
59
+ style={
60
+ {
61
+ "color": "#FFFFFF",
62
+ "fontFamily": "MontserratBold",
63
+ "fontSize": 11,
64
+ "lineHeight": 17.9,
65
+ }
66
+ }
67
+ >
68
+ Geblokkeerd
69
+ </Text>
70
+ </View>
71
+ `;
72
+
73
+ exports[`test pill given the visual state is SUCCESS return a green colored pill 1`] = `
74
+ <View
75
+ style={
76
+ [
77
+ {
78
+ "alignItems": "center",
79
+ "borderRadius": 50,
80
+ "justifyContent": "center",
81
+ "paddingHorizontal": 8,
82
+ "paddingVertical": 4,
83
+ },
84
+ false,
85
+ {
86
+ "backgroundColor": "#83D56C",
87
+ },
88
+ false,
89
+ false,
90
+ ]
91
+ }
92
+ >
93
+ <Text
94
+ style={
95
+ {
96
+ "color": "#FFFFFF",
97
+ "fontFamily": "MontserratBold",
98
+ "fontSize": 11,
99
+ "lineHeight": 17.9,
100
+ }
101
+ }
102
+ >
103
+ Voldaan
104
+ </Text>
105
+ </View>
106
+ `;
107
+
108
+ exports[`test pill given the visual state is Warning return a orange colored pill 1`] = `
109
+ <View
110
+ style={
111
+ [
112
+ {
113
+ "alignItems": "center",
114
+ "borderRadius": 50,
115
+ "justifyContent": "center",
116
+ "paddingHorizontal": 8,
117
+ "paddingVertical": 4,
118
+ },
119
+ false,
120
+ false,
121
+ {
122
+ "backgroundColor": "#FCBF6F",
123
+ },
124
+ false,
125
+ ]
126
+ }
127
+ >
128
+ <Text
129
+ style={
130
+ {
131
+ "color": "#FFFFFF",
132
+ "fontFamily": "MontserratBold",
133
+ "fontSize": 11,
134
+ "lineHeight": 17.9,
135
+ }
136
+ }
137
+ >
138
+ Pas op
139
+ </Text>
140
+ </View>
141
+ `;
@@ -0,0 +1,23 @@
1
+ import React, {useContext} from 'react';
2
+ import {View, Text} from 'react-native';
3
+ import {ThemeCtx} from '../../../context/theme.context';
4
+ import {Stylesheet} from './pill.styles';
5
+ import {VisualState} from '../../../types/visual-state.enum';
6
+
7
+ type PillProps = {
8
+ variant: VisualState;
9
+ label: string;
10
+ };
11
+
12
+ const Pill = ({variant, label}: PillProps) => {
13
+ const context = useContext(ThemeCtx);
14
+ const styles = Stylesheet(context, variant);
15
+
16
+ return (
17
+ <View style={styles.container}>
18
+ <Text style={styles.label}>{label}</Text>
19
+ </View>
20
+ );
21
+ };
22
+
23
+ export {Pill as Pill};
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import {Pill} from './pill.component';
3
+ import {VisualState} from '../../../types/visual-state.enum';
4
+ const {View} = require('react-native');
5
+
6
+ export const PillPreview = ({}: {}) => {
7
+ return (
8
+ <View
9
+ style={{
10
+ flex: 1,
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ }}
14
+ >
15
+ <Pill variant={VisualState.DEFAULT} label="default" />
16
+ <Pill variant={VisualState.ERROR} label="error" />
17
+ <Pill variant={VisualState.WARNING} label="warning" />
18
+ <Pill variant={VisualState.SUCCESS} label="success" />
19
+ </View>
20
+ );
21
+ };
@@ -0,0 +1,32 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {VisualState} from '../../../types/visual-state.enum';
3
+ import {Font} from '../../../theme/font';
4
+
5
+ export const Stylesheet = (context, variant) =>
6
+ StyleSheet.create({
7
+ container: [
8
+ {
9
+ borderRadius: 50,
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ paddingVertical: 4,
13
+ paddingHorizontal: 8,
14
+ },
15
+ variant === VisualState.DEFAULT && {
16
+ backgroundColor: context.colors.main['5'],
17
+ },
18
+ variant === VisualState.SUCCESS && {
19
+ backgroundColor: context.colors.ui.success.default,
20
+ },
21
+ variant === VisualState.WARNING && {
22
+ backgroundColor: context.colors.ui.warning.default,
23
+ },
24
+ variant === VisualState.ERROR && {
25
+ backgroundColor: context.colors.ui.error.default,
26
+ },
27
+ ],
28
+ label: {
29
+ ...Font.tinyBold,
30
+ color: context.colors.ui.white,
31
+ },
32
+ });
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import {Pill} from './pill.component';
4
+
5
+ describe('test pill', () => {
6
+ it('given the visual state is Error return a red colored pill', () => {
7
+ const tree = renderer
8
+ .create(<Pill variant="ERROR" label="Geblokkeerd" />)
9
+ .toJSON();
10
+
11
+ expect(tree).toMatchSnapshot();
12
+ });
13
+ it('given the visual state is Warning return a orange colored pill', () => {
14
+ const tree = renderer
15
+ .create(<Pill variant="WARNING" label="Pas op" />)
16
+ .toJSON();
17
+
18
+ expect(tree).toMatchSnapshot();
19
+ });
20
+ it('given the visual state is SUCCESS return a green colored pill', () => {
21
+ const tree = renderer
22
+ .create(<Pill variant="SUCCESS" label="Voldaan" />)
23
+ .toJSON();
24
+
25
+ expect(tree).toMatchSnapshot();
26
+ });
27
+ it('given the visual state is DEFAULT return a blue/purple colored pill', () => {
28
+ const tree = renderer
29
+ .create(<Pill variant="DEFAULT" label="Default" />)
30
+ .toJSON();
31
+
32
+ expect(tree).toMatchSnapshot();
33
+ });
34
+ });
@@ -0,0 +1,40 @@
1
+ import React, {useContext, useMemo} from 'react';
2
+ import {ThemeCtx} from '../../../../../context/theme.context';
3
+ import {Animated} from 'react-native';
4
+ import {Stylesheet} from './backdrop.styles';
5
+
6
+ type PopoverBackdropProps = {
7
+ isVisible: boolean;
8
+ };
9
+
10
+ const Backdrop = ({isVisible}: PopoverBackdropProps) => {
11
+ const context = useContext(ThemeCtx);
12
+ const opacity = useMemo(() => new Animated.Value(0), []);
13
+
14
+ const styles = Stylesheet(context);
15
+
16
+ const open = () => {
17
+ Animated.timing(opacity, {
18
+ toValue: 0.75,
19
+ duration: 80,
20
+ useNativeDriver: true,
21
+ }).start();
22
+ };
23
+
24
+ const close = () => {
25
+ Animated.timing(opacity, {
26
+ toValue: 0,
27
+ duration: 600,
28
+ useNativeDriver: true,
29
+ }).start();
30
+ };
31
+
32
+ if (isVisible) {
33
+ open();
34
+ } else {
35
+ close();
36
+ }
37
+
38
+ return <Animated.View style={[styles.element, {opacity: opacity}]} />;
39
+ };
40
+ export {Backdrop as Backdrop};
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+
4
+ export const Stylesheet = (Context) =>
5
+ StyleSheet.create({
6
+ element: {
7
+ width: '100%',
8
+ height: '100%',
9
+ backgroundColor: Context.colors.ui.black,
10
+ zIndex: 1001,
11
+ position: 'absolute',
12
+ top: 0,
13
+ left: 0,
14
+ },
15
+ });
@@ -0,0 +1,17 @@
1
+ import React, {useContext} from 'react';
2
+ import {ThemeCtx} from '../../../../../context/theme.context';
3
+ import {View} from 'react-native';
4
+ import {Stylesheet} from './foreground.styles';
5
+ import {Modal} from '../modal/modal.component';
6
+
7
+ type PopoverForegroundProps = {
8
+ children: React.ReactElement<typeof Modal>;
9
+ };
10
+
11
+ const Foreground = ({children}: PopoverForegroundProps) => {
12
+ const context = useContext(ThemeCtx);
13
+ const styles = Stylesheet(context);
14
+
15
+ return <View style={styles.element}>{children}</View>;
16
+ };
17
+ export {Foreground as Foreground};
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+ import {Scale} from '../../../../../theme/scale';
4
+
5
+ export const Stylesheet = (Context) =>
6
+ StyleSheet.create({
7
+ element: {
8
+ width: '100%',
9
+ height: '100%',
10
+ paddingRight: Scale.xs,
11
+ paddingLeft: Scale.xs,
12
+ zIndex: 1002,
13
+ position: 'absolute',
14
+ top: 0,
15
+ left: 0,
16
+ },
17
+ });
@@ -0,0 +1,5 @@
1
+ import {Backdrop} from './backdrop/backdrop.component';
2
+ import {Foreground} from './foreground/foreground.component';
3
+ import {Modal} from './modal/modal.component';
4
+
5
+ export {Backdrop, Foreground, Modal};
@@ -0,0 +1,21 @@
1
+ import React, {useContext} from 'react';
2
+ import {GestureResponderEvent, Pressable} from 'react-native';
3
+ import {CrossIcon} from '../../../../../../icons/outline/cross/cross.icon';
4
+ import {Stylesheet} from './close.styles';
5
+ import {ThemeCtx} from '../../../../../../context/theme.context';
6
+
7
+ type ModalCloseProps = {
8
+ onPress: (event: GestureResponderEvent) => void;
9
+ };
10
+
11
+ const Close = ({onPress}: ModalCloseProps) => {
12
+ const context = useContext(ThemeCtx);
13
+ const styles = Stylesheet(context);
14
+
15
+ return (
16
+ <Pressable onPress={onPress} style={styles.element}>
17
+ <CrossIcon />
18
+ </Pressable>
19
+ );
20
+ };
21
+ export {Close as Close};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+
4
+ export const Stylesheet = (Context) =>
5
+ StyleSheet.create({
6
+ element: {
7
+ color: Context.colors.ui.darkgrey,
8
+ position: 'absolute',
9
+ top: 20,
10
+ right: 20,
11
+ zIndex: 1003,
12
+ },
13
+ });
@@ -0,0 +1,22 @@
1
+ import React, {useContext} from 'react';
2
+ import {Text, View} from 'react-native';
3
+ import {Stylesheet} from './heading.styles';
4
+ import {ThemeCtx} from '../../../../../../context/theme.context';
5
+
6
+ type ModalHeadingProps = {
7
+ title: string;
8
+ subtitle?: string;
9
+ };
10
+
11
+ const Heading = ({title, subtitle}: ModalHeadingProps) => {
12
+ const context = useContext(ThemeCtx);
13
+ const styles = Stylesheet(context);
14
+
15
+ return (
16
+ <View style={styles.element}>
17
+ <Text style={styles.title}>{title}</Text>
18
+ {subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : ''}
19
+ </View>
20
+ );
21
+ };
22
+ export {Heading as Heading};
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+ import {Font} from '../../../../../../theme/font';
4
+ import {Scale} from '../../../../../../theme/scale';
5
+
6
+ export const Stylesheet = (Context) =>
7
+ StyleSheet.create({
8
+ element: {
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ marginBottom: Scale.xl,
12
+ },
13
+ title: {
14
+ ...Font.bigBold,
15
+ display: 'flex',
16
+ textAlign: 'center',
17
+ },
18
+ subtitle: {
19
+ ...Font.large,
20
+ display: 'flex',
21
+ textAlign: 'center',
22
+ marginTop: Scale.xxs,
23
+ },
24
+ });
@@ -0,0 +1,87 @@
1
+ import React, {useContext, useEffect, useMemo, useState} from 'react';
2
+ import {Animated, Dimensions} from 'react-native';
3
+ import {Stylesheet} from './modal.styles';
4
+ import {Close} from './close/close.component';
5
+ import {Heading} from './heading/heading.component';
6
+ import {ScrollContent} from './scroll-content/scroll-content.component';
7
+ import {ThemeCtx} from '../../../../../context/theme.context';
8
+
9
+ type PopoverModalProps = {
10
+ onClose: () => void;
11
+ title: string;
12
+ subtitle?: string;
13
+ isVisible: boolean;
14
+ children: React.ReactNode;
15
+ windowHeight: number;
16
+ };
17
+
18
+ const Modal = ({
19
+ isVisible,
20
+ title,
21
+ subtitle,
22
+ onClose,
23
+ children,
24
+ windowHeight,
25
+ }: PopoverModalProps) => {
26
+ // Keep element and window size in local state.
27
+ const [elementSize, setElementSize] = useState({width: 0, height: 0});
28
+
29
+ // Load theme and apply theme context to styleguide.
30
+ const context = useContext(ThemeCtx);
31
+ const styles = Stylesheet(context);
32
+
33
+ const elementHeight = Math.round(elementSize.height);
34
+
35
+ const maxHeight = Math.round(windowHeight / 100) * 80;
36
+ const translateYStartingPoint = windowHeight;
37
+
38
+ const saveHeight = elementHeight > maxHeight ? maxHeight : elementHeight;
39
+
40
+ const translateY = useMemo(
41
+ () => new Animated.Value(translateYStartingPoint),
42
+ [translateYStartingPoint]
43
+ );
44
+
45
+ const open = () => {
46
+ Animated.timing(translateY, {
47
+ toValue: translateYStartingPoint - saveHeight,
48
+ duration: 500,
49
+ useNativeDriver: true,
50
+ }).start();
51
+ };
52
+
53
+ const close = () => {
54
+ Animated.timing(translateY, {
55
+ toValue: translateYStartingPoint,
56
+ duration: 500,
57
+ useNativeDriver: true,
58
+ }).start();
59
+ };
60
+
61
+ if (isVisible) {
62
+ open();
63
+ } else {
64
+ close();
65
+ }
66
+
67
+ const transform = [{translateY: translateY}];
68
+
69
+ console.log(maxHeight);
70
+
71
+ return (
72
+ <Animated.View
73
+ style={[styles.element, {maxHeight: maxHeight}, {transform: transform}]}
74
+ onLayout={(event) => {
75
+ const {width, height} = event.nativeEvent.layout;
76
+ setElementSize({width: width, height: height});
77
+ }}
78
+ >
79
+ <Close onPress={onClose} />
80
+ <Animated.View style={styles.inner}>
81
+ <Heading title={title} subtitle={subtitle} />
82
+ <ScrollContent>{children}</ScrollContent>
83
+ </Animated.View>
84
+ </Animated.View>
85
+ );
86
+ };
87
+ export {Modal as Modal};
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+ import {Scale} from '../../../../../theme/scale';
4
+
5
+ export const Stylesheet = (Context) =>
6
+ StyleSheet.create({
7
+ element: {
8
+ position: 'relative',
9
+ display: 'flex',
10
+ alignItems: 'stretch',
11
+ paddingTop: Scale.m,
12
+ paddingBottom: Scale.m,
13
+ paddingLeft: Scale.m,
14
+ paddingRight: Scale.m,
15
+ borderTopLeftRadius: Scale.l,
16
+ borderTopRightRadius: Scale.l,
17
+ backgroundColor: Context.colors.ui.white,
18
+ },
19
+ inner: {
20
+ display: 'flex',
21
+ alignItems: 'stretch',
22
+ },
23
+ });
@@ -0,0 +1,18 @@
1
+ import React, {useContext} from 'react';
2
+ import {Animated, ScrollView, Text, View} from 'react-native';
3
+ import {Stylesheet} from './scroll-content.styles';
4
+ import {ThemeCtx} from '../../../../../../context/theme.context';
5
+
6
+ type ModalScrollContentProps = {
7
+ children: React.ReactNode;
8
+ };
9
+
10
+ const ScrollContent = ({children}: ModalScrollContentProps) => {
11
+ const context = useContext(ThemeCtx);
12
+ const styles = Stylesheet(context);
13
+
14
+ return (
15
+ <ScrollView contentContainerStyle={styles.element}>{children}</ScrollView>
16
+ );
17
+ };
18
+ export {ScrollContent as ScrollContent};
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import {StyleSheet} from 'react-native';
3
+
4
+ export const Stylesheet = (Context) =>
5
+ StyleSheet.create({
6
+ element: {
7
+ display: 'flex',
8
+ alignItems: 'stretch',
9
+ },
10
+ });
@@ -0,0 +1,60 @@
1
+ import React, {useContext, useEffect, useState} from 'react';
2
+ import {ThemeCtx} from '../../../context/theme.context';
3
+ import {Dimensions, View} from 'react-native';
4
+ import {Stylesheet} from './popover.styles';
5
+ import {Backdrop, Modal, Foreground} from './components';
6
+
7
+ type PopoverProps = {
8
+ onClose: () => void;
9
+ title: string;
10
+ subtitle?: string;
11
+ isVisible: boolean;
12
+ children?: React.ReactNode;
13
+ };
14
+
15
+ const window = Dimensions.get('window');
16
+
17
+ const Popover = ({
18
+ isVisible,
19
+ title,
20
+ subtitle,
21
+ onClose,
22
+ children,
23
+ }: PopoverProps) => {
24
+ // Keep element and window size in local state.
25
+ const [windowHeight, setWindowHeight] = useState(window.height);
26
+ const [windowWidth, setWindowWidth] = useState(window.width);
27
+
28
+ // Subscribe to change events
29
+ useEffect(() => {
30
+ const subscription = Dimensions.addEventListener('change', ({window}) => {
31
+ setWindowHeight(window.height);
32
+ setWindowWidth(window.width);
33
+ });
34
+ return () => subscription?.remove();
35
+ });
36
+
37
+ const context = useContext(ThemeCtx);
38
+ const styles = Stylesheet(context);
39
+
40
+ return (
41
+ <View
42
+ style={[styles.element, {width: windowWidth, height: windowHeight}]}
43
+ pointerEvents={isVisible ? 'auto' : 'none'}
44
+ >
45
+ <Backdrop isVisible={isVisible} />
46
+ <Foreground>
47
+ <Modal
48
+ windowHeight={windowHeight}
49
+ isVisible={isVisible}
50
+ onClose={onClose}
51
+ title={title}
52
+ subtitle={subtitle}
53
+ >
54
+ {children}
55
+ </Modal>
56
+ </Foreground>
57
+ </View>
58
+ );
59
+ };
60
+ export {Popover as Popover};