atlas-design-system 1.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/.eslintrc.js +33 -0
- package/README.md +5 -0
- package/example/README.md +50 -0
- package/example/app/_layout.tsx +32 -0
- package/example/app/buttonGallery.tsx +49 -0
- package/example/app/dateTimeInputGallery.tsx +28 -0
- package/example/app/index.tsx +58 -0
- package/example/app/selectInputGallery.tsx +45 -0
- package/example/app/sheetGallery.tsx +36 -0
- package/example/app/switchToggleInputGallery.tsx +28 -0
- package/example/app/textGallery.tsx +68 -0
- package/example/app/textInputGallery.tsx +28 -0
- package/example/app.json +37 -0
- package/example/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/example/assets/images/adaptive-icon.png +0 -0
- package/example/assets/images/favicon.png +0 -0
- package/example/assets/images/icon.png +0 -0
- package/example/assets/images/partial-react-logo.png +0 -0
- package/example/assets/images/react-logo.png +0 -0
- package/example/assets/images/react-logo@2x.png +0 -0
- package/example/assets/images/react-logo@3x.png +0 -0
- package/example/assets/images/splash.png +0 -0
- package/example/babel.config.js +6 -0
- package/example/components/Collapsible.tsx +41 -0
- package/example/components/ExternalLink.tsx +24 -0
- package/example/components/ParallaxScrollView.tsx +76 -0
- package/example/components/ThemedText.tsx +60 -0
- package/example/components/ThemedView.tsx +14 -0
- package/example/components/__tests__/ThemedText-test.tsx +10 -0
- package/example/components/__tests__/__snapshots__/ThemedText-test.tsx.snap +24 -0
- package/example/components/navigation/TabBarIcon.js +24 -0
- package/example/components/navigation/TabBarIcon.tsx +9 -0
- package/example/constants/Colors.ts +26 -0
- package/example/hooks/useColorScheme.ts +1 -0
- package/example/hooks/useThemeColor.ts +22 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/Podfile +58 -0
- package/example/ios/Podfile.lock +1603 -0
- package/example/ios/Podfile.properties.json +4 -0
- package/example/ios/example/AppDelegate.h +7 -0
- package/example/ios/example/AppDelegate.mm +62 -0
- package/example/ios/example/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +14 -0
- package/example/ios/example/Images.xcassets/Contents.json +6 -0
- package/example/ios/example/Images.xcassets/SplashScreen.imageset/Contents.json +21 -0
- package/example/ios/example/Images.xcassets/SplashScreen.imageset/image.png +0 -0
- package/example/ios/example/Images.xcassets/SplashScreenBackground.imageset/Contents.json +21 -0
- package/example/ios/example/Images.xcassets/SplashScreenBackground.imageset/image.png +0 -0
- package/example/ios/example/Info.plist +81 -0
- package/example/ios/example/PrivacyInfo.xcprivacy +48 -0
- package/example/ios/example/SplashScreen.storyboard +51 -0
- package/example/ios/example/Supporting/Expo.plist +12 -0
- package/example/ios/example/example-Bridging-Header.h +3 -0
- package/example/ios/example/example.entitlements +5 -0
- package/example/ios/example/main.m +10 -0
- package/example/ios/example/noop-file.swift +4 -0
- package/example/ios/example.xcodeproj/project.pbxproj +555 -0
- package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +88 -0
- package/example/ios/example.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/metro.config.js +34 -0
- package/example/package.json +53 -0
- package/example/react-native.config.js +9 -0
- package/example/scripts/reset-project.js +73 -0
- package/example/tsconfig.json +17 -0
- package/example/yarn.lock +8571 -0
- package/package.json +49 -0
- package/src/components/Button/Button.tsx +110 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Button/styles/ButtonStyle.ts +47 -0
- package/src/components/DateTimeInput/index.tsx +172 -0
- package/src/components/DragHandle/index.tsx +49 -0
- package/src/components/MenuItemDescription/MenuItemDescription.tsx +34 -0
- package/src/components/MenuItemDescription/index.ts +1 -0
- package/src/components/NavigationListRow/index.tsx +68 -0
- package/src/components/SelectInput/SelectInput.tsx +191 -0
- package/src/components/SelectInput/index.ts +2 -0
- package/src/components/SelectInput/types.ts +5 -0
- package/src/components/Sheet/index.tsx +189 -0
- package/src/components/SwitchToggle/index.tsx +31 -0
- package/src/components/Text/Text.tsx +74 -0
- package/src/components/Text/index.tsx +2 -0
- package/src/components/TextInput/TextInput.tsx +241 -0
- package/src/components/TextInput/index.tsx +2 -0
- package/src/components/TitleBar/TitleBar.tsx +150 -0
- package/src/components/TitleBar/index.ts +2 -0
- package/src/components/index.ts +11 -0
- package/src/context/index.ts +6 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTheme.ts +7 -0
- package/src/hooks/useThemedStyle.ts +18 -0
- package/src/index.ts +5 -0
- package/src/shared/styles/index.ts +33 -0
- package/src/themes/AtlasLightTheme.ts +90 -0
- package/src/themes/index.ts +1 -0
- package/src/types/index.ts +3 -0
- package/src/types/theme.ts +45 -0
- package/src/types/typography.ts +14 -0
- package/tsconfig.json +111 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
} from "react";
|
|
7
|
+
import {
|
|
8
|
+
KeyboardTypeOptions,
|
|
9
|
+
StyleSheet,
|
|
10
|
+
View,
|
|
11
|
+
TextInput as RNTextInput,
|
|
12
|
+
TextInputProps as RNTextInputProps,
|
|
13
|
+
Pressable,
|
|
14
|
+
StyleProp,
|
|
15
|
+
ViewStyle,
|
|
16
|
+
} from "react-native";
|
|
17
|
+
import Animated, {
|
|
18
|
+
Easing,
|
|
19
|
+
interpolate,
|
|
20
|
+
interpolateColor,
|
|
21
|
+
useAnimatedStyle,
|
|
22
|
+
useSharedValue,
|
|
23
|
+
withTiming,
|
|
24
|
+
} from "react-native-reanimated";
|
|
25
|
+
|
|
26
|
+
import Text from "../Text";
|
|
27
|
+
import { MenuItemDescription } from "../MenuItemDescription";
|
|
28
|
+
import { useThemedStyle } from "../../hooks";
|
|
29
|
+
|
|
30
|
+
export type TextInputProps = {
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
testId?: string;
|
|
33
|
+
caption?: string;
|
|
34
|
+
keyboardType?: KeyboardTypeOptions;
|
|
35
|
+
onBlur?: (text: string) => void;
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
39
|
+
} & Omit<RNTextInputProps, "onBlur">;
|
|
40
|
+
|
|
41
|
+
export const TextInput = forwardRef(
|
|
42
|
+
(
|
|
43
|
+
{
|
|
44
|
+
caption,
|
|
45
|
+
keyboardType,
|
|
46
|
+
onChangeText,
|
|
47
|
+
testId,
|
|
48
|
+
value,
|
|
49
|
+
label,
|
|
50
|
+
onBlur,
|
|
51
|
+
containerStyle,
|
|
52
|
+
disabled = false,
|
|
53
|
+
...rest
|
|
54
|
+
}: TextInputProps,
|
|
55
|
+
ref
|
|
56
|
+
) => {
|
|
57
|
+
const { styles, theme } = useStyles(disabled);
|
|
58
|
+
|
|
59
|
+
const inputRef = useRef<RNTextInput>(null);
|
|
60
|
+
|
|
61
|
+
useImperativeHandle(ref, () => ({
|
|
62
|
+
focus: () => {
|
|
63
|
+
inputRef?.current?.focus();
|
|
64
|
+
},
|
|
65
|
+
blur: () => {
|
|
66
|
+
inputRef?.current?.blur();
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
const animatedValue = useSharedValue(value ? 1 : 0);
|
|
71
|
+
const focusedValue = useSharedValue(0);
|
|
72
|
+
|
|
73
|
+
const animatedLabelStyles = useAnimatedStyle(() => {
|
|
74
|
+
return {
|
|
75
|
+
transform: [
|
|
76
|
+
{ translateY: interpolate(animatedValue.value, [0, 1], [1, -8]) },
|
|
77
|
+
],
|
|
78
|
+
fontSize: interpolate(animatedValue.value, [0, 1], [14, 10]),
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
const animatedInputStyles = useAnimatedStyle(() => {
|
|
83
|
+
return {
|
|
84
|
+
flex: 1,
|
|
85
|
+
transform: [{ translateY: animatedValue.value * 4 }],
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const animatedContainerStyles = useAnimatedStyle(() => {
|
|
90
|
+
return {
|
|
91
|
+
borderColor: interpolateColor(
|
|
92
|
+
focusedValue.value,
|
|
93
|
+
[0, 1],
|
|
94
|
+
["#ffffff00", theme.colors.border]
|
|
95
|
+
),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const handleOnChangeText = (text: string) => {
|
|
100
|
+
if (text.length === 0) {
|
|
101
|
+
animatedValue.value = withTiming(0, {
|
|
102
|
+
duration: 200,
|
|
103
|
+
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
onChangeText?.(text);
|
|
107
|
+
if (value || animatedValue.value === 1) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
animatedValue.value = withTiming(1, {
|
|
111
|
+
duration: 200,
|
|
112
|
+
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const handleOnBlur: RNTextInputProps["onBlur"] = ({ nativeEvent }) => {
|
|
117
|
+
onBlur?.(nativeEvent.text);
|
|
118
|
+
focusedValue.value = withTiming(0, {
|
|
119
|
+
duration: 200,
|
|
120
|
+
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
121
|
+
});
|
|
122
|
+
if (!value) {
|
|
123
|
+
animatedValue.value = withTiming(0, {
|
|
124
|
+
duration: 200,
|
|
125
|
+
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const onFocus = () => {
|
|
131
|
+
focusedValue.value = withTiming(1, {
|
|
132
|
+
duration: 200,
|
|
133
|
+
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<View style={styles.container}>
|
|
139
|
+
<Pressable
|
|
140
|
+
onPress={() => {
|
|
141
|
+
inputRef?.current?.focus();
|
|
142
|
+
}}
|
|
143
|
+
style={styles.pressable}
|
|
144
|
+
disabled={disabled}
|
|
145
|
+
>
|
|
146
|
+
<Animated.View
|
|
147
|
+
style={[
|
|
148
|
+
styles.itemContainer,
|
|
149
|
+
animatedContainerStyles,
|
|
150
|
+
containerStyle,
|
|
151
|
+
]}
|
|
152
|
+
>
|
|
153
|
+
<View pointerEvents="none" style={styles.labelContainer}>
|
|
154
|
+
<Animated.Text style={[styles.label, animatedLabelStyles]}>
|
|
155
|
+
{label}
|
|
156
|
+
</Animated.Text>
|
|
157
|
+
</View>
|
|
158
|
+
<Animated.View style={animatedInputStyles}>
|
|
159
|
+
{disabled ? (
|
|
160
|
+
<Text style={styles.text}>{value}</Text>
|
|
161
|
+
) : (
|
|
162
|
+
<RNTextInput
|
|
163
|
+
ref={inputRef}
|
|
164
|
+
testID={testId}
|
|
165
|
+
value={value}
|
|
166
|
+
style={styles.textInput}
|
|
167
|
+
numberOfLines={1}
|
|
168
|
+
keyboardType={keyboardType}
|
|
169
|
+
placeholderTextColor={theme.placeholderTextColor}
|
|
170
|
+
onChangeText={handleOnChangeText}
|
|
171
|
+
maxLength={40}
|
|
172
|
+
returnKeyType="done"
|
|
173
|
+
onBlur={handleOnBlur}
|
|
174
|
+
onFocus={onFocus}
|
|
175
|
+
keyboardAppearance={theme.keyboardAppearance}
|
|
176
|
+
{...rest}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
</Animated.View>
|
|
180
|
+
</Animated.View>
|
|
181
|
+
</Pressable>
|
|
182
|
+
{!!caption && <MenuItemDescription description={caption} />}
|
|
183
|
+
</View>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
export default TextInput;
|
|
189
|
+
|
|
190
|
+
TextInput.displayName = 'TextInput'
|
|
191
|
+
|
|
192
|
+
const useStyles = (disabled: boolean) =>
|
|
193
|
+
useThemedStyle(
|
|
194
|
+
useCallback(
|
|
195
|
+
(theme) =>
|
|
196
|
+
StyleSheet.create({
|
|
197
|
+
container: {
|
|
198
|
+
width: "100%",
|
|
199
|
+
flexShrink: 0.5,
|
|
200
|
+
},
|
|
201
|
+
pressable: {
|
|
202
|
+
flexGrow: 2,
|
|
203
|
+
flexShrink: 1,
|
|
204
|
+
},
|
|
205
|
+
textInput: {
|
|
206
|
+
paddingHorizontal: theme.size.baseSize * 2,
|
|
207
|
+
...theme.typography.p1,
|
|
208
|
+
color: theme.colors.foregroundLowContrast,
|
|
209
|
+
},
|
|
210
|
+
text: {
|
|
211
|
+
marginTop: theme.size.baseSize,
|
|
212
|
+
paddingHorizontal: theme.size.baseSize * 2,
|
|
213
|
+
color: theme.colors.foregroundLowContrast,
|
|
214
|
+
},
|
|
215
|
+
itemContainer: {
|
|
216
|
+
borderWidth: theme.borderWidth,
|
|
217
|
+
borderColor: theme.colors.borderSecondary,
|
|
218
|
+
backgroundColor: theme.colors.backgroundOnPrimary,
|
|
219
|
+
borderRadius: theme.borderRadius,
|
|
220
|
+
minHeight: theme.size.baseSize * 8,
|
|
221
|
+
flexDirection: "row",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
},
|
|
224
|
+
labelContainer: {
|
|
225
|
+
left: theme.size.baseSize * 2,
|
|
226
|
+
position: "absolute",
|
|
227
|
+
},
|
|
228
|
+
label: {
|
|
229
|
+
color: !disabled
|
|
230
|
+
? theme.colors.foreground
|
|
231
|
+
: theme.colors.foregroundLowContrast,
|
|
232
|
+
...theme.typography.p1,
|
|
233
|
+
},
|
|
234
|
+
descriptionContainer: {
|
|
235
|
+
marginHorizontal: theme.size.baseSize * 4,
|
|
236
|
+
marginBottom: theme.size.baseSize * 2,
|
|
237
|
+
},
|
|
238
|
+
}),
|
|
239
|
+
[disabled]
|
|
240
|
+
)
|
|
241
|
+
);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { View, StyleSheet, ViewStyle, SafeAreaView, Pressable } from "react-native";
|
|
3
|
+
import IonIcons from 'react-native-vector-icons/Ionicons'
|
|
4
|
+
|
|
5
|
+
import { useThemedStyle } from "../../hooks";
|
|
6
|
+
import Text from "../Text";
|
|
7
|
+
import DragHandle from "../DragHandle";
|
|
8
|
+
|
|
9
|
+
const TitleBarHeight = 60;
|
|
10
|
+
|
|
11
|
+
export type TitleBarProps = {
|
|
12
|
+
title?: string;
|
|
13
|
+
titleComponent?: React.ReactElement;
|
|
14
|
+
rightItem?: React.ReactElement;
|
|
15
|
+
onBackPressed?: () => void;
|
|
16
|
+
canGoBack?: boolean;
|
|
17
|
+
type?: "modal" | "default";
|
|
18
|
+
containerStyle?: ViewStyle;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const TitleBar = ({
|
|
22
|
+
title,
|
|
23
|
+
onBackPressed,
|
|
24
|
+
canGoBack = true,
|
|
25
|
+
rightItem,
|
|
26
|
+
titleComponent,
|
|
27
|
+
type = "default",
|
|
28
|
+
containerStyle = {},
|
|
29
|
+
}: TitleBarProps) => {
|
|
30
|
+
const isModal = type === "modal";
|
|
31
|
+
const styles = useStyles(canGoBack, isModal).styles;
|
|
32
|
+
|
|
33
|
+
// const edges: [] = useMemo(() => {
|
|
34
|
+
// let _edges: [] = ['right', 'left'];
|
|
35
|
+
// if (!isModal) {
|
|
36
|
+
// _edges = [..._edges, 'top'];
|
|
37
|
+
// }
|
|
38
|
+
// return _edges;
|
|
39
|
+
// }, [isModal]);
|
|
40
|
+
|
|
41
|
+
const handleOnBackPress = useCallback(() => {
|
|
42
|
+
if (!onBackPressed) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
onBackPressed();
|
|
46
|
+
}, [onBackPressed]);
|
|
47
|
+
|
|
48
|
+
const renderBack = () => {
|
|
49
|
+
if (isModal || !canGoBack) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return (
|
|
53
|
+
<Pressable style={styles.backButtonContainer} onPress={handleOnBackPress}>
|
|
54
|
+
<IonIcons
|
|
55
|
+
style={styles.backButton}
|
|
56
|
+
name="chevron-back-outline"
|
|
57
|
+
size={20}
|
|
58
|
+
/>
|
|
59
|
+
</Pressable>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<SafeAreaView style={[styles.container, containerStyle]}>
|
|
65
|
+
{isModal && <DragHandle size="large" />}
|
|
66
|
+
<View style={styles.bar}>
|
|
67
|
+
{renderBack()}
|
|
68
|
+
{!!titleComponent && (
|
|
69
|
+
<View style={styles.titleComponentContainer}>{titleComponent}</View>
|
|
70
|
+
)}
|
|
71
|
+
{!titleComponent && !!title && (
|
|
72
|
+
<View style={styles.titleContainer}>
|
|
73
|
+
<Text
|
|
74
|
+
category="h1"
|
|
75
|
+
style={styles.headerTitle}
|
|
76
|
+
adjustsFontSizeToFit
|
|
77
|
+
numberOfLines={1}
|
|
78
|
+
>
|
|
79
|
+
{title ?? ""}
|
|
80
|
+
</Text>
|
|
81
|
+
</View>
|
|
82
|
+
)}
|
|
83
|
+
{!!rightItem && (
|
|
84
|
+
<View style={styles.rightItemContainer}>{rightItem}</View>
|
|
85
|
+
)}
|
|
86
|
+
</View>
|
|
87
|
+
</SafeAreaView>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const useStyles = (canGoBack: boolean, isModal: boolean) =>
|
|
92
|
+
useThemedStyle(
|
|
93
|
+
useCallback(
|
|
94
|
+
(theme) =>
|
|
95
|
+
StyleSheet.create({
|
|
96
|
+
container: {
|
|
97
|
+
backgroundColor: theme.colors.backgroundPrimary,
|
|
98
|
+
overflow: "hidden",
|
|
99
|
+
},
|
|
100
|
+
bar: {
|
|
101
|
+
flexDirection: "row",
|
|
102
|
+
paddingHorizontal: theme.size.baseSize * 2,
|
|
103
|
+
overflow: "hidden",
|
|
104
|
+
},
|
|
105
|
+
backButtonContainer: {
|
|
106
|
+
position: "absolute",
|
|
107
|
+
height: "100%",
|
|
108
|
+
top: 16,
|
|
109
|
+
justifyContent: "center",
|
|
110
|
+
zIndex: 20,
|
|
111
|
+
},
|
|
112
|
+
headerTitle: {
|
|
113
|
+
flexShrink: 1,
|
|
114
|
+
marginLeft: canGoBack
|
|
115
|
+
? theme.size.baseSize * 4
|
|
116
|
+
: theme.size.baseSize * 4,
|
|
117
|
+
paddingLeft: !canGoBack || isModal ? 0 : theme.size.baseSize * 4,
|
|
118
|
+
},
|
|
119
|
+
backButton: {
|
|
120
|
+
height: "100%",
|
|
121
|
+
marginLeft: theme.size.baseSize * 4,
|
|
122
|
+
},
|
|
123
|
+
titleComponentContainer: {
|
|
124
|
+
flex: 1,
|
|
125
|
+
justifyContent: "center",
|
|
126
|
+
paddingLeft: canGoBack ? theme.size.baseSize * 4 : 0,
|
|
127
|
+
},
|
|
128
|
+
titleContainer: {
|
|
129
|
+
flex: 1,
|
|
130
|
+
justifyContent: "center",
|
|
131
|
+
height: TitleBarHeight,
|
|
132
|
+
},
|
|
133
|
+
rightItemContainer: {
|
|
134
|
+
position: "absolute",
|
|
135
|
+
top: 0,
|
|
136
|
+
right: 0,
|
|
137
|
+
zIndex: 20,
|
|
138
|
+
justifyContent: "center",
|
|
139
|
+
alignItems: "flex-end",
|
|
140
|
+
height: "100%",
|
|
141
|
+
},
|
|
142
|
+
chevronBack: {
|
|
143
|
+
color: theme.colors.foreground,
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
[]
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
export default TitleBar;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./Button";
|
|
2
|
+
export * from "./Text";
|
|
3
|
+
export * from "./TextInput";
|
|
4
|
+
export * from "./SwitchToggle";
|
|
5
|
+
export * from "./Sheet";
|
|
6
|
+
export * from "./MenuItemDescription";
|
|
7
|
+
export * from "./DateTimeInput";
|
|
8
|
+
export * from "./NavigationListRow";
|
|
9
|
+
export * from "./DragHandle";
|
|
10
|
+
export * from "./TitleBar";
|
|
11
|
+
export * from "./SelectInput";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import useTheme from '../hooks/useTheme';
|
|
5
|
+
import { AtlasTheme } from '../types/theme';
|
|
6
|
+
|
|
7
|
+
export declare type ThemedStyleCreator<T extends StyleSheet.NamedStyles<unknown>> = (theme: AtlasTheme) => T;
|
|
8
|
+
|
|
9
|
+
export const useThemedStyle = <T extends StyleSheet.NamedStyles<unknown>>(creator: ThemedStyleCreator<T>) => {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
|
|
12
|
+
const styles = useMemo(() => creator(theme), [theme, creator]);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
theme,
|
|
16
|
+
styles,
|
|
17
|
+
};
|
|
18
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { useThemedStyle } from "../../hooks";
|
|
4
|
+
|
|
5
|
+
export const MENU_ITEM_HEIGHT = 40;
|
|
6
|
+
|
|
7
|
+
export const useMenuItemStyles = () =>
|
|
8
|
+
useThemedStyle(
|
|
9
|
+
useCallback(
|
|
10
|
+
theme =>
|
|
11
|
+
StyleSheet.create({
|
|
12
|
+
textInput: {
|
|
13
|
+
...theme.typography.h3,
|
|
14
|
+
},
|
|
15
|
+
container: {
|
|
16
|
+
marginBottom: theme.size.baseSize * 3,
|
|
17
|
+
},
|
|
18
|
+
itemContainer: {
|
|
19
|
+
backgroundColor: theme.menuItemContainerBackground,
|
|
20
|
+
borderRadius: theme.borderRadius,
|
|
21
|
+
paddingHorizontal: theme.size.baseSize * 2,
|
|
22
|
+
minHeight: MENU_ITEM_HEIGHT,
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
justifyContent: 'space-between',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
},
|
|
27
|
+
itemLabel: {
|
|
28
|
+
color: theme.textPrimary,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
[]
|
|
32
|
+
)
|
|
33
|
+
);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { AtlasTheme, FontWeights, Typography } from '../types';
|
|
2
|
+
|
|
3
|
+
const fontFamily = 'System';
|
|
4
|
+
const fontWeight: FontWeights = '700';
|
|
5
|
+
|
|
6
|
+
const typography: Typography = {
|
|
7
|
+
h1xl: {
|
|
8
|
+
fontSize: 32,
|
|
9
|
+
lineHeight: 36,
|
|
10
|
+
fontFamily,
|
|
11
|
+
fontWeight: '900',
|
|
12
|
+
},
|
|
13
|
+
h1: {
|
|
14
|
+
fontSize: 24,
|
|
15
|
+
lineHeight: 28,
|
|
16
|
+
fontFamily,
|
|
17
|
+
fontWeight,
|
|
18
|
+
},
|
|
19
|
+
h2: {
|
|
20
|
+
fontSize: 20,
|
|
21
|
+
lineHeight: 24,
|
|
22
|
+
fontFamily,
|
|
23
|
+
fontWeight,
|
|
24
|
+
},
|
|
25
|
+
h3: {
|
|
26
|
+
fontSize: 17,
|
|
27
|
+
lineHeight: 22,
|
|
28
|
+
fontFamily,
|
|
29
|
+
fontWeight,
|
|
30
|
+
},
|
|
31
|
+
p1: {
|
|
32
|
+
fontSize: 14,
|
|
33
|
+
lineHeight: 20,
|
|
34
|
+
fontFamily,
|
|
35
|
+
fontWeight,
|
|
36
|
+
},
|
|
37
|
+
p2: {
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
lineHeight: 18,
|
|
40
|
+
fontFamily,
|
|
41
|
+
fontWeight: '200',
|
|
42
|
+
},
|
|
43
|
+
p3: {
|
|
44
|
+
fontSize: 10,
|
|
45
|
+
lineHeight: 16,
|
|
46
|
+
fontFamily,
|
|
47
|
+
fontWeight: '200',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const ATLAS_LIGHT: AtlasTheme = {
|
|
52
|
+
size: {
|
|
53
|
+
baseSize: 5,
|
|
54
|
+
},
|
|
55
|
+
borderWidth: 2,
|
|
56
|
+
borderRadius: 10,
|
|
57
|
+
keyboardAppearance: 'light',
|
|
58
|
+
colors: {
|
|
59
|
+
primary: '#21b473',
|
|
60
|
+
primaryLowContrast: '#90d9b9',
|
|
61
|
+
secondaryPositive: '#02AD5D',
|
|
62
|
+
secondaryNegative: '#f55555',
|
|
63
|
+
secondaryWarning: '#FFC107',
|
|
64
|
+
foreground: '#2D2D2D',
|
|
65
|
+
foregroundHighContrast: '#0B0B0B',
|
|
66
|
+
foregroundLowContrast: '#8A8A8A',
|
|
67
|
+
foregroundPrimary: '#21b473',
|
|
68
|
+
foregroundNegative: '#f55555',
|
|
69
|
+
foregroundOnPrimary: '#fff',
|
|
70
|
+
border: '#898989',
|
|
71
|
+
borderSecondary: '#00000000',
|
|
72
|
+
backgroundPrimary: '#f1f1f1',
|
|
73
|
+
backgroundOnPrimary: '#e4e4e4',
|
|
74
|
+
},
|
|
75
|
+
typography,
|
|
76
|
+
isDarkTheme: false,
|
|
77
|
+
modalBackground: '#f6f6f6',
|
|
78
|
+
primary: '#21b473',
|
|
79
|
+
text: '#000000',
|
|
80
|
+
textPrimary: '#000',
|
|
81
|
+
textSecondary: '#fff',
|
|
82
|
+
menuItemContainerBackground: '#e4e4e4',
|
|
83
|
+
background: '#ffffff',
|
|
84
|
+
LIGHT_BAR_STYLE: 'light-content',
|
|
85
|
+
DARK_BAR_STYLE: 'dark-content',
|
|
86
|
+
card: 'rgb(255, 255, 255)',
|
|
87
|
+
chevronForward: '#afb0b3',
|
|
88
|
+
workoutStatisticsBarItemBackground: '#EDEDED',
|
|
89
|
+
placeholderTextColor: '#8A8A8A',
|
|
90
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AtlasLightTheme'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StatusBarStyle, TextInputProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { Typography } from './typography';
|
|
4
|
+
|
|
5
|
+
export type AtlasTheme = {
|
|
6
|
+
size: {
|
|
7
|
+
baseSize: number;
|
|
8
|
+
};
|
|
9
|
+
borderRadius: number;
|
|
10
|
+
borderWidth: number;
|
|
11
|
+
keyboardAppearance: TextInputProps['keyboardAppearance'];
|
|
12
|
+
colors: {
|
|
13
|
+
primary: string; // The main color for the theme
|
|
14
|
+
primaryLowContrast: string; // A low contrast version of the primary color. Used for disabled buttons
|
|
15
|
+
secondaryPositive: string; // Color for positive actions
|
|
16
|
+
secondaryNegative: string; // Color for negative actions
|
|
17
|
+
secondaryWarning: string; // Color for conveying a warning
|
|
18
|
+
foreground: string;
|
|
19
|
+
foregroundHighContrast: string;
|
|
20
|
+
foregroundLowContrast: string;
|
|
21
|
+
foregroundPrimary: string; // Color for positiveContent that will sit on the backgroundPrimary color
|
|
22
|
+
foregroundNegative: string; // Color for negative content that will sit on the backgroundPrimary color
|
|
23
|
+
foregroundOnPrimary: string;
|
|
24
|
+
border: string; // Primary border color
|
|
25
|
+
borderSecondary: string; // Color of the border when element is inactive
|
|
26
|
+
backgroundPrimary: string; // The main background color
|
|
27
|
+
backgroundOnPrimary: string; // Background color for items that will be on top of the background
|
|
28
|
+
};
|
|
29
|
+
// Deprecated use backgroundPrimary
|
|
30
|
+
background: string;
|
|
31
|
+
primary: string;
|
|
32
|
+
text: string;
|
|
33
|
+
modalBackground: string;
|
|
34
|
+
textPrimary: string;
|
|
35
|
+
textSecondary: string;
|
|
36
|
+
menuItemContainerBackground: string; // Deprecated use backgroundOnPrimary
|
|
37
|
+
LIGHT_BAR_STYLE: string;
|
|
38
|
+
DARK_BAR_STYLE: StatusBarStyle;
|
|
39
|
+
isDarkTheme: boolean;
|
|
40
|
+
card: string;
|
|
41
|
+
chevronForward: string;
|
|
42
|
+
workoutStatisticsBarItemBackground: string;
|
|
43
|
+
placeholderTextColor: string;
|
|
44
|
+
typography: Typography;
|
|
45
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TypographyVariants = 'h1xl' | 'h1' | 'h2' | 'h3' | 'p1' | 'p2' | 'p3';
|
|
2
|
+
|
|
3
|
+
export type FontWeights = '200' | '300' | '400' | '500' | '700' | '800' | '900';
|
|
4
|
+
|
|
5
|
+
export interface TypographyStyles {
|
|
6
|
+
fontSize: number;
|
|
7
|
+
lineHeight: number;
|
|
8
|
+
fontWeight: FontWeights;
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type Typography = {
|
|
13
|
+
[variant in TypographyVariants]: TypographyStyles;
|
|
14
|
+
};
|