feat : Librairie de base
This commit is contained in:
20
src/theme/ThemeProvider.tsx
Normal file
20
src/theme/ThemeProvider.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { type PropsWithChildren, useMemo } from 'react';
|
||||
|
||||
import colors from './colors';
|
||||
import spacing, { borderRadius } from './spacing';
|
||||
import typography from './typography';
|
||||
import { ThemeContext } from './useTheme';
|
||||
|
||||
export function ThemeProvider({ children }: PropsWithChildren) {
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
colors,
|
||||
typography,
|
||||
spacing,
|
||||
borderRadius,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
|
||||
}
|
||||
17
src/theme/colors.ts
Normal file
17
src/theme/colors.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export const colors = {
|
||||
deepBackground: '#0A0A12',
|
||||
surface: '#14141F',
|
||||
surfaceElevated: '#1E1E2D',
|
||||
border: '#2A2A3C',
|
||||
primary: '#FF2E88',
|
||||
secondary: '#7B3DFF',
|
||||
tertiary: '#28E0F0',
|
||||
success: '#3DDC97',
|
||||
textPrimary: '#F4F4FA',
|
||||
textSecondary: '#9A9AB4',
|
||||
signatureGradient: ['#7B3DFF', '#FF2E88'] as const,
|
||||
} as const;
|
||||
|
||||
export const signatureGradient = colors.signatureGradient;
|
||||
|
||||
export default colors;
|
||||
16
src/theme/index.ts
Normal file
16
src/theme/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import colors from './colors';
|
||||
import spacing, { borderRadius } from './spacing';
|
||||
import typography from './typography';
|
||||
|
||||
export const theme = {
|
||||
colors,
|
||||
typography,
|
||||
spacing,
|
||||
borderRadius,
|
||||
} as const;
|
||||
|
||||
export * from './ThemeProvider';
|
||||
export * from './useTheme';
|
||||
export { borderRadius, colors, spacing, typography };
|
||||
|
||||
export default theme;
|
||||
18
src/theme/spacing.ts
Normal file
18
src/theme/spacing.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export const spacing = {
|
||||
4: 4,
|
||||
8: 8,
|
||||
12: 12,
|
||||
16: 16,
|
||||
24: 24,
|
||||
32: 32,
|
||||
} as const;
|
||||
|
||||
export const space = spacing;
|
||||
|
||||
export const borderRadius = {
|
||||
card: 20,
|
||||
button: 14,
|
||||
chip: 9999,
|
||||
} as const;
|
||||
|
||||
export default spacing;
|
||||
67
src/theme/typography.ts
Normal file
67
src/theme/typography.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { Inter_400Regular, Inter_500Medium } from '@expo-google-fonts/inter';
|
||||
import { SpaceGrotesk_600SemiBold, SpaceGrotesk_700Bold } from '@expo-google-fonts/space-grotesk';
|
||||
import { useFonts } from 'expo-font';
|
||||
|
||||
export const fontFamily = {
|
||||
display: 'SpaceGrotesk_600SemiBold',
|
||||
displayBold: 'SpaceGrotesk_700Bold',
|
||||
body: 'Inter_400Regular',
|
||||
bodyMedium: 'Inter_500Medium',
|
||||
mono: 'monospace',
|
||||
} as const;
|
||||
|
||||
export const typography = {
|
||||
display: {
|
||||
fontFamily: fontFamily.display,
|
||||
fontSize: 40,
|
||||
lineHeight: 48,
|
||||
letterSpacing: -0.8,
|
||||
},
|
||||
screenTitle: {
|
||||
fontFamily: fontFamily.displayBold,
|
||||
fontSize: 26,
|
||||
lineHeight: 32,
|
||||
letterSpacing: -0.6,
|
||||
},
|
||||
cardTitle: {
|
||||
fontFamily: fontFamily.display,
|
||||
fontSize: 18,
|
||||
lineHeight: 24,
|
||||
letterSpacing: -0.2,
|
||||
},
|
||||
sectionLabel: {
|
||||
fontFamily: fontFamily.mono,
|
||||
fontSize: 11,
|
||||
lineHeight: 16,
|
||||
letterSpacing: 0.8,
|
||||
textTransform: 'uppercase' as const,
|
||||
},
|
||||
body: {
|
||||
fontFamily: fontFamily.body,
|
||||
fontSize: 15,
|
||||
lineHeight: 22,
|
||||
letterSpacing: 0,
|
||||
},
|
||||
metadata: {
|
||||
fontFamily: fontFamily.bodyMedium,
|
||||
fontSize: 13,
|
||||
lineHeight: 18,
|
||||
letterSpacing: 0,
|
||||
},
|
||||
digits: {
|
||||
fontFamily: fontFamily.mono,
|
||||
fontSize: 11,
|
||||
lineHeight: 16,
|
||||
letterSpacing: 0.4,
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const loadFonts = () =>
|
||||
useFonts({
|
||||
SpaceGrotesk_600SemiBold,
|
||||
SpaceGrotesk_700Bold,
|
||||
Inter_400Regular,
|
||||
Inter_500Medium,
|
||||
});
|
||||
|
||||
export default typography;
|
||||
24
src/theme/useTheme.ts
Normal file
24
src/theme/useTheme.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
import colors from './colors';
|
||||
import spacing, { borderRadius } from './spacing';
|
||||
import typography from './typography';
|
||||
|
||||
export type ThemeContextValue = {
|
||||
colors: typeof colors;
|
||||
typography: typeof typography;
|
||||
spacing: typeof spacing;
|
||||
borderRadius: typeof borderRadius;
|
||||
};
|
||||
|
||||
export const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);
|
||||
|
||||
export const useTheme = () => {
|
||||
const context = useContext(ThemeContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error('useTheme must be used within a ThemeProvider');
|
||||
}
|
||||
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user