@tactics/toddle-styleguide 4.0.2 → 4.1.0

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/index.d.ts CHANGED
@@ -63,6 +63,8 @@ import { TimetableEditorStaff } from './src/components/organisms/timetable-edito
63
63
  import { InlineError } from './src/components/molecules/inline-error/inline-error.component';
64
64
  import { InlineNotice } from './src/components/molecules/inline-notice/inline-notice.component';
65
65
  import { SelectableListItem } from './src/components/molecules/selectable-list-item/selectable-list-item.component';
66
+ import { SwipeableContainer } from './src/components/molecules/swipeable/swipeable-container.component';
67
+ import { SwipeableAction } from './src/components/molecules/swipeable/swipeable-action.component';
66
68
  import { BubbleAlignment } from './src/types/bubble-alignment.enum';
67
69
  import { KeyBoardTypes } from './src/types/keyboard-types.enum';
68
70
  import { Size } from './src/types/size.enum';
@@ -74,4 +76,4 @@ import { ToddleDateTime } from './src/utilities/toddle-datetime/toddle-datetime.
74
76
  import { ThemeCtx } from './src/context/theme.context';
75
77
  import { Scale } from './src/theme/scale/index';
76
78
  import CreateResponsiveStyle from './src/theme/responsive/index';
77
- export { AllCapsHeading, Avatar, BackgroundGradient, BlockedMessage, Button, Calendar, CalendarSelect, CancelLink, Check, Checkbox, ChildListItem, ContactItem, ContactRole, DateInput, DefaultSelect, DepartmentLogo, FilterRange, FilterTab, Footer, Heading1, Heading2, Heading3, Heading4, Icon, ImageBubble, IncrementInput, Info, JournalEntry, LanguageButton, Line, LoadingIndicator, Logo, MessageInput, Modal, MoreInfoButton, MyChildListItem, Paragraph, PasswordInput, PersonInfoCard, Pill, Popover, PressableIcon, QuickFilter, QuickMessage, Search, SelectLink, SelectListItem, SelectPicker, SmallText, Snackbar, SplitContainer, Tag, TextBubble, TextInput, TimeLine, TimePicker, TimeTracker, TinyText, WaveBackground, WideButton, BubbleAlignment, Initials, KeyBoardTypes, Size, ThemeCtx, ToddleDateTime, VisualState, CreateResponsiveStyle, Scale, TimetableEdit, ContextLabel, Count, Amount, TimetableEditor, TimetableEditorStaff, TimeSlotRecord, TimeSlotSequence, InlineError, InlineNotice, SelectableListItem };
79
+ export { AllCapsHeading, Avatar, BackgroundGradient, BlockedMessage, Button, Calendar, CalendarSelect, CancelLink, Check, Checkbox, ChildListItem, ContactItem, ContactRole, DateInput, DefaultSelect, DepartmentLogo, FilterRange, FilterTab, Footer, Heading1, Heading2, Heading3, Heading4, Icon, ImageBubble, IncrementInput, Info, JournalEntry, LanguageButton, Line, LoadingIndicator, Logo, MessageInput, Modal, MoreInfoButton, MyChildListItem, Paragraph, PasswordInput, PersonInfoCard, Pill, Popover, PressableIcon, QuickFilter, QuickMessage, Search, SelectLink, SelectListItem, SelectPicker, SmallText, Snackbar, SplitContainer, Tag, TextBubble, TextInput, TimeLine, TimePicker, TimeTracker, TinyText, WaveBackground, WideButton, BubbleAlignment, Initials, KeyBoardTypes, Size, ThemeCtx, ToddleDateTime, VisualState, CreateResponsiveStyle, Scale, TimetableEdit, ContextLabel, Count, Amount, TimetableEditor, TimetableEditorStaff, TimeSlotRecord, TimeSlotSequence, InlineError, InlineNotice, SelectableListItem, SwipeableContainer, SwipeableAction, };
package/index.tsx CHANGED
@@ -84,6 +84,8 @@ import { TimetableEditorStaff } from './src/components/organisms/timetable-edito
84
84
  import { InlineError } from './src/components/molecules/inline-error/inline-error.component';
85
85
  import { InlineNotice } from './src/components/molecules/inline-notice/inline-notice.component';
86
86
  import { SelectableListItem } from './src/components/molecules/selectable-list-item/selectable-list-item.component';
