forked from Shopify/restyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestContainer.tsx
74 lines (67 loc) · 1.43 KB
/
TestContainer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React from 'react';
import {View, ViewProps} from 'react-native';
import useRestyle from '../hooks/useRestyle';
import createVariant, {VariantProps} from '../createVariant';
import composeRestyleFunctions from '../composeRestyleFunctions';
import {
backgroundColor,
BackgroundColorProps,
BorderProps,
spacing,
SpacingProps,
} from '../restyleFunctions';
const palette = {
purple: '#5A31F4',
green: '#099C77',
black: '#101010',
white: '#FFF',
};
export const theme = {
colors: {
background: palette.purple,
},
spacing: {
none: 0,
m: 8,
},
fontSizes: {
xs: 14,
s: 16,
m: 20,
l: 24,
},
breakpoints: {
phone: 320,
tablet: 768,
},
spacingVariant: {
defaults: {},
spacingParent: {
padding: {
phone: 'none',
tablet: 'none',
},
},
spacingNested: {
padding: {
phone: 'm',
tablet: 'm',
},
},
},
};
type Theme = typeof theme;
type RestyleProps = SpacingProps<Theme> &
BorderProps<Theme> &
BackgroundColorProps<Theme> &
VariantProps<Theme, 'spacingVariant'>;
const restyleFunctions = composeRestyleFunctions<Theme, RestyleProps>([
spacing,
backgroundColor,
createVariant({themeKey: 'spacingVariant'}),
]);
type Props = RestyleProps & ViewProps;
export const Container = ({children, ...rest}: Props) => {
const props = useRestyle(restyleFunctions, rest);
return <View {...props}>{children}</View>;
};