@tactics/toddle-styleguide 4.0.2 → 4.2.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.2.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,57 @@
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
+ case VisualState.DEFAULT:
35
+ return context.colors.main[5];
36
+ default:
37
+ return context.colors.ui.darkgrey;
38
+ }
39
+ };
40
+
41
+
42
+ return (
43
+ <RectButton
44
+ onPress={onPress}
45
+ style={[{backgroundColor: calculateBackgroundColor(visualState)},styles.container]}
46
+ >
47
+ {icon}
48
+ <Text
49
+ numberOfLines={2}
50
+ ellipsizeMode="tail"
51
+ style={styles.text}
52
+ >
53
+ {label}
54
+ </Text>
55
+ </RectButton>
56
+ );
57
+ };
@@ -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,20 @@
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
+ maxWidth: 130,
13
+ paddingTop: Scale.xs,
14
+ },
15
+ text: {
16
+ color: '#fff',
17
+ textAlign: 'center',
18
+ }
19
+ }
20
+ );
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { VisualState } from "../../../types/visual-state.enum";
3
+ type SwipeableContainerProps = {
4
+ actions: SwipeableContainerAction[];
5
+ children: React.ReactNode;
6
+ };
7
+ type SwipeableContainerAction = {
8
+ visualState: VisualState;
9
+ label: string;
10
+ icon: React.ReactElement;
11
+ onPress: () => void;
12
+ };
13
+ export declare const SwipeableContainer: ({ actions, children }: SwipeableContainerProps) => React.JSX.Element;
14
+ export {};
@@ -0,0 +1,69 @@
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
+ actions: SwipeableContainerAction[];
10
+ children: React.ReactNode;
11
+ };
12
+
13
+ type SwipeableContainerAction = {
14
+ visualState: VisualState;
15
+ label: string;
16
+ icon: React.ReactElement;
17
+ onPress: () => void;
18
+ }
19
+
20
+ export const SwipeableContainer = ({
21
+ actions,
22
+ children
23
+ }: SwipeableContainerProps) => {
24
+ const styles = Stylesheet();
25
+ const swipeableRef = React.useRef<Swipeable>(null);
26
+ const context = useContext(ThemeCtx);
27
+
28
+ const calculateBackgroundColor = () => {
29
+ const lastAction = actions[actions.length - 1];
30
+ const visualState = lastAction?.visualState;
31
+
32
+ switch (visualState) {
33
+ case VisualState.ERROR:
34
+ return context.colors.ui.error.default;
35
+ case VisualState.SUCCESS:
36
+ return context.colors.ui.success.dark;
37
+ case VisualState.WARNING:
38
+ return context.colors.ui.warning.dark;
39
+ case VisualState.INACTIVE:
40
+ return context.colors.ui.darkgrey;
41
+ case VisualState.DEFAULT:
42
+ return context.colors.main[5];
43
+ default:
44
+ return context.colors.ui.darkgrey;
45
+ }
46
+ };
47
+
48
+ const renderLeftActions = () => {
49
+ return actions.map(i => {
50
+ return <SwipeableAction
51
+ key={i.label}
52
+ label={i.label}
53
+ visualState={i.visualState}
54
+ icon={i.icon}
55
+ onPress={() => {
56
+ i.onPress();
57
+ swipeableRef.current?.close();
58
+ }}
59
+ />
60
+ }
61
+ );
62
+ };
63
+
64
+ return (
65
+ <Swipeable renderLeftActions={renderLeftActions} ref={swipeableRef} containerStyle={[{backgroundColor: calculateBackgroundColor()},styles.container]}>
66
+ {children}
67
+ </Swipeable>
68
+ );
69
+ };
@@ -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);
@@ -57,55 +62,80 @@ export const ChildListItemPreview = ({}: {}) => {
57
62
  const [isLoading, setIsLoading] = useState(false);
58
63
 
59
64
  const renderChildList = ({item}: any) => {
65
+ const swipeableActions = [
66
+ {
67
+ visualState: VisualState.ERROR,
68
+ label: 'Afwezig',
69
+ icon: <Icon name='clock' style='regular' size={20} color={context.colors.ui.white} />,
70
+ onPress: () => {
71
+ console.log('Afwezig');
72
+ },
73
+ },
74
+ {
75
+ visualState: VisualState.DEFAULT,
76
+ label: 'Planning Wissen',
77
+ icon: <Icon name='clock' style='regular' size={20} color={context.colors.ui.white} />,
78
+ onPress: () => {
79
+ console.log('Planning Wissen');
80
+ },
81
+ }
82
+ ];
83
+
60
84
  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
- />
85
+ <SwipeableContainer
86
+ actions={swipeableActions}
87
+ >
88
+ <ChildListItem
89
+ id={item.id}
90
+ name={item.name}
91
+ department={item.department}
92
+ selectable={isSelectable}
93
+ isSelected={isIdSelected(item.id)}
94
+ onPressArrow={(id) => console.log(id + ' pressed')}
95
+ onPressText={(id) => console.log('We will do something with id ' + id)}
96
+ onLongPress={(id) => console.log('Do something with id ' + id)}
97
+ onSelect={addIdToSelected}
98
+ // sourceAvatar={require('./../../../../assets/components/avatar/baby.png')}
99
+ sourceAvatar={Initials.for('Zeno', 'Driesen')}
100
+ tags={item.tags}
101
+ error={true}
102
+ />
103
+ </SwipeableContainer>
76
104
  );
77
105
  };
78
106
 
79
107
  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
108
+ <GestureHandlerRootView style={{ flex: 1 }}>
109
+ <View
101
110
  style={{
102
111
  flex: 1,
112
+ padding: 16,
113
+ justifyContent: 'center',
114
+ backgroundColor: 'white',
103
115
  }}
104
- contentContainerStyle={{gap: 16}}
105
- data={data}
106
- renderItem={renderChildList}
107
- keyExtractor={(item) => item.id}
108
- />
109
- </View>
116
+ >
117
+ <View style={{alignItems: 'center', marginBottom: 28}}>
118
+ <PressableIcon
119
+ icon={
120
+ <Icon
121
+ style={'regular'}
122
+ name={'sm-view-grid-add'}
123
+ key={'unique key'}
124
+ />
125
+ }
126
+ onPress={selectChildren}
127
+ />
128
+ </View>
129
+ <FlatList
130
+ style={{
131
+ flex: 1,
132
+ }}
133
+ contentContainerStyle={{gap: 16}}
134
+ data={data}
135
+ renderItem={renderChildList}
136
+ keyExtractor={(item) => item.id}
137
+ />
138
+ </View>
139
+ </GestureHandlerRootView>
110
140
  );
111
141
  };
@@ -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
  };