87
+ import { SwipeableContainer } from './src/components/molecules/swipeable/swipeable-container.component';
88
+ import { SwipeableAction } from './src/components/molecules/swipeable/swipeable-action.component';
87
89
 
88
90
  // Exports of enums
89
91
  import {BubbleAlignment} from './src/types/bubble-alignment.enum';
@@ -188,5 +190,7 @@ export {
188
190
  TimeSlotSequence,
189
191
  InlineError,
190
192
  InlineNotice,
191
- SelectableListItem
193
+ SelectableListItem,
194
+ SwipeableContainer,
195
+ SwipeableAction,
192
196
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -8,6 +8,7 @@ export const QuickFilterPreview = ({}: {}) => {
8
8
  const [successFilterIsSelected, setSuccessFilterIsSelected] = useState(false);
9
9
  const [errorFilterIsSelected, setErrorFilterIsSelected] = useState(false);
10
10
  const [warningFilterIsSelected, setWarningFilterIsSelected] = useState(false);
11
+ const [absentFilterIsSelected, setAbsentFilterIsSelected] = useState(false);
11
12
 
12
13
  return (
13
14
  <View>
@@ -43,6 +44,14 @@ export const QuickFilterPreview = ({}: {}) => {
43
44
  visualState={State.EXPECTED}
44
45
  isSelected={warningFilterIsSelected}
45
46
  />
47
+ <QuickFilter
48
+ id={'5'}
49
+ isLoading={false}
50
+ amount={5}
51
+ onSelect={() => setAbsentFilterIsSelected((current) => !current)}
52
+ visualState={State.ABSENT}
53
+ isSelected={absentFilterIsSelected}
54
+ />
46
55
  </View>
47
56
  );
48
57
  };
@@ -39,5 +39,11 @@ export const Stylesheet = (context, visualState, isSelected) =>
39
39
  : context.colors.ui.white,
40
40
  borderColor: context.colors.state.out.dark,
41
41
  },
42
+ visualState === State.ABSENT && {
43
+ backgroundColor: isSelected
44
+ ? context.colors.state.absent.default
45
+ : context.colors.ui.white,
46
+ borderColor: context.colors.state.absent.dark,
47
+ },
42
48
  ],
