@tactics/toddle-styleguide 1.7.14 → 1.7.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.7.14",
3
+ "version": "1.7.16",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface CountProps {
3
3
  count: number;
4
+ disabled?: boolean;
4
5
  }
5
- export declare const Count: ({ count, }: CountProps) => React.JSX.Element;
6
+ export declare const Count: ({ count, disabled }: CountProps) => React.JSX.Element;
6
7
  export {};
@@ -7,13 +7,15 @@ import { Paragraph } from "../paragraph-components";
7
7
 
8
8
  interface CountProps {
9
9
  count: number;
10
+ disabled?: boolean
10
11
  }
11
12
 
12
13
  export const Count = ({
13
14
  count,
15
+ disabled
14
16
  }: CountProps) => {
15
17
  const context = useContext(ThemeCtx);
16
- const styles = Stylesheet(context);
18
+ const styles = Stylesheet(context, disabled);
17
19
  return <View style={styles.container}>
18
20
  <Paragraph addStyle={styles.text}>{count}</Paragraph>
19
21
  </View>;
@@ -1,4 +1,4 @@
1
- export function Stylesheet(context: any): {
1
+ export function Stylesheet(context: any, disabled: any): {
2
2
  container: {
3
3
  borderWidth: number;
4
4
  borderColor: any;
@@ -16,5 +16,6 @@ export function Stylesheet(context: any): {
16
16
  text: {
17
17
  width: "auto";
18
18
  fontSize: number;
19
+ color: any;
19
20
  };
20
21
  };
@@ -1,24 +1,25 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
  import { Scale } from '../../../theme/scale';
3
3
 
4
- export const Stylesheet = (context) =>
4
+ export const Stylesheet = (context, disabled) =>
5
5
  StyleSheet.create({
6
6
  container: {
7
7
  borderWidth: 1,
8
- borderColor: context.colors.main['1'],
8
+ borderColor: disabled === true ? context.colors.ui.xlightgrey : context.colors.main['1'],
9
9
  borderRadius: 20,
10
10
  paddingVertical: Scale.xs,
11
11
  paddingHorizontal: Scale.m,
12
12
  minWidth: Scale.xxxl,
13
- color: context.colors.main['2'],
13
+ color: disabled === true ? context.colors.ui.grey : context.colors.main['2'],
14
14
  display: 'flex',
15
15
  alignItems: 'center',
16
16
  justifyContent: 'center',
17
17
  flex: 0,
18
- backgroundColor: context.colors.ui.white
18
+ backgroundColor: disabled === true ? context.colors.ui.xlightgrey : context.colors.ui.white
19
19
  },
20
20
  text: {
21
21
  width: 'auto',
22
- fontSize: Scale.m
22
+ fontSize: Scale.m,
23
+ color: disabled === true ? context.colors.ui.grey : context.colors.main['2'],
23
24
  }
24
25
  });
@@ -6,6 +6,7 @@ interface AmountProps {
6
6
  label: string;
7
7
  description?: string;
8
8
  onSave: (num: number) => void;
9
+ readonly: boolean;
9
10
  }
10
- export declare const Amount: ({ initialAmount, image, label, description, onSave }: AmountProps) => React.JSX.Element;
11
+ export declare const Amount: ({ initialAmount, image, label, description, onSave, readonly }: AmountProps) => React.JSX.Element;
11
12
  export {};
@@ -14,7 +14,8 @@ interface AmountProps {
14
14
  image?: ImageSourcePropType;
15
15
  label: string;
16
16
  description?: string;
17
- onSave: (num: number) => void
17
+ onSave: (num: number) => void;
18
+ readonly: boolean
18
19
  }
19
20
 
20
21
  export const Amount = ({
@@ -22,7 +23,8 @@ export const Amount = ({
22
23
  image,
23
24
  label,
24
25
  description,
25
- onSave
26
+ onSave,
27
+ readonly
26
28
  }: AmountProps) => {
27
29
  const [editMode, setEditMode] = useState(false);
28
30
  const [countdown, setCountdown] = useState(0);
@@ -80,6 +82,32 @@ export const Amount = ({
80
82
  </>
81
83
  }
82
84
 
85
+ const renderInput = () => {
86
+ return <View style={styles.incrementContainer}>
87
+ {editMode ? (
88
+ <>
89
+ <View>
90
+ <IncrementInput value={amount} onPress={updateAmount} />
91
+ </View>
92
+ <PressableIcon
93
+ onPress={saveChargedProduct}
94
+ icon={
95
+ <Icon key={label} name="check-circle" style="regular" />
96
+ }
97
+ />
98
+ </>
99
+ ) : (
100
+ <Pressable onPress={startEditMode}>
101
+ <Count count={amount} />
102
+ </Pressable>
103
+ )}
104
+ </View>
105
+ }
106
+
107
+ const renderCount = () => {
108
+ return <Count disabled={true} count={amount} />
109
+ }
110
+
83
111
  return (
84
112
  <View style={styles.rootContainer}>
85
113
  <View style={styles.imageContainer}>
@@ -88,25 +116,7 @@ export const Amount = ({
88
116
  <View style={styles.container}>
89
117
  <Paragraph bold={true} numberOfLines={1} ellipsizeMode="tail">{label}</Paragraph>
90
118
  {description ? <Paragraph textColor={context.colors.ui.darkgrey} numberOfLines={1} ellipsizeMode="tail">{description}</Paragraph> : <></>}
91
- <View style={styles.incrementContainer}>
92
- {editMode ? (
93
- <>
94
- <View>
95
- <IncrementInput value={amount} onPress={updateAmount} />
96
- </View>
97
- <PressableIcon
98
- onPress={saveChargedProduct}
99
- icon={
100
- <Icon key={label} name="check-circle" style="regular" />
101
- }
102
- />
103
- </>
104
- ) : (
105
- <Pressable onPress={startEditMode}>
106
- <Count count={amount} />
107
- </Pressable>
108
- )}
109
- </View>
119
+ {readonly ? renderCount() : renderInput()}
110
120
  </View>
111
121
  </View>
112
122
  );
@@ -12,10 +12,14 @@ export const AmountPreview = ({}: {}) => {
12
12
  backgroundColor: 'white',
13
13
  }}
14
14
  >
15
- <Amount initialAmount={9} label='Maaltijd' onSave={(num) => console.log(num)} />
16
- <Amount initialAmount={2} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd' onSave={(num) => console.log(num)} />
17
- <Amount initialAmount={5} label='Maaltijd veggy' description='Hmm, lekker hoor' onSave={(num) => console.log(num)} />
18
- <Amount initialAmount={1} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd met een lekkere lange titel' description='Hmm, lekker hoor. Met een sappige beschrijving' onSave={(num) => console.log(num)} />
15
+ <Amount readonly={false} initialAmount={9} label='Maaltijd' onSave={(num) => console.log(num)} />
16
+ <Amount readonly={false} initialAmount={2} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd' onSave={(num) => console.log(num)} />
17
+ <Amount readonly={false} initialAmount={5} label='Maaltijd veggy' description='Hmm, lekker hoor' onSave={(num) => console.log(num)} />
18
+ <Amount readonly={false} initialAmount={1} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd met een lekkere lange titel' description='Hmm, lekker hoor. Met een sappige beschrijving' onSave={(num) => console.log(num)} />
19
+ <Amount readonly={true} initialAmount={9} label='Maaltijd' onSave={(num) => console.log(num)} />
20
+ <Amount readonly={true} initialAmount={2} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd' onSave={(num) => console.log(num)} />
21
+ <Amount readonly={true} initialAmount={5} label='Maaltijd veggy' description='Hmm, lekker hoor' onSave={(num) => console.log(num)} />
22
+ <Amount readonly={true} initialAmount={1} image={require('./../../../../assets/components/avatar/baby.png')} label='Maaltijd met een lekkere lange titel' description='Hmm, lekker hoor. Met een sappige beschrijving' onSave={(num) => console.log(num)} />
19
23
  </View>
20
24
  </ScrollView>
21
25
  );
@@ -9,79 +9,88 @@ import {Icon} from '../../../icons/index';
9
9
  import { useDebounce } from '../../../hooks/use-debounce';
10
10
 
11
11
  type CalendarSelectProps = {
12
- onPressDate: (date: ToddleDateTime) => void;
13
- startDate: ToddleDateTime;
14
- onUpdateDate: (date: ToddleDateTime) => void;
12
+ onPressDate: (date: ToddleDateTime) => void;
13
+ startDate: ToddleDateTime;
14
+ onUpdateDate: (date: ToddleDateTime) => void;
15
+ labelForToday: string | undefined
15
16
  };
16
17
 
17
18
  const CalendarSelect = ({
18
- onPressDate,
19
- startDate,
20
- onUpdateDate,
21
- }: CalendarSelectProps) => {
22
- const context = useContext(ThemeCtx);
23
- const styles = Stylesheet(context);
19
+ onPressDate,
20
+ startDate,
21
+ onUpdateDate,
22
+ labelForToday
23
+ }: CalendarSelectProps) => {
24
+ const context = useContext(ThemeCtx);
25
+ const styles = Stylesheet(context);
24
26
 
25
- const [visibleDate, setVisibleDate] = useState(startDate);
26
- const debouncedVisibleDate = useDebounce<ToddleDateTime>(visibleDate, 500);
27
+ const today = ToddleDateTime.now();
28
+ const isToday = today.toISO() === startDate.toISO();
27
29
 
28
- useEffect(() => {
29
- setVisibleDate(startDate);
30
- }, [startDate]);
30
+ const [visibleDate, setVisibleDate] = useState(startDate);
31
+ const debouncedVisibleDate = useDebounce<ToddleDateTime>(visibleDate, 500);
31
32
 
32
- useEffect(() => {
33
- // If they are the same dont trigger event again.
34
- if (visibleDate !== startDate) {
35
- onUpdateDate(debouncedVisibleDate);
36
- }
37
- }, [debouncedVisibleDate])
33
+ useEffect(() => {
34
+ setVisibleDate(startDate);
35
+ }, [startDate]);
38
36
 
39
- return (
40
- <View style={styles.container}>
41
- <Pressable
42
- onPress={() => {
43
- setVisibleDate(visibleDate.minus({days: 1}));
44
- }}
45
- style={styles.arrowContainer}
46
- >
47
- <Icon
48
- style={'regular'}
49
- name={'chevron-left'}
50
- color={context.colors.main['9']}
51
- />
52
- </Pressable>
37
+ useEffect(() => {
38
+ // If they are the same dont trigger event again.
39
+ if (visibleDate !== startDate) {
40
+ onUpdateDate(debouncedVisibleDate);
41
+ }
42
+ }, [debouncedVisibleDate])
53
43
 
54
- <Pressable
55
- onPress={() => onPressDate(visibleDate)}
56
- style={styles.dateContainer}
57
- >
58
- <View style={styles.icon}>
59
- <Icon
60
- style={'regular'}
61
- name={'calendar'}
62
- color={context.colors.main['9']}
63
- />
64
- </View>
65
- <View>
66
- <Paragraph textColor={context.colors.main['9']}>
67
- {visibleDate.toLocaleString({weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})}
68
- </Paragraph>
69
- </View>
70
- </Pressable>
44
+ return (
45
+ <View style={styles.container}>
46
+ <Pressable
47
+ onPress={() => {
48
+ setVisibleDate(visibleDate.minus({days: 1}));
49
+ }}
50
+ style={styles.arrowContainer}
51
+ >
52
+ <Icon
53
+ style={'regular'}
54
+ name={'chevron-left'}
55
+ color={context.colors.main['9']}
56
+ />
57
+ </Pressable>
71
58
 
72
- <Pressable
73
- onPress={() => {
74
- setVisibleDate(visibleDate.plus({days: 1}));
75
- }}
76
- style={styles.arrowContainer}
77
- >
78
- <Icon
79
- style={'regular'}
80
- name={'chevron-right'}
81
- color={context.colors.main['9']}
82
- />
83
- </Pressable>
84
- </View>
85
- );
59
+ <Pressable
60
+ onPress={() => onPressDate(visibleDate)}
61
+ style={styles.dateContainer}
62
+ >
63
+ <View style={styles.icon}>
64
+ <Icon
65
+ style={'regular'}
66
+ name={'calendar'}
67
+ color={context.colors.main['9']}
68
+ />
69
+ </View>
70
+ <View>
71
+ <Paragraph textColor={context.colors.main['9']}>
72
+ {
73
+ isToday && labelForToday ?
74
+ labelForToday :
75
+ visibleDate.toLocaleString({weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})
76
+ }
77
+ </Paragraph>
78
+ </View>
79
+ </Pressable>
80
+
81
+ <Pressable
82
+ onPress={() => {
83
+ setVisibleDate(visibleDate.plus({days: 1}));
84
+ }}
85
+ style={styles.arrowContainer}
86
+ >
87
+ <Icon
88
+ style={'regular'}
89
+ name={'chevron-right'}
90
+ color={context.colors.main['9']}
91
+ />
92
+ </Pressable>
93
+ </View>
94
+ );
86
95
  };
87
96
  export {CalendarSelect as CalendarSelect};