react-native-ui-datepicker
Version:
Customizable date picker for React Native
243 lines (226 loc) • 7.86 kB
text/typescript
import { useColorScheme } from 'react-native';
import { ClassNames, Styles } from './types';
import {
UI,
SelectionState,
DayFlag,
MonthState,
YearState,
CalenderFlag,
} from './ui';
export function useDefaultClassNames(): ClassNames {
const classNames: ClassNames = {
[ ]: '',
[ ]: 'p-0.5',
[ ]: 'group rounded-md web:hover:bg-accent',
[ ]: 'web:whitespace-nowrap text-foreground font-normal',
[ ]: '',
[ ]: 'group rounded-md web:hover:bg-accent active:bg-accent',
[ ]:
'web:whitespace-nowrap text-foreground group-active:text-accent-foreground font-normal',
[ ]: '',
[ ]: 'group rounded-md web:hover:bg-accent active:bg-accent',
[ ]:
'web:whitespace-nowrap text-foreground group-active:text-accent-foreground font-normal',
[ ]: 'bg-accent',
[ ]: '',
[ ]: '',
[ ]: 'mb-1',
[ ]: '',
[ ]: 'font-semibold text-lg text-foreground',
[ ]: '',
[ ]: 'font-semibold text-lg text-foreground',
[ ]: '',
[ ]: 'font-semibold text-lg text-foreground',
[ ]: '',
[ ]: '',
[ ]: 'text-sm uppercase text-muted-foreground',
[ ]: '',
[ ]: '',
[ ]: '',
[ ]: '',
[ ]: 'text-foreground text-2xl font-medium',
[ ]: 'bg-muted rounded-lg',
[ ]: '',
[ ]: 'text-primary-foreground',
[ ]: 'bg-transparent',
[ ]: 'text-accent-foreground',
[ ]: '',
[ ]: 'text-primary-foreground',
[ ]:
'group bg-primary web:hover:bg-primary web:hover:opacity-90 active:opacity-90',
[ ]: 'text-primary-foreground',
[ ]: '',
[ ]: 'text-muted-foreground opacity-50',
[ ]: '',
[ ]: '',
[ ]: 'text-muted-foreground',
[ ]: 'bg-accent',
[ ]: 'text-accent-foreground',
[ ]:
'group bg-primary web:hover:bg-primary web:hover:opacity-90 active:opacity-90',
[ ]: 'text-primary-foreground',
[ ]:
'group bg-primary web:hover:bg-primary web:hover:opacity-90 active:opacity-90',
[ ]: 'text-primary-foreground',
[ ]: 'bg-accent',
[ ]: 'text-accent-foreground',
};
return classNames;
}
export function useDefaultStyles(scheme?: 'dark' | 'light'): Styles {
const colorScheme = useColorScheme();
const theme = scheme || (colorScheme ?? 'light');
const styles: Styles = {
[ ]: {},
[ ]: { padding: 1.5 },
[ ]: { borderRadius: 5 },
[ ]: { color: COLORS[theme].accentForeground },
[ ]: {},
[ ]: {
borderColor: COLORS[theme].border,
borderWidth: 1,
borderRadius: 5,
},
[ ]: { color: COLORS[theme].accentForeground },
[ ]: {},
[ ]: {
borderColor: COLORS[theme].border,
borderWidth: 1,
borderRadius: 5,
},
[ ]: { color: COLORS[theme].accentForeground },
[ ]: { backgroundColor: COLORS[theme].accent },
[ ]: {},
[ ]: {},
[ ]: { marginBottom: 5 },
[ ]: {},
[ ]: {
fontSize: 16,
fontWeight: '500',
color: COLORS[theme].foreground,
},
[ ]: {},
[ ]: {
fontSize: 16,
fontWeight: '500',
color: COLORS[theme].foreground,
},
[ ]: {},
[ ]: {
fontSize: 16,
fontWeight: '500',
color: COLORS[theme].foreground,
},
[ ]: {},
[ ]: {},
[ ]: {
fontSize: 12,
textTransform: 'uppercase',
color: COLORS[theme].mutedForeground,
},
[ ]: {},
[ ]: {},
[ ]: {},
[ ]: {},
[ ]: {
fontSize: 22,
fontWeight: '500',
color: COLORS[theme].foreground,
},
[ ]: {
backgroundColor: COLORS[theme].muted,
borderRadius: 5,
},
[ ]: {},
[ ]: {
color: COLORS[theme].primaryForeground,
},
[ ]: { backgroundColor: 'transparent' },
[ ]: {
color: COLORS[theme].accentForeground,
},
[ ]: {},
[ ]: {
color: COLORS[theme].primaryForeground,
},
[ ]: {
backgroundColor: COLORS[theme].primary,
},
[ ]: {
color: COLORS[theme].primaryForeground,
},
[ ]: {},
[ ]: {
color: COLORS[theme].mutedForeground,
opacity: 0.5,
},
[ ]: {},
[ ]: {},
[ ]: { color: COLORS[theme].mutedForeground },
[ ]: { backgroundColor: COLORS[theme].accent },
[ ]: { color: COLORS[theme].accentForeground },
[ ]: {
backgroundColor: COLORS[theme].primary,
borderColor: COLORS[theme].primary,
},
[ ]: {
color: COLORS[theme].primaryForeground,
},
[ ]: {
backgroundColor: COLORS[theme].primary,
borderColor: COLORS[theme].primary,
},
[ ]: {
color: COLORS[theme].primaryForeground,
},
[ ]: {
backgroundColor: COLORS[theme].accent,
borderColor: COLORS[theme].accent,
},
[ ]: {
color: COLORS[theme].accentForeground,
},
};
return styles;
}
export const COLORS = {
light: {
background: 'hsl(0 0% 100%)',
foreground: 'hsl(240 10% 3.9%)',
card: 'hsl(0 0% 100%)',
cardForeground: 'hsl(240 10% 3.9%)',
popover: 'hsl(0 0% 100%)',
popoverForeground: 'hsl(240 10% 3.9%)',
primary: 'hsl(240 5.9% 10%)',
primaryForeground: 'hsl(0 0% 98%)',
secondary: 'hsl(240 4.8% 95.9%)',
secondaryForeground: 'hsl(240 5.9% 10%)',
muted: 'hsl(240 4.8% 95.9%)',
mutedForeground: 'hsl(240 3.8% 46.1%)',
accent: 'hsl(240 4.8% 95.9%)',
accentForeground: 'hsl(240 5.9% 10%)',
destructive: 'hsl(0 84.2% 60.2%)',
destructiveForeground: 'hsl(0 0% 98%)',
border: 'hsl(240 5.9% 90%)',
},
dark: {
background: 'hsl(240 10% 3.9%)',
foreground: 'hsl(0 0% 98%)',
card: 'hsl(240 10% 3.9%)',
cardForeground: 'hsl(0 0% 98%)',
popover: 'hsl(240 10% 3.9%)',
popoverForeground: 'hsl(0 0% 98%)',
primary: 'hsl(0 0% 98%)',
primaryForeground: 'hsl(240 5.9% 10%)',
secondary: 'hsl(240 3.7% 15.9%)',
secondaryForeground: 'hsl(0 0% 98%)',
muted: 'hsl(240 3.7% 15.9%)',
mutedForeground: 'hsl(240 5% 64.9%)',
accent: 'hsl(240 3.7% 15.9%)',
accentForeground: 'hsl(0 0% 98%)',
destructive: 'hsl(0 62.8% 30.6%)',
destructiveForeground: 'hsl(0 0% 98%)',
border: 'hsl(240 3.7% 15.9%)',
},
};