43
49
  });
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { VisualState } from "../../../types/visual-state.enum";
3
+ type SwipeableActionProps = {
4
+ visualState: VisualState;
5
+ label: string;
6
+ icon: React.ReactElement;
7
+ onPress: () => void;
8
+ };
9
+ export declare const SwipeableAction: ({ label, icon, visualState, onPress, }: SwipeableActionProps) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,49 @@
1
+ import React, { useContext } from "react";
2
+ import { Text } from "react-native";
3
+ import { RectButton } from "react-native-gesture-handler";
4
+ import { VisualState } from "../../../types/visual-state.enum";
5
+ import {Stylesheet} from './swipeable-action.styles';
6
+ import {ThemeCtx} from '../../../context/theme.context';
7
+
8
+ type SwipeableActionProps = {
9
+ visualState: VisualState;
10
+ label: string;
11
+ icon: React.ReactElement;
12
+ onPress: () => void;
13
+ };
14
+
15
+ export const SwipeableAction = ({
16
+ label,
17
+ icon,
18
+ visualState,
19
+ onPress,
20
+ }: SwipeableActionProps) => {
21
+ const styles = Stylesheet();
22
+ const context = useContext(ThemeCtx);
23
+
24
+ const calculateBackgroundColor = (visualState: VisualState) => {
25
+ switch (visualState) {
26
+ case VisualState.ERROR:
27
+ return context.colors.ui.error.default;
28
+ case VisualState.SUCCESS:
29
+ return context.colors.ui.success.dark;
30
+ case VisualState.WARNING:
31
+ return context.colors.ui.warning.dark;
32
+ case VisualState.INACTIVE:
33
+ return context.colors.ui.darkgrey;
34
+ default:
35
+ return context.colors.ui.darkgrey;
36
+ }
37
+ };
38
+
39
+
40
+ return (
41
+ <RectButton
42
+ onPress={onPress}
43
+ style={[{backgroundColor: calculateBackgroundColor(visualState)},styles.container]}
44
+ >
45
+ {icon}
46
+ <Text style={styles.text}>{label}</Text>
47
+ </RectButton>
48
+ );
49
+ };
@@ -0,0 +1,12 @@
1
+ export function Stylesheet(): {
2
+ container: {
3
+ alignItems: "center";
4
+ justifyContent: "center";
5
+ gap: number;
6
+ color: string;
7
+ paddingHorizontal: number;
8
+ };
9
+ text: {
10
+ color: string;
11
+ };
12
+ };
@@ -0,0 +1,17 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {Scale} from '../../../theme/scale/index';
3
+
4
+ export const Stylesheet = () =>
5
+ StyleSheet.create({
6
+ container: {
7
+ alignItems: 'center',
8
+ justifyContent: 'center',
9
+ gap: Scale.xs,
10
+ color: '#fff',
11
+ paddingHorizontal: Scale.xl,
12
+ },
13
+ text: {
14
+ color: '#fff'
15
+ }
16
+ }
17
+ );
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { VisualState } from "../../../types/visual-state.enum";
3
+ type SwipeableContainerProps = {
4
+ visualState: VisualState;
5
+ label: string;
6
+ icon: React.ReactElement;
7
+ onPress: () => void;
8
+ children: React.ReactNode;
9
+ };
10
+ export declare const SwipeableContainer: ({ label, icon, visualState, onPress, children }: SwipeableContainerProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1,61 @@
1
+ import React, { useContext } from "react";
2
+ import { Swipeable } from "react-native-gesture-handler";
3
+ import { VisualState } from "../../../types/visual-state.enum";
4
+ import { SwipeableAction } from "./swipeable-action.component";
5
+ import {Stylesheet} from './swipeable-container.styles';
6
+ import {ThemeCtx} from '../../../context/theme.context';
7
+
8
+ type SwipeableContainerProps = {
9
+ visualState: VisualState;
10
+ label: string;
11
+ icon: React.ReactElement;
12
+ onPress: () => void;
13
+ children: React.ReactNode;
14
+ };
15
+
16
+ export const SwipeableContainer = ({
17
+ label,
18
+ icon,
19
+ visualState,
20
+ onPress,
21
+ children
22
+ }: SwipeableContainerProps) => {
23
+ const styles = Stylesheet();
24
+ const swipeableRef = React.useRef<Swipeable>(null);
25
+ const context = useContext(ThemeCtx);
26
+
27
+ const calculateBackgroundColor = (visualState: VisualState) => {
28
+ switch (visualState) {
29
+ case VisualState.ERROR:
30
+ return context.colors.ui.error.default;
31
+ case VisualState.SUCCESS:
32
+ return context.colors.ui.success.dark;
33
+ case VisualState.WARNING:
34
+ return context.colors.ui.warning.dark;
35
+ case VisualState.INACTIVE:
36
+ return context.colors.ui.darkgrey;
37
+ default:
38
+ return context.colors.ui.darkgrey;
39
+ }
40
+ };
41
+
42
+ const renderLeftActions = () => {
43
+ return (
44
+ <SwipeableAction
45
+ label={label}
46
+ visualState={visualState}
47
+ icon={icon}
48
+ onPress={() => {
49
+ onPress();
50
+ swipeableRef.current?.close();
51
+ }}
52
+ />
53
+ );
54
+ };
55
+
56
+ return (
57
+ <Swipeable renderLeftActions={renderLeftActions} ref={swipeableRef} containerStyle={[{backgroundColor: calculateBackgroundColor(visualState)},styles.container]}>
58
+ {children}
59
+ </Swipeable>
60
+ );
61
+ };
@@ -0,0 +1,9 @@
1
+ export function Stylesheet(): {
2
+ container: {
3
+ borderTopLeftRadius: number;
4
+ borderBottomLeftRadius: number;
5
+ borderTopRightRadius: number;
6
+ borderBottomRightRadius: number;
7
+ overflow: "hidden";
8
+ };
9
+ };
@@ -0,0 +1,14 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {Scale} from '../../../theme/scale/index';
3
+
4
+ export const Stylesheet = () =>
5
+ StyleSheet.create({
6
+ container: {
7
+ borderTopLeftRadius: Scale.xl,
8
+ borderBottomLeftRadius: Scale.xl,
9
+ borderTopRightRadius: Scale.l,
10
+ borderBottomRightRadius: Scale.l,
11
+ overflow: 'hidden',
12
+ },
13
+ }
14
+ );
@@ -1,10 +1,13 @@
1
- import React, {useState} from 'react';
1
+ import React, {useContext, useState} from 'react';
2
2
  import {ChildListItem} from './child-list-item.component';
3
3
  import {FlatList, View} from 'react-native';
4
4
  import {VisualState} from '../../../types/visual-state.enum';
5
5
  import {PressableIcon} from '../../molecules/pressable-icon/pressable-icon.component';
6
6
  import {Icon} from '../../../icons/index';
7
7
  import {Initials} from '../../../models/initials.model';
8
+ import { GestureHandlerRootView, Swipeable } from 'react-native-gesture-handler';
9
+ import {ThemeCtx} from '../../../context/theme.context';
10
+ import { SwipeableContainer } from '../../molecules/swipeable/swipeable-container.component';
8
11
 
9
12
  interface IData {
10
13
  id: string;
@@ -35,6 +38,8 @@ export const ChildListItemPreview = ({}: {}) => {
35
38
  const [isSelectable, setIsSelectable] = useState(false);
36
39
  console.log(selectedIDs);
37
40
 
41
+ const context = useContext(ThemeCtx);
42
+
38
43
  const selectChildren = () => {
39
44
  if (!isSelectable) {
40
45
  setIsSelectable(true);
@@ -58,54 +63,65 @@ export const ChildListItemPreview = ({}: {}) => {
58
63
 
59
64
  const renderChildList = ({item}: any) => {
60
65
  return (
61
- <ChildListItem
62
- id={item.id}
63
- name={item.name}
64
- department={item.department}
65
- selectable={isSelectable}
66
- isSelected={isIdSelected(item.id)}
67
- onPressArrow={(id) => console.log(id + ' pressed')}
68
- onPressText={(id) => console.log('We will do something with id ' + id)}
69
- onLongPress={(id) => console.log('Do something with id ' + id)}
70
- onSelect={addIdToSelected}
71
- // sourceAvatar={require('./../../../../assets/components/avatar/baby.png')}
72
- sourceAvatar={Initials.for('Zeno', 'Driesen')}
73
- tags={item.tags}
74
- error={true}
75
- />
66
+ <SwipeableContainer
67
+ icon={<Icon name='clock' style='regular' size={20} color={context.colors.ui.white} />}
68
+ label='Afwezig'
69
+ visualState={VisualState.ERROR}
70
+ onPress={() => {
71
+ console.log('Afwezig');
72
+ }}
73
+ >
74
+ <ChildListItem
75
+ id={item.id}
76
+ name={item.name}
77
+ department={item.department}
78
+ selectable={isSelectable}
79
+ isSelected={isIdSelected(item.id)}
80
+ onPressArrow={(id) => console.log(id + ' pressed')}
81
+ onPressText={(id) => console.log('We will do something with id ' + id)}
82
+ onLongPress={(id) => console.log('Do something with id ' + id)}
83
+ onSelect={addIdToSelected}
84
+ // sourceAvatar={require('./../../../../assets/components/avatar/baby.png')}
85
+ sourceAvatar={Initials.for('Zeno', 'Driesen')}
86
+ tags={item.tags}
87
+ error={true}
88
+ />
89
+ </SwipeableContainer>
76
90
  );
77
91
  };
78
92
 
79
93
  return (
80
- <View
81
- style={{
82
- flex: 1,
83
- padding: 16,
84
- justifyContent: 'center',
85
- backgroundColor: 'white',
86
- }}
87
- >
88
- <View style={{alignItems: 'center', marginBottom: 28}}>
89
- <PressableIcon
90
- icon={
91
- <Icon
92
- style={'regular'}
93
- name={'sm-view-grid-add'}
94
- key={'unique key'}
95
- />
96
- }
97
- onPress={selectChildren}
98
- />
99
- </View>
100
- <FlatList
94
+ <GestureHandlerRootView style={{ flex: 1 }}>
95
+ <View
101
96
  style={{
102
97
  flex: 1,
98
+ padding: 16,
99
+ justifyContent: 'center',
100
+ backgroundColor: 'white',
103
101
  }}
104
- contentContainerStyle={{gap: 16}}
105
- data={data}
106
- renderItem={renderChildList}
107
- keyExtractor={(item) => item.id}
108
- />
109
- </View>
102
+ >
103
+ <View style={{alignItems: 'center', marginBottom: 28}}>
104
+ <PressableIcon
105
+ icon={
106
+ <Icon
107
+ style={'regular'}
108
+ name={'sm-view-grid-add'}
109
+ key={'unique key'}
110
+ />
111
+ }
112
+ onPress={selectChildren}
113
+ />
114
+ </View>
115
+ <FlatList
116
+ style={{
117
+ flex: 1,
118
+ }}
119
+ contentContainerStyle={{gap: 16}}
120
+ data={data}
121
+ renderItem={renderChildList}
122
+ keyExtractor={(item) => item.id}
123
+ />
124
+ </View>
125
+ </GestureHandlerRootView>
110
126
  );
111
127
  };
@@ -34,6 +34,10 @@ interface ThemeInterface {
34
34
  default: string;
35
35
  dark: string;
36
36
  };
37
+ absent: {
38
+ default: string;
39
+ dark: string;
40
+ };
37
41
  };
38
42
  ui: {
39
43
  black: string;
@@ -36,6 +36,10 @@ interface ThemeInterface {
36
36
  default: string;
37
37
  dark: string;
38
38
  };
39
+ absent: {
40
+ default: string;
41
+ dark: string;
42
+ };
39
43
  };
40
44
  ui: {
41
45
  black: string;
@@ -33,6 +33,10 @@ export declare const ParentTheme: {
33
33
  default: string;
34
34
  dark: string;
35
35
  };
36
+ absent: {
37
+ default: string;
38
+ dark: string;
39
+ };
36
40
  };
37
41
  ui: {
38
42
  black: string;
@@ -35,6 +35,10 @@ export const ParentTheme = {
35
35
  default: Colors.ui.success.default,
36
36
  dark: Colors.ui.success.dark,
37
37
  },
38
+ absent: {
39
+ default: Colors.ui.error.default,
40
+ dark: Colors.ui.error.dark,
41
+ },
38
42
  },
39
43
  ui: {
40
44
  black: Colors.ui.black,
@@ -33,6 +33,10 @@ export declare const StaffMemberTheme: {
33
33
  default: string;
34
34
  dark: string;
35
35
  };
36
+ absent: {
37
+ default: string;
38
+ dark: string;
39
+ };
36
40
  };
37
41
  ui: {
38
42
  black: string;
@@ -35,6 +35,10 @@ export const StaffMemberTheme = {
35
35
  default: Colors.ui.success.default,
36
36
  dark: Colors.ui.success.dark,
37
37
  },
38
+ absent: {
39
+ default: Colors.ui.error.default,
40
+ dark: Colors.ui.error.dark,
41
+ },
38
42
  },
39
43
  ui: {
40
44
  black: Colors.ui.black,
@@ -2,5 +2,6 @@ export declare enum State {
2
2
  UNPLANNED = "UNPLANNED",
3
3
  IN = "IN",
4
4
  OUT = "OUT",
5
- EXPECTED = "EXPECTED"
5
+ EXPECTED = "EXPECTED",
6
+ ABSENT = "ABSENT"
6
7
  }
@@ -3,4 +3,5 @@ export enum State {
3
3
  IN = 'IN',
4
4
  OUT = 'OUT',
5
5
  EXPECTED = 'EXPECTED',
6
+ ABSENT = 'ABSENT',
6
7
  }
@@ -48,6 +48,7 @@ export const StateTextColorHandler = (
48
48
  const expectedTextColor = context.colors.state.expected.dark;
49
49
  const inTextColor = context.colors.state.in.dark;
50
50
  const outTextColor = context.colors.state.out.dark;
51
+ const absentTextColor = context.colors.state.absent.dark;
51
52
 
52
53
  if (visualState === State.UNPLANNED) {
53
54
  if (selected && loading) return selectedTextColor;
@@ -65,5 +66,9 @@ export const StateTextColorHandler = (
65
66
  if (selected && loading) return selectedTextColor;
66
67
  if (selected && !loading) return selectedTextColor;
67
68
  return selected ? selectedTextColor : outTextColor;
69
+ } else if (visualState === State.ABSENT) {
70
+ if (selected && loading) return selectedTextColor;
71
+ if (selected && !loading) return selectedTextColor;
72
+ return selected ? selectedTextColor : absentTextColor;
68
73
  } else return context.colors.ui.white;
69
74
  };