@tactics/toddle-styleguide 4.1.0 → 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/package.json +1 -1
- package/src/components/molecules/swipeable/swipeable-action.component.tsx +9 -1
- package/src/components/molecules/swipeable/swipeable-action.styles.js +4 -1
- package/src/components/molecules/swipeable/swipeable-container.component.d.ts +5 -2
- package/src/components/molecules/swipeable/swipeable-container.component.tsx +23 -15
- package/src/components/organisms/child-list-item/child-list-item.preview.tsx +20 -6
package/package.json
CHANGED
|
@@ -31,6 +31,8 @@ export const SwipeableAction = ({
|
|
|
31
31
|
return context.colors.ui.warning.dark;
|
|
32
32
|
case VisualState.INACTIVE:
|
|
33
33
|
return context.colors.ui.darkgrey;
|
|
34
|
+
case VisualState.DEFAULT:
|
|
35
|
+
return context.colors.main[5];
|
|
34
36
|
default:
|
|
35
37
|
return context.colors.ui.darkgrey;
|
|
36
38
|
}
|
|
@@ -43,7 +45,13 @@ export const SwipeableAction = ({
|
|
|
43
45
|
style={[{backgroundColor: calculateBackgroundColor(visualState)},styles.container]}
|
|
44
46
|
>
|
|
45
47
|
{icon}
|
|
46
|
-
<Text
|
|
48
|
+
<Text
|
|
49
|
+
numberOfLines={2}
|
|
50
|
+
ellipsizeMode="tail"
|
|
51
|
+
style={styles.text}
|
|
52
|
+
>
|
|
53
|
+
{label}
|
|
54
|
+
</Text>
|
|
47
55
|
</RectButton>
|
|
48
56
|
);
|
|
49
57
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { VisualState } from "../../../types/visual-state.enum";
|
|
3
3
|
type SwipeableContainerProps = {
|
|
4
|
+
actions: SwipeableContainerAction[];
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type SwipeableContainerAction = {
|
|
4
8
|
visualState: VisualState;
|
|
5
9
|
label: string;
|
|
6
10
|
icon: React.ReactElement;
|
|
7
11
|
onPress: () => void;
|
|
8
|
-
children: React.ReactNode;
|
|
9
12
|
};
|
|
10
|
-
export declare const SwipeableContainer: ({
|
|
13
|
+
export declare const SwipeableContainer: ({ actions, children }: SwipeableContainerProps) => React.JSX.Element;
|
|
11
14
|
export {};
|
|
@@ -6,25 +6,29 @@ import {Stylesheet} from './swipeable-container.styles';
|
|
|
6
6
|
import {ThemeCtx} from '../../../context/theme.context';
|
|
7
7
|
|
|
8
8
|
type SwipeableContainerProps = {
|
|
9
|
+
actions: SwipeableContainerAction[];
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type SwipeableContainerAction = {
|
|
9
14
|
visualState: VisualState;
|
|
10
15
|
label: string;
|
|
11
16
|
icon: React.ReactElement;
|
|
12
17
|
onPress: () => void;
|
|
13
|
-
|
|
14
|
-
};
|
|
18
|
+
}
|
|
15
19
|
|
|
16
20
|
export const SwipeableContainer = ({
|
|
17
|
-
|
|
18
|
-
icon,
|
|
19
|
-
visualState,
|
|
20
|
-
onPress,
|
|
21
|
+
actions,
|
|
21
22
|
children
|
|
22
23
|
}: SwipeableContainerProps) => {
|
|
23
24
|
const styles = Stylesheet();
|
|
24
25
|
const swipeableRef = React.useRef<Swipeable>(null);
|
|
25
26
|
const context = useContext(ThemeCtx);
|
|
26
27
|
|
|
27
|
-
const calculateBackgroundColor = (
|
|
28
|
+
const calculateBackgroundColor = () => {
|
|
29
|
+
const lastAction = actions[actions.length - 1];
|
|
30
|
+
const visualState = lastAction?.visualState;
|
|
31
|
+
|
|
28
32
|
switch (visualState) {
|
|
29
33
|
case VisualState.ERROR:
|
|
30
34
|
return context.colors.ui.error.default;
|
|
@@ -34,27 +38,31 @@ export const SwipeableContainer = ({
|
|
|
34
38
|
return context.colors.ui.warning.dark;
|
|
35
39
|
case VisualState.INACTIVE:
|
|
36
40
|
return context.colors.ui.darkgrey;
|
|
41
|
+
case VisualState.DEFAULT:
|
|
42
|
+
return context.colors.main[5];
|
|
37
43
|
default:
|
|
38
44
|
return context.colors.ui.darkgrey;
|
|
39
45
|
}
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
const renderLeftActions = () => {
|
|
43
|
-
return (
|
|
44
|
-
<SwipeableAction
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
return actions.map(i => {
|
|
50
|
+
return <SwipeableAction
|
|
51
|
+
key={i.label}
|
|
52
|
+
label={i.label}
|
|
53
|
+
visualState={i.visualState}
|
|
54
|
+
icon={i.icon}
|
|
48
55
|
onPress={() => {
|
|
49
|
-
onPress();
|
|
56
|
+
i.onPress();
|
|
50
57
|
swipeableRef.current?.close();
|
|
51
58
|
}}
|
|
52
|
-
|
|
59
|
+
/>
|
|
60
|
+
}
|
|
53
61
|
);
|
|
54
62
|
};
|
|
55
63
|
|
|
56
64
|
return (
|
|
57
|
-
<Swipeable renderLeftActions={renderLeftActions} ref={swipeableRef} containerStyle={[{backgroundColor: calculateBackgroundColor(
|
|
65
|
+
<Swipeable renderLeftActions={renderLeftActions} ref={swipeableRef} containerStyle={[{backgroundColor: calculateBackgroundColor()},styles.container]}>
|
|
58
66
|
{children}
|
|
59
67
|
</Swipeable>
|
|
60
68
|
);
|
|
@@ -62,14 +62,28 @@ export const ChildListItemPreview = ({}: {}) => {
|
|
|
62
62
|
const [isLoading, setIsLoading] = useState(false);
|
|
63
63
|
|
|
64
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
|
+
|
|
65
84
|
return (
|
|
66
85
|
<SwipeableContainer
|
|
67
|
-
|
|
68
|
-
label='Afwezig'
|
|
69
|
-
visualState={VisualState.ERROR}
|
|
70
|
-
onPress={() => {
|
|
71
|
-
console.log('Afwezig');
|
|
72
|
-
}}
|
|
86
|
+
actions={swipeableActions}
|
|
73
87
|
>
|
|
74
88
|
<ChildListItem
|
|
75
89
|
id={item.id}
|