Skip to content

Commit

Permalink
Design system init
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerSchaefer4 committed May 22, 2024
1 parent 313f136 commit 43b53e2
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 23 deletions.
27 changes: 6 additions & 21 deletions frontend/mobile/app/(app)/(tabs)/discover.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { StyleSheet, Text, View } from 'react-native';
import { Box, Text } from '@/app/(design-system)';

const DiscoverPage = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>Discover</Text>
</View>
<Box flex={1} alignItems="center" justifyContent="center" padding="m">
<Text color="aqua" variant="text-1">
DiscoverAA
</Text>
</Box>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
title: {
fontSize: 20,
fontWeight: 'bold'
},
separator: {
marginVertical: 30,
height: 1,
width: '80%'
}
});

export default DiscoverPage;
14 changes: 14 additions & 0 deletions frontend/mobile/app/(design-system)/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { PropsWithChildren } from 'react';
import { ViewProps } from 'react-native-svg/lib/typescript/fabric/utils';

import { BoxProps, createBox } from '@shopify/restyle';

import { Theme } from './theme';

type Props = ViewProps & PropsWithChildren & BoxProps<Theme>;

const BoxDefault = createBox<Theme>();

export const Box: React.FC<Props> = ({ style, ...rest }) => {
return <BoxDefault style={[style]} {...rest} />;
};
12 changes: 12 additions & 0 deletions frontend/mobile/app/(design-system)/Colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// TODO: We will have to change these
export const Colors = {
darkBlue: '#0C3354',
darkRed: '#C8102E',
green: '#14AC3F',
blue: '#2663FF',
aqua: '#35B8E2',
purple: '#9226FF',
red: '#EC2215',
orange: '#FF7426',
yellow: '#FFB626'
};
10 changes: 10 additions & 0 deletions frontend/mobile/app/(design-system)/Spacing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const Spacing = {
none: 0,
xxs: 4,
xs: 8,
s: 12,
m: 16,
l: 24,
xl: 32,
xxl: 40
};
5 changes: 5 additions & 0 deletions frontend/mobile/app/(design-system)/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createText } from '@shopify/restyle';

import { Theme } from './theme';

export const Text = createText<Theme>();
20 changes: 20 additions & 0 deletions frontend/mobile/app/(design-system)/TextVariants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Add actual text variants here
const Texts = {
'text-1': {
fontSize: 20,
fontWeight: 'bold'
},
'text-2': {
fontSize: 16,
fontWeight: 'normal'
},
'text-3': {
fontSize: 14,
fontWeight: 'normal'
}
} as const;

export const TextVariants = {
defaults: Texts['text-1'],
...Texts
};
5 changes: 5 additions & 0 deletions frontend/mobile/app/(design-system)/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './Text';
export * from './Box';
export * from './theme';
export * from './Colors';
export * from './Spacing';
13 changes: 13 additions & 0 deletions frontend/mobile/app/(design-system)/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createTheme } from '@shopify/restyle';

import { Colors } from './Colors';
import { Spacing } from './Spacing';
import { TextVariants } from './TextVariants';

export const theme = createTheme({
colors: Colors,
spacing: Spacing,
textVariants: TextVariants
});

export type Theme = typeof theme;
9 changes: 7 additions & 2 deletions frontend/mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';

import FontAwesome from '@expo/vector-icons/FontAwesome';
import { ThemeProvider } from '@shopify/restyle';

import { store } from '@/store/store';

import { theme } from './(design-system)';

export { ErrorBoundary } from 'expo-router';

SplashScreen.preventAutoHideAsync();
Expand Down Expand Up @@ -52,8 +55,10 @@ const RootLayout = () => {
return (
<GestureHandlerRootView style={{ flex: 1 }}>

Check warning on line 56 in frontend/mobile/app/_layout.tsx

View workflow job for this annotation

GitHub Actions / Lint

Inline style: { flex: 1 }
<Provider store={store}>
<StatusBar style="light" />
<InitalLayout />
<ThemeProvider theme={theme}>
<StatusBar style="light" />
<InitalLayout />
</ThemeProvider>
</Provider>
</GestureHandlerRootView>
);
Expand Down

0 comments on commit 43b53e2

Please sign in to comment.