atlas-design-system 1.5.2 → 1.6.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/README.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Atlas Design System
2
+ A themable design system library with core components used in a React Native App.
3
+ Designed for Atlas Workout app and EzBudget budget app.
2
4
 
5
+ <img width=300 alt="screenshot" src="https://github.com/juancstlm/AtlasDesignSystem/blob/master/example/assets/images/iPhone-example.png?raw=true"></img>
6
+
7
+ ## Usage
8
+
9
+ Ensure your app has the `peerDependencies` installed
10
+
11
+ ```javascript
12
+ //...
13
+ //1. Import the ThemeContext and a theme. You can make your own or use the provided light theme ATLAS_LIGHT
14
+ import { ThemeContext, ATLAS_LIGHT } from "atlas-design-system";
15
+
16
+ export default function MyThemedApp(){
17
+
18
+ return (
19
+ // 2. Wrap your app with the ThemeContext.Provider and provide your theme
20
+ <ThemeContext.Provider value={ATLAS_LIGHT}>
21
+ <MyApp>
22
+ </ThemeContext.Provider>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ```javascript
28
+ import { Text } from "atlas-design-system";
29
+ import { View } from "react-native";
30
+
31
+ // 3. Use the components
32
+ export default function MyApp() {
33
+ return (
34
+ <View>
35
+ <Text category="h1" >Welcome to My App</Text>
36
+ </View>
37
+ )
38
+ }
39
+ ```
3
40
 
4
41
  # Running exmple app
5
42
  The example app is provided as a way to test and develop on the design system. It is also used as a gallery to view all the components and features of the desgin system.
@@ -68,7 +68,6 @@ const BottomSheet = ({ open, children, height, setOpen }) => {
68
68
  return (<react_native_1.Modal transparent visible>
69
69
  <react_native_1.Pressable onPress={() => {
70
70
  setOpen(false);
71
- console.log("tests");
72
71
  }} style={styles.wrapper}></react_native_1.Pressable>
73
72
  <react_native_reanimated_1.default.View style={[styles.sheet, animatedStyle]}>
74
73
  {children}
@@ -1,5 +1,5 @@
1
- import { IOSNativeProps, AndroidNativeProps } from '@react-native-community/datetimepicker';
2
- import { StyleProp, ViewStyle } from 'react-native';
1
+ import { IOSNativeProps, AndroidNativeProps } from "@react-native-community/datetimepicker";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
3
  export type DateTimeInputProps = {
4
4
  label: string;
5
5
  caption?: string;
@@ -9,8 +9,9 @@ export type DateTimeInputProps = {
9
9
  disabled?: boolean;
10
10
  testID?: string;
11
11
  containerStyle?: StyleProp<ViewStyle>;
12
- mode?: IOSNativeProps['mode'] | AndroidNativeProps['mode'];
12
+ mode?: IOSNativeProps["mode"] | AndroidNativeProps["mode"];
13
13
  error?: string;
14
+ display?: IOSNativeProps["display"] | AndroidNativeProps["display"];
14
15
  };
15
16
  export declare const DateTimeInput: ({ value, onChange, testID, containerStyle, label, caption, mode, error, disabled, onSave, }: DateTimeInputProps) => import("react").JSX.Element;
16
17
  export default DateTimeInput;
@@ -42,19 +42,19 @@ const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimated
42
42
  const FieldError_1 = require("../FieldError/FieldError");
43
43
  const getFormat = (mode) => {
44
44
  switch (mode) {
45
- case 'date': {
46
- return 'MMM D, YYYY';
45
+ case "date": {
46
+ return "MMM D, YYYY";
47
47
  }
48
- case 'time': {
49
- return 'h:mm A';
48
+ case "time": {
49
+ return "h:mm A";
50
50
  }
51
- case 'datetime':
51
+ case "datetime":
52
52
  default: {
53
- return 'MMM D, YYYY h:mm A';
53
+ return "MMM D, YYYY h:mm A";
54
54
  }
55
55
  }
56
56
  };
57
- const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption, mode = 'date', error, disabled = false, onSave, }) => {
57
+ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption, mode = "date", error, disabled = false, onSave, }) => {
58
58
  const { styles, theme } = useStyles(disabled);
59
59
  const [dateSheetOpen, setDateSheetOpen] = (0, react_1.useState)(false);
60
60
  const [date, setDate] = (0, react_1.useState)(value);
@@ -71,11 +71,15 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
71
71
  setBorderColor(styles.itemContainerError.borderColor);
72
72
  return;
73
73
  }
74
- setBorderColor(dateSheetOpen ? styles.itemContainerFocused.borderColor : styles.itemContainer.borderColor);
74
+ setBorderColor(dateSheetOpen
75
+ ? styles.itemContainerFocused.borderColor
76
+ : styles.itemContainer.borderColor);
75
77
  }, [error, dateSheetOpen]);
76
78
  const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
77
79
  return {
78
- transform: [{ translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [1, -8]) }],
80
+ transform: [
81
+ { translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [1, -8]) },
82
+ ],
79
83
  fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, [0, 1], [14, 10]),
80
84
  };
81
85
  }, []);
@@ -90,22 +94,25 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
90
94
  <react_native_1.TouchableOpacity onPress={() => setDateSheetOpen(true)} disabled={disabled}>
91
95
  <react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
92
96
  <react_native_1.View pointerEvents="none" style={styles.labelContainer}>
93
- <react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>{label}</react_native_reanimated_1.default.Text>
97
+ <react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>
98
+ {label}
99
+ </react_native_reanimated_1.default.Text>
94
100
  </react_native_1.View>
95
101
  <react_native_reanimated_1.default.View style={animatedValueStyle}>
96
102
  <Text_1.default contrast="low" style={styles.value}>
97
103
  {(0, moment_1.default)(value).format(getFormat(mode)).toString()}
98
104
  </Text_1.default>
99
105
  </react_native_reanimated_1.default.View>
100
- <Ionicons_1.default style={styles.iconRight} color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast} name={mode === 'time' ? 'time-outline' : 'calendar-outline'} size={20}/>
106
+ <Ionicons_1.default style={styles.iconRight} color={!disabled
107
+ ? theme.colors.foreground
108
+ : theme.colors.foregroundLowContrast} name={mode === "time" ? "time-outline" : "calendar-outline"} size={20}/>
101
109
  </react_native_reanimated_1.default.View>
102
110
  </react_native_1.TouchableOpacity>
103
111
  {!!error && <FieldError_1.FieldError error={error}/>}
104
112
  {!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
105
113
  </react_native_1.View>
106
114
  <Sheet_1.default disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen}>
107
- <datetimepicker_1.default value={date} mode={mode} themeVariant={theme.isDarkTheme ? 'dark' : 'light'} display="spinner" onChange={(_, newDate) => {
108
- console.log({ newDate });
115
+ <datetimepicker_1.default value={date} mode={mode} themeVariant={theme.isDarkTheme ? "dark" : "light"} display="spinner" onChange={(_, newDate) => {
109
116
  if (!newDate) {
110
117
  return;
111
118
  }
@@ -121,23 +128,22 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
121
128
  };
122
129
  exports.DateTimeInput = DateTimeInput;
123
130
  exports.default = exports.DateTimeInput;
124
- const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)(t => react_native_1.StyleSheet.create({
125
- container: {
126
- marginBottom: t.size.baseSize * 3,
127
- },
131
+ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
132
+ container: {},
128
133
  itemContainer: {
129
134
  backgroundColor: t.colors.backgroundOnPrimary,
130
135
  borderRadius: t.borderRadius,
131
136
  paddingHorizontal: t.size.baseSize * 2,
132
137
  minHeight: t.size.baseSize * 8,
133
- flexDirection: 'row',
134
- justifyContent: 'space-between',
135
- alignItems: 'center',
136
- borderColor: t.colors.backgroundPrimary,
138
+ flexDirection: "row",
139
+ justifyContent: "space-between",
140
+ alignItems: "center",
141
+ borderColor: t.colors.backgroundOnPrimary,
137
142
  borderWidth: t.borderWidth,
143
+ height: t.size.baseSize * 9,
138
144
  },
139
145
  itemContainerError: {
140
- borderColor: t.colors.foregroundNegative
146
+ borderColor: t.colors.foregroundNegative,
141
147
  },
142
148
  itemContainerFocused: {
143
149
  borderColor: t.colors.border,
@@ -147,9 +153,11 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
147
153
  },
148
154
  labelContainer: {
149
155
  left: t.size.baseSize * 2,
150
- position: 'absolute',
156
+ position: "absolute",
151
157
  },
152
- label: Object.assign({ color: !disabled ? t.colors.foreground : t.colors.foregroundLowContrast }, t.typography.p1),
158
+ label: Object.assign({ color: !disabled
159
+ ? t.colors.foreground
160
+ : t.colors.foregroundLowContrast }, t.typography.p1),
153
161
  iconRight: {},
154
162
  value: {
155
163
  paddingHorizontal: t.size.baseSize * 0,
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
2
3
  import { Option } from "./types";
3
4
  export type SelectInputProps<T> = {
4
5
  caption?: string;
@@ -7,6 +8,7 @@ export type SelectInputProps<T> = {
7
8
  onChange: (newValue: Option<T>) => void;
8
9
  error?: string;
9
10
  renderOption?: (option: Option<T>) => React.ReactNode;
11
+ containerStyle?: StyleProp<ViewStyle>;
10
12
  };
11
- export declare function SelectInput<T>({ caption, label, options, onChange, error, renderOption, }: SelectInputProps<T>): React.JSX.Element;
13
+ export declare function SelectInput<T>({ caption, label, options, onChange, error, renderOption, containerStyle, }: SelectInputProps<T>): React.JSX.Element;
12
14
  export default SelectInput;
@@ -38,7 +38,7 @@ const hooks_1 = require("../../hooks");
38
38
  const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
39
39
  const animations_1 = require("../../constants/animations");
40
40
  const SelectionItem_1 = __importDefault(require("./components/SelectionItem"));
41
- function SelectInput({ caption, label, options = [], onChange, error, renderOption, }) {
41
+ function SelectInput({ caption, label, options = [], onChange, error, renderOption, containerStyle, }) {
42
42
  const styles = useStyles().styles;
43
43
  const value = (0, react_1.useMemo)(() => {
44
44
  return options.find((v) => v.selected);
@@ -87,7 +87,7 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
87
87
  onChange(option);
88
88
  setSheetOpen(false);
89
89
  };
90
- return (<>
90
+ return (<react_native_1.View style={containerStyle}>
91
91
  <react_native_1.TouchableOpacity onPress={() => setSheetOpen(true)}>
92
92
  <react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
93
93
  <react_native_1.View pointerEvents="none" style={styles.labelContainer}>
@@ -111,7 +111,7 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
111
111
  {renderOption ? (renderOption(option)) : (<SelectionItem_1.default option={option}/>)}
112
112
  </react_native_1.TouchableOpacity>))}
113
113
  </Sheet_1.default>
114
- </>);
114
+ </react_native_1.View>);
115
115
  }
116
116
  const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
117
117
  chevron: {
@@ -127,6 +127,7 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
127
127
  flexDirection: "row",
128
128
  alignItems: "center",
129
129
  justifyContent: "space-between",
130
+ height: theme.size.baseSize * 9,
130
131
  },
131
132
  itemContainerFocused: {
132
133
  borderColor: theme.colors.border,
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
1
+ import React from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
3
  export type SwitchToggleProps = {
4
4
  label: string;
5
5
  value?: boolean;
@@ -7,7 +7,8 @@ export type SwitchToggleProps = {
7
7
  testId?: string;
8
8
  onChange?: (value: boolean) => void;
9
9
  touchableStyle?: StyleProp<ViewStyle>;
10
+ containerStyle?: StyleProp<ViewStyle>;
10
11
  error?: string;
11
12
  };
12
- export declare const SwitchToggle: ({ testId, onChange, value, caption, label, touchableStyle, error }: SwitchToggleProps) => React.JSX.Element;
13
+ export declare const SwitchToggle: ({ testId, onChange, value, caption, label, touchableStyle, error, containerStyle, }: SwitchToggleProps) => React.JSX.Element;
13
14
  export default SwitchToggle;
@@ -35,17 +35,17 @@ const MenuItemDescription_1 = require("../MenuItemDescription");
35
35
  const index_1 = require("../../shared/styles/index");
36
36
  const FieldError_1 = require("../FieldError/FieldError");
37
37
  const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
38
- const SwitchToggle = ({ testId, onChange, value, caption, label, touchableStyle, error }) => {
38
+ const SwitchToggle = ({ testId, onChange, value, caption, label, touchableStyle, error, containerStyle, }) => {
39
39
  const { styles, theme } = (0, index_1.useMenuItemStyles)();
40
40
  const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
41
41
  (0, react_1.useEffect)(() => {
42
42
  setBorderColor(error ? theme.colors.foregroundNegative : styles.itemContainer.borderColor);
43
43
  }, [error]);
44
- return (<react_native_1.View style={styles.container}>
44
+ return (<react_native_1.View style={[styles.container, containerStyle]}>
45
45
  <react_native_1.TouchableOpacity testID={testId} style={touchableStyle}>
46
46
  <react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
47
47
  <Text_1.default numberOfLines={1}>{label}</Text_1.default>
48
- <react_native_1.Switch testID={`${testId}_toggle`} onValueChange={onChange} value={value}/>
48
+ <react_native_1.Switch onValueChange={onChange} value={value}/>
49
49
  </react_native_reanimated_1.default.View>
50
50
  </react_native_1.TouchableOpacity>
51
51
  {!!error && <FieldError_1.FieldError error={error}/>}
@@ -105,7 +105,9 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
105
105
  (0, react_1.useEffect)(() => {
106
106
  var _a;
107
107
  if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.isFocused()) {
108
- setBorderColor(error ? styles.itemContainerError.borderColor : styles.itemContainerFocused.borderColor);
108
+ setBorderColor(error
109
+ ? styles.itemContainerError.borderColor
110
+ : styles.itemContainerFocused.borderColor);
109
111
  }
110
112
  else {
111
113
  startBlurAnimation();
@@ -122,7 +124,9 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
122
124
  animatedValue.value = (0, react_native_reanimated_1.withTiming)(1, animations_1.DEFAULT_TIMING_CONFIG);
123
125
  };
124
126
  const startBlurAnimation = () => {
125
- setBorderColor(error ? `${styles.itemContainerError.borderColor}40` : styles.itemContainer.borderColor);
127
+ setBorderColor(error
128
+ ? `${styles.itemContainerError.borderColor}40`
129
+ : styles.itemContainer.borderColor);
126
130
  if (!value) {
127
131
  animatedValue.value = (0, react_native_reanimated_1.withTiming)(0, animations_1.DEFAULT_TIMING_CONFIG);
128
132
  }
@@ -132,18 +136,16 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
132
136
  startBlurAnimation();
133
137
  };
134
138
  const onFocus = () => {
135
- setBorderColor(error ? styles.itemContainerError.borderColor : styles.itemContainerFocused.borderColor);
139
+ setBorderColor(error
140
+ ? styles.itemContainerError.borderColor
141
+ : styles.itemContainerFocused.borderColor);
136
142
  };
137
143
  return (<react_native_1.View style={styles.container}>
138
144
  <react_native_1.Pressable onPress={() => {
139
145
  var _a;
140
146
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
141
147
  }} style={styles.pressable} disabled={disabled}>
142
- <react_native_reanimated_1.default.View style={[
143
- styles.itemContainer,
144
- animatedBorderStyle,
145
- containerStyle,
146
- ]}>
148
+ <react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle, containerStyle]}>
147
149
  <react_native_1.View pointerEvents="none" style={styles.labelContainer}>
148
150
  <react_native_reanimated_1.default.Text style={[styles.label, animatedLabelStyles]}>
149
151
  {label}
@@ -154,7 +156,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
154
156
  </react_native_reanimated_1.default.View>
155
157
  </react_native_reanimated_1.default.View>
156
158
  </react_native_1.Pressable>
157
- {!!error && (<FieldError_1.FieldError error={error}/>)}
159
+ {!!error && <FieldError_1.FieldError error={error}/>}
158
160
  {!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
159
161
  </react_native_1.View>);
160
162
  });
@@ -180,7 +182,7 @@ const useStyles = (disabled, error) => (0, hooks_1.useThemedStyle)((0, react_1.u
180
182
  color: theme.colors.foregroundLowContrast,
181
183
  },
182
184
  })),
183
- text: Object.assign({ marginTop: theme.size.baseSize, paddingHorizontal: theme.size.baseSize * 2, color: theme.colors.foregroundLowContrast }, getTextInputStyle(disabled, error, {
185
+ text: Object.assign(Object.assign(Object.assign({}, theme.typography.p1), { paddingVertical: theme.size.baseSize * 1, marginTop: theme.size.baseSize, paddingHorizontal: theme.size.baseSize * 2, color: theme.colors.foregroundLowContrast }), getTextInputStyle(disabled, error, {
184
186
  disabled: {
185
187
  color: theme.colors.foregroundLowContrast,
186
188
  },
@@ -194,6 +196,7 @@ const useStyles = (disabled, error) => (0, hooks_1.useThemedStyle)((0, react_1.u
194
196
  itemContainer: {
195
197
  borderWidth: theme.borderWidth,
196
198
  backgroundColor: theme.colors.backgroundOnPrimary,
199
+ height: theme.size.baseSize * 9,
197
200
  borderRadius: theme.borderRadius,
198
201
  minHeight: theme.size.baseSize * 8,
199
202
  flexDirection: "row",
@@ -8,9 +8,7 @@ export declare const useMenuItemStyles: () => {
8
8
  fontWeight: import("../..").FontWeights;
9
9
  fontFamily: string;
10
10
  };
11
- container: {
12
- marginBottom: number;
13
- };
11
+ container: {};
14
12
  itemContainer: {
15
13
  borderWidth: number;
16
14
  borderColor: string;
@@ -21,6 +19,7 @@ export declare const useMenuItemStyles: () => {
21
19
  flexDirection: "row";
22
20
  justifyContent: "space-between";
23
21
  alignItems: "center";
22
+ height: number;
24
23
  };
25
24
  itemLabel: {
26
25
  color: string;
@@ -5,21 +5,20 @@ const react_1 = require("react");
5
5
  const react_native_1 = require("react-native");
6
6
  const hooks_1 = require("../../hooks");
7
7
  exports.MENU_ITEM_HEIGHT = 40;
8
- const useMenuItemStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)(theme => react_native_1.StyleSheet.create({
8
+ const useMenuItemStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
9
9
  textInput: Object.assign({}, theme.typography.h3),
10
- container: {
11
- marginBottom: theme.size.baseSize * 3,
12
- },
10
+ container: {},
13
11
  itemContainer: {
14
12
  borderWidth: theme.borderWidth,
15
- borderColor: theme.colors.backgroundPrimary,
16
- backgroundColor: theme.menuItemContainerBackground,
13
+ borderColor: theme.colors.backgroundOnPrimary,
14
+ backgroundColor: theme.colors.backgroundOnPrimary,
17
15
  borderRadius: theme.borderRadius,
18
16
  paddingHorizontal: theme.size.baseSize * 2,
19
17
  minHeight: exports.MENU_ITEM_HEIGHT,
20
- flexDirection: 'row',
21
- justifyContent: 'space-between',
22
- alignItems: 'center',
18
+ flexDirection: "row",
19
+ justifyContent: "space-between",
20
+ alignItems: "center",
21
+ height: theme.size.baseSize * 9,
23
22
  },
24
23
  itemLabel: {
25
24
  color: theme.textPrimary,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atlas-design-system",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "A react native design system for the Atlas workout app",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",