atlas-design-system 1.17.5 → 1.18.1
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 +51 -25
- package/dist/components/DateTimeInput/index.js +34 -13
- package/dist/components/NavigationListRow/index.js +5 -6
- package/dist/components/Search/Search.d.ts +5 -6
- package/dist/components/Search/Search.js +30 -20
- package/dist/components/Search/index.d.ts +2 -1
- package/dist/components/Search/index.js +6 -0
- package/dist/components/SelectInput/SelectInput.js +12 -5
- package/dist/components/TextInput/TextInput.js +15 -6
- package/dist/components/TextInput/index.d.ts +2 -2
- package/dist/components/TextInput/index.js +2 -2
- package/dist/constants/animations.d.ts +1 -0
- package/dist/constants/animations.js +3 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +4 -0
- package/dist/hooks/useInputFieldFontSizeInterpolationOutputRange.d.ts +1 -0
- package/dist/hooks/useInputFieldFontSizeInterpolationOutputRange.js +11 -0
- package/dist/shared/styles/index.d.ts +0 -1
- package/dist/shared/styles/index.js +4 -4
- package/dist/utils/animation.d.ts +22 -0
- package/dist/utils/animation.js +28 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,45 +4,71 @@ Designed for Atlas Workout app and EzBudget budget app.
|
|
|
4
4
|
|
|
5
5
|
<img width=300 alt="screenshot" src="https://github.com/juancstlm/AtlasDesignSystem/blob/master/example/assets/images/iPhone-example.png?raw=true"></img>
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Atlas Design System relies on a few peer dependencies that need to be present in your project. Install everything at once with **npm**:
|
|
10
10
|
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install atlas-design-system @react-native-community/datetimepicker informed moment react-native-reanimated react-native-safe-area-context react-native-vector-icons
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
—or with **Yarn**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add atlas-design-system @react-native-community/datetimepicker informed moment react-native-reanimated react-native-safe-area-context react-native-vector-icons
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
After the packages are installed, make sure to install the iOS pods:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx pod-install ios
|
|
25
|
+
```
|
|
15
26
|
|
|
16
|
-
|
|
27
|
+
Using **Expo**? You can rely on `expo install` to ensure the correct versions:
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
```bash
|
|
30
|
+
expo install atlas-design-system @react-native-community/datetimepicker react-native-reanimated react-native-safe-area-context react-native-vector-icons
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> **Note**
|
|
34
|
+
> • React Native ≥ 0.64 is required.
|
|
35
|
+
> • Follow the React-Native-Reanimated [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/) and enable the Babel plugin if you haven't already.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// 1. Import the ThemeContext and a theme. You can make your own or use the provided light theme ATLAS_LIGHT
|
|
41
|
+
import { ThemeContext, ATLAS_LIGHT } from "atlas-design-system";
|
|
42
|
+
|
|
43
|
+
export default function MyThemedApp() {
|
|
44
|
+
return (
|
|
45
|
+
// 2. Wrap your app with the ThemeContext.Provider and provide your theme
|
|
46
|
+
<ThemeContext.Provider value={ATLAS_LIGHT}>
|
|
47
|
+
<MyApp />
|
|
48
|
+
</ThemeContext.Provider>
|
|
49
|
+
);
|
|
24
50
|
}
|
|
25
51
|
```
|
|
26
52
|
|
|
27
|
-
```
|
|
53
|
+
```tsx
|
|
28
54
|
import { Text } from "atlas-design-system";
|
|
29
55
|
import { View } from "react-native";
|
|
30
56
|
|
|
31
57
|
// 3. Use the components
|
|
32
58
|
export default function MyApp() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
return (
|
|
60
|
+
<View>
|
|
61
|
+
<Text category="h1">Welcome to My App</Text>
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
38
64
|
}
|
|
39
65
|
```
|
|
40
66
|
|
|
41
|
-
|
|
42
|
-
The example app is provided as a way to test and develop
|
|
67
|
+
## Running the example app
|
|
68
|
+
The example app is provided as a way to test and develop the design system. It also serves as a gallery showcasing all the components and features.
|
|
43
69
|
|
|
44
|
-
To run the example app
|
|
45
|
-
```bash
|
|
46
|
-
cd /example && yarn && yarn ios
|
|
47
|
-
```
|
|
70
|
+
To run the example app, execute:
|
|
48
71
|
|
|
72
|
+
```bash
|
|
73
|
+
cd example && yarn && yarn ios
|
|
74
|
+
```
|
|
@@ -41,6 +41,8 @@ const Button_1 = __importDefault(require("../Button"));
|
|
|
41
41
|
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
42
42
|
const FieldError_1 = require("../FieldError/FieldError");
|
|
43
43
|
const animations_1 = require("../../constants/animations");
|
|
44
|
+
const constants_1 = require("../../constants");
|
|
45
|
+
const useInputFieldFontSizeInterpolationOutputRange_1 = require("../../hooks/useInputFieldFontSizeInterpolationOutputRange");
|
|
44
46
|
const getFormat = (mode) => {
|
|
45
47
|
switch (mode) {
|
|
46
48
|
case "date": {
|
|
@@ -59,6 +61,7 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
59
61
|
const { styles, theme } = useStyles(disabled);
|
|
60
62
|
const [dateSheetOpen, setDateSheetOpen] = (0, react_1.useState)(false);
|
|
61
63
|
const [date, setDate] = (0, react_1.useState)(value);
|
|
64
|
+
const isInitialMount = (0, react_1.useRef)(true);
|
|
62
65
|
(0, react_1.useEffect)(() => {
|
|
63
66
|
if (dateSheetOpen) {
|
|
64
67
|
return;
|
|
@@ -67,6 +70,18 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
67
70
|
}, [dateSheetOpen, value]);
|
|
68
71
|
const animatedValue = (0, react_native_reanimated_1.useSharedValue)(value ? 1 : 0);
|
|
69
72
|
const { animatedBorderStyle, setBorderColor } = (0, useInputFieldAnimatedBorder_1.useInputFieldAnimatedBorder)(styles.itemContainer.borderColor);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (isInitialMount.current) {
|
|
75
|
+
// skip animation on initial mount we already have the value
|
|
76
|
+
isInitialMount.current = false;
|
|
77
|
+
animatedValue.value = value ? 1 : 0;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// After initial mount, animate the value changes
|
|
82
|
+
animatedValue.value = (0, react_native_reanimated_1.withTiming)(value ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
83
|
+
}
|
|
84
|
+
}, [value]);
|
|
70
85
|
(0, react_1.useEffect)(() => {
|
|
71
86
|
if (error) {
|
|
72
87
|
setBorderColor(styles.itemContainerError.borderColor);
|
|
@@ -76,6 +91,7 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
76
91
|
? styles.itemContainerFocused.borderColor
|
|
77
92
|
: styles.itemContainer.borderColor);
|
|
78
93
|
}, [error, dateSheetOpen]);
|
|
94
|
+
const labelFontSizeInterpolationOutputRange = (0, useInputFieldFontSizeInterpolationOutputRange_1.useInputFieldFontSizeInterpolationOutputRange)();
|
|
79
95
|
const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
80
96
|
return {
|
|
81
97
|
transform: [
|
|
@@ -83,13 +99,17 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
83
99
|
translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, animations_1.LABEL_INTERPOLATION_OUTPUT_RANGE),
|
|
84
100
|
},
|
|
85
101
|
],
|
|
86
|
-
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value,
|
|
102
|
+
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, labelFontSizeInterpolationOutputRange),
|
|
87
103
|
};
|
|
88
|
-
}, []);
|
|
104
|
+
}, [labelFontSizeInterpolationOutputRange]);
|
|
89
105
|
const animatedValueStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
90
106
|
return {
|
|
91
107
|
flex: 1,
|
|
92
|
-
transform: [
|
|
108
|
+
transform: [
|
|
109
|
+
{
|
|
110
|
+
translateY: animatedValue.value * animations_1.ANIMATED_VALUE_TRANSLATE_Y_MULTIPLIER,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
93
113
|
};
|
|
94
114
|
});
|
|
95
115
|
return (<>
|
|
@@ -106,7 +126,7 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
106
126
|
{(0, moment_1.default)(value).format(getFormat(mode)).toString()}
|
|
107
127
|
</Text_1.default>
|
|
108
128
|
</react_native_reanimated_1.default.View>
|
|
109
|
-
<Ionicons_1.default
|
|
129
|
+
<Ionicons_1.default color={!disabled
|
|
110
130
|
? theme.colors.foreground
|
|
111
131
|
: theme.colors.foregroundLowContrast} name={mode === "time" ? "time-outline" : "calendar-outline"} size={20}/>
|
|
112
132
|
</react_native_reanimated_1.default.View>
|
|
@@ -114,18 +134,17 @@ const DateTimeInput = ({ value, onChange, testID, containerStyle, label, caption
|
|
|
114
134
|
{!!error && <FieldError_1.FieldError error={error}/>}
|
|
115
135
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
116
136
|
</react_native_1.View>
|
|
117
|
-
<Sheet_1.default disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen}
|
|
118
|
-
|
|
137
|
+
<Sheet_1.default disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen} footer={<Button_1.default text="Save" onPress={() => {
|
|
138
|
+
onSave === null || onSave === void 0 ? void 0 : onSave(date);
|
|
139
|
+
setDateSheetOpen(false);
|
|
140
|
+
}}/>}>
|
|
141
|
+
<datetimepicker_1.default value={date} style={styles.datePicker} mode={mode} themeVariant={theme.isDarkTheme ? "dark" : "light"} display="spinner" onChange={(_, newDate) => {
|
|
119
142
|
if (!newDate) {
|
|
120
143
|
return;
|
|
121
144
|
}
|
|
122
145
|
setDate(newDate);
|
|
123
146
|
onChange === null || onChange === void 0 ? void 0 : onChange(newDate);
|
|
124
147
|
}}/>
|
|
125
|
-
<Button_1.default text="Save" onPress={() => {
|
|
126
|
-
onSave === null || onSave === void 0 ? void 0 : onSave(date);
|
|
127
|
-
setDateSheetOpen(false);
|
|
128
|
-
}}/>
|
|
129
148
|
</Sheet_1.default>
|
|
130
149
|
</>);
|
|
131
150
|
};
|
|
@@ -133,17 +152,20 @@ exports.DateTimeInput = DateTimeInput;
|
|
|
133
152
|
exports.default = exports.DateTimeInput;
|
|
134
153
|
const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
|
|
135
154
|
container: {},
|
|
155
|
+
datePicker: {
|
|
156
|
+
height: t.size.baseSize * 60,
|
|
157
|
+
},
|
|
136
158
|
itemContainer: {
|
|
137
159
|
backgroundColor: t.colors.backgroundOnPrimary,
|
|
138
160
|
borderRadius: t.borderRadius,
|
|
139
161
|
paddingHorizontal: t.size.baseSize * 2,
|
|
140
|
-
minHeight: t.size.baseSize *
|
|
162
|
+
minHeight: t.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
141
163
|
flexDirection: "row",
|
|
142
164
|
justifyContent: "space-between",
|
|
143
165
|
alignItems: "center",
|
|
144
166
|
borderColor: t.colors.backgroundOnPrimary,
|
|
145
167
|
borderWidth: t.borderWidth,
|
|
146
|
-
height: t.size.baseSize *
|
|
168
|
+
height: t.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
147
169
|
},
|
|
148
170
|
itemContainerError: {
|
|
149
171
|
borderColor: t.colors.foregroundNegative,
|
|
@@ -158,7 +180,6 @@ const useStyles = (disabled) => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
158
180
|
label: Object.assign({ color: !disabled
|
|
159
181
|
? t.colors.foregroundHighContrast
|
|
160
182
|
: t.colors.foregroundLowContrast }, t.typography.p1),
|
|
161
|
-
iconRight: {},
|
|
162
183
|
value: {
|
|
163
184
|
paddingHorizontal: t.size.baseSize * 0,
|
|
164
185
|
},
|
|
@@ -45,18 +45,17 @@ const NavigationListRow = ({ label, caption, onPress, disabled, defaultPadding =
|
|
|
45
45
|
exports.NavigationListRow = NavigationListRow;
|
|
46
46
|
exports.default = exports.NavigationListRow;
|
|
47
47
|
const useStyles = (defaultPadding) => (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
|
|
48
|
-
content: {
|
|
49
|
-
flexGrow: 1,
|
|
50
|
-
},
|
|
51
48
|
container: {
|
|
52
|
-
width: "100%",
|
|
53
49
|
flexDirection: "row",
|
|
50
|
+
justifyContent: "flex-start",
|
|
51
|
+
columnGap: t.size.baseSize * 0,
|
|
54
52
|
paddingVertical: t.size.baseSize * 2,
|
|
55
53
|
paddingHorizontal: defaultPadding ? t.size.baseSize * 4 : 0,
|
|
56
54
|
},
|
|
55
|
+
content: {
|
|
56
|
+
flex: 1,
|
|
57
|
+
},
|
|
57
58
|
chevronRight: {
|
|
58
|
-
height: "100%",
|
|
59
|
-
flexGrow: 0,
|
|
60
59
|
color: t.colors.foregroundHighContrast,
|
|
61
60
|
},
|
|
62
61
|
}), [defaultPadding]));
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { ViewStyle, ReturnKeyType, StyleProp } from
|
|
3
|
-
type
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle, ReturnKeyType, StyleProp, TextInputProps } from "react-native";
|
|
3
|
+
type SearchProps = {
|
|
4
4
|
searchQuery: string;
|
|
5
5
|
onChangeText: (text: string) => void;
|
|
6
6
|
rightComponent?: React.ReactNode;
|
|
7
7
|
onPressFilter?: () => void;
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
label: string;
|
|
10
|
-
autoFocus?: boolean;
|
|
11
10
|
containerStyle?: StyleProp<ViewStyle>;
|
|
12
11
|
returnKeyType?: ReturnKeyType;
|
|
13
|
-
}
|
|
14
|
-
|
|
12
|
+
} & Omit<TextInputProps, "returnKeyType" | "onFocus" | "onBlur" | "onChangeText">;
|
|
13
|
+
declare const Search: ({ searchQuery, onChangeText, placeholder, containerStyle, returnKeyType, label, ...rest }: SearchProps) => React.JSX.Element;
|
|
15
14
|
export default Search;
|
|
@@ -22,28 +22,39 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
27
35
|
};
|
|
28
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Search = void 0;
|
|
30
37
|
const react_1 = __importStar(require("react"));
|
|
31
38
|
const react_native_1 = require("react-native");
|
|
32
39
|
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
33
|
-
const
|
|
34
|
-
const Text_1 = __importDefault(require("../Text"));
|
|
40
|
+
const components_1 = require("../../components");
|
|
35
41
|
const hooks_1 = require("../../hooks");
|
|
36
42
|
const CANCEL_BUTTON_WIDTH = 62;
|
|
37
|
-
const Search = (
|
|
43
|
+
const Search = (_a) => {
|
|
44
|
+
var { searchQuery, onChangeText, placeholder, containerStyle = {}, returnKeyType, label } = _a, rest = __rest(_a, ["searchQuery", "onChangeText", "placeholder", "containerStyle", "returnKeyType", "label"]);
|
|
38
45
|
const { styles } = useStyles();
|
|
39
46
|
const inputRef = (0, react_1.useRef)(null);
|
|
40
47
|
const [minWidth, setMinWidth] = (0, react_1.useState)(0);
|
|
41
48
|
const focused = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
42
49
|
const onFocus = () => {
|
|
43
|
-
focused.value = (0, react_native_reanimated_1.withTiming)(1, {
|
|
50
|
+
focused.value = (0, react_native_reanimated_1.withTiming)(1, {
|
|
51
|
+
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
52
|
+
});
|
|
44
53
|
};
|
|
45
54
|
const onBlur = () => {
|
|
46
|
-
focused.value = (0, react_native_reanimated_1.withTiming)(0, {
|
|
55
|
+
focused.value = (0, react_native_reanimated_1.withTiming)(0, {
|
|
56
|
+
easing: react_native_reanimated_1.Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
57
|
+
});
|
|
47
58
|
};
|
|
48
59
|
const animatedCancelButtonStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
|
|
49
60
|
opacity: focused.value,
|
|
@@ -53,7 +64,7 @@ const Search = ({ searchQuery, onChangeText, placeholder, autoFocus, containerSt
|
|
|
53
64
|
}), [focused, minWidth]);
|
|
54
65
|
const onPressCancel = (0, react_1.useCallback)(() => {
|
|
55
66
|
var _a;
|
|
56
|
-
onChangeText(
|
|
67
|
+
onChangeText("");
|
|
57
68
|
// @ts-expect-error not yet typed
|
|
58
69
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
59
70
|
}, [inputRef]);
|
|
@@ -62,32 +73,31 @@ const Search = ({ searchQuery, onChangeText, placeholder, autoFocus, containerSt
|
|
|
62
73
|
};
|
|
63
74
|
return (<react_native_1.View style={[styles.searchBarContainer, containerStyle]} onLayout={onLayout}>
|
|
64
75
|
<react_native_reanimated_1.default.View style={[animatedSearchInput, styles.animatedContainer]}>
|
|
65
|
-
<
|
|
76
|
+
<components_1.TextInput ref={inputRef} value={searchQuery} onFocus={onFocus} onBlur={onBlur} returnKeyType={returnKeyType !== null && returnKeyType !== void 0 ? returnKeyType : "search"} label={label || placeholder || "Enter search term"} onChangeText={onChangeText} {...rest}/>
|
|
66
77
|
</react_native_reanimated_1.default.View>
|
|
67
78
|
<react_native_reanimated_1.default.View style={animatedCancelButtonStyle}>
|
|
68
79
|
<react_native_1.TouchableOpacity style={styles.cancelButton} onPress={onPressCancel}>
|
|
69
|
-
<
|
|
80
|
+
<components_1.Text style={styles.cancelButtonText}>Cancel</components_1.Text>
|
|
70
81
|
</react_native_1.TouchableOpacity>
|
|
71
82
|
</react_native_reanimated_1.default.View>
|
|
72
83
|
</react_native_1.View>);
|
|
73
84
|
};
|
|
74
|
-
exports.
|
|
75
|
-
|
|
76
|
-
const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)(theme => react_native_1.StyleSheet.create({
|
|
85
|
+
exports.default = Search;
|
|
86
|
+
const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((theme) => react_native_1.StyleSheet.create({
|
|
77
87
|
searchBarContainer: {
|
|
78
|
-
flexDirection:
|
|
79
|
-
width:
|
|
88
|
+
flexDirection: "row",
|
|
89
|
+
width: "100%",
|
|
80
90
|
},
|
|
81
91
|
animatedContainer: {
|
|
82
|
-
width:
|
|
83
|
-
justifyContent:
|
|
92
|
+
width: "100%",
|
|
93
|
+
justifyContent: "center",
|
|
84
94
|
},
|
|
85
95
|
cancelButton: {
|
|
86
96
|
flex: 1,
|
|
87
97
|
maxWidth: CANCEL_BUTTON_WIDTH,
|
|
88
98
|
minWidth: CANCEL_BUTTON_WIDTH,
|
|
89
|
-
justifyContent:
|
|
90
|
-
alignItems:
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
alignItems: "center",
|
|
91
101
|
},
|
|
92
102
|
cancelButtonText: {
|
|
93
103
|
color: theme.colors.primary,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Search";
|
|
2
|
+
export { default as Search } from "./Search";
|
|
@@ -13,5 +13,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Search = void 0;
|
|
17
21
|
__exportStar(require("./Search"), exports);
|
|
22
|
+
var Search_1 = require("./Search");
|
|
23
|
+
Object.defineProperty(exports, "Search", { enumerable: true, get: function () { return __importDefault(Search_1).default; } });
|
|
@@ -37,6 +37,8 @@ const hooks_1 = require("../../hooks");
|
|
|
37
37
|
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
38
38
|
const Chevron_1 = __importDefault(require("../Chevron"));
|
|
39
39
|
const animations_1 = require("../../constants/animations");
|
|
40
|
+
const useInputFieldFontSizeInterpolationOutputRange_1 = require("../../hooks/useInputFieldFontSizeInterpolationOutputRange");
|
|
41
|
+
const constants_1 = require("../../constants");
|
|
40
42
|
const SelectionItem_1 = __importDefault(require("./components/SelectionItem"));
|
|
41
43
|
function SelectInput({ caption, label, options = [], onChange, error, renderOption, containerStyle, }) {
|
|
42
44
|
const styles = useStyles().styles;
|
|
@@ -73,6 +75,7 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
|
|
|
73
75
|
animatedValue.value = (0, react_native_reanimated_1.withTiming)(value ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
74
76
|
}
|
|
75
77
|
}, [value]);
|
|
78
|
+
const labelFontSizeInterpolationOutputRange = (0, useInputFieldFontSizeInterpolationOutputRange_1.useInputFieldFontSizeInterpolationOutputRange)();
|
|
76
79
|
const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
77
80
|
return {
|
|
78
81
|
transform: [
|
|
@@ -80,13 +83,17 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
|
|
|
80
83
|
translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, animations_1.LABEL_INTERPOLATION_OUTPUT_RANGE, react_native_reanimated_1.Extrapolation.CLAMP),
|
|
81
84
|
},
|
|
82
85
|
],
|
|
83
|
-
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value,
|
|
86
|
+
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, labelFontSizeInterpolationOutputRange, react_native_reanimated_1.Extrapolation.CLAMP),
|
|
84
87
|
};
|
|
85
|
-
}, []);
|
|
88
|
+
}, [labelFontSizeInterpolationOutputRange]);
|
|
86
89
|
const animatedValueStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
87
90
|
return {
|
|
88
91
|
flex: 1,
|
|
89
|
-
transform: [
|
|
92
|
+
transform: [
|
|
93
|
+
{
|
|
94
|
+
translateY: animatedValue.value * animations_1.ANIMATED_VALUE_TRANSLATE_Y_MULTIPLIER,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
90
97
|
};
|
|
91
98
|
}, [animatedValue]);
|
|
92
99
|
const handleOptionPress = (0, react_1.useCallback)((option) => {
|
|
@@ -127,11 +134,11 @@ const useStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallback)((th
|
|
|
127
134
|
borderColor: theme.colors.backgroundOnPrimary,
|
|
128
135
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
129
136
|
borderRadius: theme.borderRadius,
|
|
130
|
-
minHeight: theme.size.baseSize *
|
|
137
|
+
minHeight: theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
131
138
|
flexDirection: "row",
|
|
132
139
|
alignItems: "center",
|
|
133
140
|
justifyContent: "space-between",
|
|
134
|
-
height: theme.size.baseSize *
|
|
141
|
+
height: theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
135
142
|
},
|
|
136
143
|
itemContainerFocused: {
|
|
137
144
|
borderColor: theme.colors.border,
|
|
@@ -47,6 +47,8 @@ const hooks_1 = require("../../hooks");
|
|
|
47
47
|
const FieldError_1 = require("../FieldError/FieldError");
|
|
48
48
|
const useInputFieldAnimatedBorder_1 = require("../../hooks/useInputFieldAnimatedBorder");
|
|
49
49
|
const animations_1 = require("../../constants/animations");
|
|
50
|
+
const useInputFieldFontSizeInterpolationOutputRange_1 = require("../../hooks/useInputFieldFontSizeInterpolationOutputRange");
|
|
51
|
+
const constants_1 = require("../../constants");
|
|
50
52
|
const getLabelStyle = (disabled, error, style) => {
|
|
51
53
|
if (disabled) {
|
|
52
54
|
return style.disabled;
|
|
@@ -95,6 +97,7 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
95
97
|
animatedValue.value = (0, react_native_reanimated_1.withTiming)(value ? 1 : 0, animations_1.DEFAULT_TIMING_CONFIG);
|
|
96
98
|
}
|
|
97
99
|
}, [value]);
|
|
100
|
+
const labelFontSizeInterpolationOutputRange = (0, useInputFieldFontSizeInterpolationOutputRange_1.useInputFieldFontSizeInterpolationOutputRange)();
|
|
98
101
|
const animatedLabelStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
99
102
|
return {
|
|
100
103
|
transform: [
|
|
@@ -102,13 +105,17 @@ exports.TextInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
102
105
|
translateY: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, animations_1.LABEL_INTERPOLATION_OUTPUT_RANGE),
|
|
103
106
|
},
|
|
104
107
|
],
|
|
105
|
-
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value,
|
|
108
|
+
fontSize: (0, react_native_reanimated_1.interpolate)(animatedValue.value, animations_1.LABEL_INTERPOLATION_RANGE, labelFontSizeInterpolationOutputRange),
|
|
106
109
|
};
|
|
107
|
-
}, []);
|
|
110
|
+
}, [labelFontSizeInterpolationOutputRange]);
|
|
108
111
|
const animatedInputStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
109
112
|
return {
|
|
110
113
|
flex: 1,
|
|
111
|
-
transform: [
|
|
114
|
+
transform: [
|
|
115
|
+
{
|
|
116
|
+
translateY: animatedValue.value * animations_1.ANIMATED_VALUE_TRANSLATE_Y_MULTIPLIER,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
112
119
|
};
|
|
113
120
|
});
|
|
114
121
|
(0, react_1.useEffect)(() => {
|
|
@@ -206,8 +213,8 @@ const useStyles = (disabled, error, multiline) => (0, hooks_1.useThemedStyle)((0
|
|
|
206
213
|
borderWidth: theme.borderWidth,
|
|
207
214
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
208
215
|
height: multiline
|
|
209
|
-
? theme.size.baseSize *
|
|
210
|
-
: theme.size.baseSize *
|
|
216
|
+
? theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER * 2.5
|
|
217
|
+
: theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
211
218
|
borderRadius: theme.borderRadius,
|
|
212
219
|
minHeight: theme.size.baseSize * 8,
|
|
213
220
|
flexDirection: "row",
|
|
@@ -222,7 +229,9 @@ const useStyles = (disabled, error, multiline) => (0, hooks_1.useThemedStyle)((0
|
|
|
222
229
|
},
|
|
223
230
|
labelContainer: {
|
|
224
231
|
left: theme.size.baseSize * 2,
|
|
225
|
-
top: multiline
|
|
232
|
+
top: multiline
|
|
233
|
+
? theme.size.baseSize * 1
|
|
234
|
+
: theme.size.baseSize * 2.5,
|
|
226
235
|
position: "absolute",
|
|
227
236
|
},
|
|
228
237
|
label: getLabelStyle(disabled, error, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export * from
|
|
1
|
+
export { default as TextInput } from "./TextInput";
|
|
2
|
+
export * from "./TextInput";
|
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.TextInput = void 0;
|
|
21
21
|
var TextInput_1 = require("./TextInput");
|
|
22
|
-
Object.defineProperty(exports, "
|
|
22
|
+
Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return __importDefault(TextInput_1).default; } });
|
|
23
23
|
__exportStar(require("./TextInput"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LABEL_INTERPOLATION_OUTPUT_RANGE = exports.LABEL_INTERPOLATION_RANGE = exports.DEFAULT_TIMING_CONFIG = exports.DEFAULT_EASING = void 0;
|
|
3
|
+
exports.ANIMATED_VALUE_TRANSLATE_Y_MULTIPLIER = exports.LABEL_INTERPOLATION_OUTPUT_RANGE = exports.LABEL_INTERPOLATION_RANGE = exports.DEFAULT_TIMING_CONFIG = exports.DEFAULT_EASING = void 0;
|
|
4
4
|
const react_native_reanimated_1 = require("react-native-reanimated");
|
|
5
5
|
exports.DEFAULT_EASING = react_native_reanimated_1.Easing.inOut(react_native_reanimated_1.Easing.quad);
|
|
6
6
|
exports.DEFAULT_TIMING_CONFIG = {
|
|
@@ -8,4 +8,5 @@ exports.DEFAULT_TIMING_CONFIG = {
|
|
|
8
8
|
easing: exports.DEFAULT_EASING,
|
|
9
9
|
};
|
|
10
10
|
exports.LABEL_INTERPOLATION_RANGE = [0, 1];
|
|
11
|
-
exports.LABEL_INTERPOLATION_OUTPUT_RANGE = [1, -
|
|
11
|
+
exports.LABEL_INTERPOLATION_OUTPUT_RANGE = [1, -10];
|
|
12
|
+
exports.ANIMATED_VALUE_TRANSLATE_Y_MULTIPLIER = 7;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIELD_HEIGHT_MULTIPLIER = 10;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useInputFieldFontSizeInterpolationOutputRange: () => number[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInputFieldFontSizeInterpolationOutputRange = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const useTheme_1 = require("./useTheme");
|
|
7
|
+
const useInputFieldFontSizeInterpolationOutputRange = () => {
|
|
8
|
+
const theme = (0, useTheme_1.useTheme)();
|
|
9
|
+
return (0, react_1.useMemo)(() => (0, utils_1.getInputLabelFontSizeInterpolationOutputRange)(theme), [theme]);
|
|
10
|
+
};
|
|
11
|
+
exports.useInputFieldFontSizeInterpolationOutputRange = useInputFieldFontSizeInterpolationOutputRange;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMenuItemStyles =
|
|
3
|
+
exports.useMenuItemStyles = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
|
-
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
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
10
|
container: {},
|
|
@@ -14,11 +14,11 @@ const useMenuItemStyles = () => (0, hooks_1.useThemedStyle)((0, react_1.useCallb
|
|
|
14
14
|
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
15
15
|
borderRadius: theme.borderRadius,
|
|
16
16
|
paddingHorizontal: theme.size.baseSize * 2,
|
|
17
|
-
minHeight:
|
|
17
|
+
minHeight: theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
18
18
|
flexDirection: "row",
|
|
19
19
|
justifyContent: "space-between",
|
|
20
20
|
alignItems: "center",
|
|
21
|
-
height: theme.size.baseSize *
|
|
21
|
+
height: theme.size.baseSize * constants_1.FIELD_HEIGHT_MULTIPLIER,
|
|
22
22
|
},
|
|
23
23
|
itemLabel: {
|
|
24
24
|
color: theme.colors.foregroundHighContrast,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AtlasTheme } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the font size interpolation output range for animated input labels.
|
|
4
|
+
*
|
|
5
|
+
* This function returns an array of font sizes used to animate text input labels
|
|
6
|
+
* between two states - typically from a larger size when the input is empty/unfocused
|
|
7
|
+
* to a smaller size when the input has content or is focused.
|
|
8
|
+
*
|
|
9
|
+
* @param theme - The Atlas theme object containing typography definitions
|
|
10
|
+
* @returns A tuple containing [largerFontSize, smallerFontSize] for label animation
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const theme = useTheme();
|
|
15
|
+
* const [startSize, endSize] = getInputLabelFontSizeInterpolationOutputRange(theme);
|
|
16
|
+
* // Use with react-native-reanimated interpolate function
|
|
17
|
+
* const animatedStyle = useAnimatedStyle(() => ({
|
|
18
|
+
* fontSize: interpolate(animationValue, [0, 1], [startSize, endSize])
|
|
19
|
+
* }));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const getInputLabelFontSizeInterpolationOutputRange: (theme: AtlasTheme) => number[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInputLabelFontSizeInterpolationOutputRange = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the font size interpolation output range for animated input labels.
|
|
6
|
+
*
|
|
7
|
+
* This function returns an array of font sizes used to animate text input labels
|
|
8
|
+
* between two states - typically from a larger size when the input is empty/unfocused
|
|
9
|
+
* to a smaller size when the input has content or is focused.
|
|
10
|
+
*
|
|
11
|
+
* @param theme - The Atlas theme object containing typography definitions
|
|
12
|
+
* @returns A tuple containing [largerFontSize, smallerFontSize] for label animation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const theme = useTheme();
|
|
17
|
+
* const [startSize, endSize] = getInputLabelFontSizeInterpolationOutputRange(theme);
|
|
18
|
+
* // Use with react-native-reanimated interpolate function
|
|
19
|
+
* const animatedStyle = useAnimatedStyle(() => ({
|
|
20
|
+
* fontSize: interpolate(animationValue, [0, 1], [startSize, endSize])
|
|
21
|
+
* }));
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const getInputLabelFontSizeInterpolationOutputRange = (theme) => {
|
|
25
|
+
const { typography } = theme;
|
|
26
|
+
return [typography.p1.fontSize, typography.p2.fontSize];
|
|
27
|
+
};
|
|
28
|
+
exports.getInputLabelFontSizeInterpolationOutputRange = getInputLabelFontSizeInterpolationOutputRange;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./animation";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./animation"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
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",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"minor": "npm version minor",
|
|
22
22
|
"watch": "tsc --watch",
|
|
23
23
|
"publish:dryrun": "npm publish --dry-run",
|
|
24
|
-
"publish:real": "yarn build &&
|
|
24
|
+
"publish:real": "yarn build && yarn publish",
|
|
25
|
+
"postinstall": "npx pod-install"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
27
28
|
"react-native",
|