@@ -4,7 +4,7 @@ import {Typography, Colors, BorderRadiuses, Spacings, ThemeManager} from '../sty
4
4
import { BorderRadiusesLiterals } from '../style/borderRadiuses' ;
5
5
import TypographyPresets from '../style/typographyPresets' ;
6
6
import { SpacingLiterals } from '../style/spacings' ;
7
-
7
+ import { colorsPalette } from '../style/colorsPalette' ;
8
8
export const FLEX_KEY_PATTERN = / ^ f l e x ( G | S ) ? ( - \d * ) ? $ / ;
9
9
export const PADDING_KEY_PATTERN = new RegExp ( `padding[LTRBHV]?-([0-9]*|${ Spacings . getKeysPattern ( ) } )` ) ;
10
10
export const MARGIN_KEY_PATTERN = new RegExp ( `margin[LTRBHV]?-([0-9]*|${ Spacings . getKeysPattern ( ) } )` ) ;
@@ -42,9 +42,6 @@ const PADDING_VARIATIONS = {
42
42
paddingV : 'paddingVertical'
43
43
} as const ;
44
44
45
- export type PaddingModifierKeyType = keyof typeof PADDING_VARIATIONS ;
46
- export type NativePaddingKeyType = typeof PADDING_VARIATIONS [ PaddingModifierKeyType ] ;
47
-
48
45
const MARGIN_VARIATIONS = {
49
46
margin : 'margin' ,
50
47
marginL : 'marginLeft' ,
@@ -54,17 +51,46 @@ const MARGIN_VARIATIONS = {
54
51
marginH : 'marginHorizontal' ,
55
52
marginV : 'marginVertical'
56
53
} as const ;
57
- export type MarginModifierKeyType = keyof typeof MARGIN_VARIATIONS ;
58
- export type NativeMarginModifierKeyType = typeof MARGIN_VARIATIONS [ MarginModifierKeyType ] ;
59
54
60
55
const STYLE_KEY_CONVERTERS = {
61
56
flex : 'flex' ,
62
57
flexG : 'flexGrow' ,
63
58
flexS : 'flexShrink'
64
59
} as const ;
65
60
66
- export type FlexModifierKeyType = keyof typeof STYLE_KEY_CONVERTERS ;
67
- export type NativeFlexModifierKeyType = typeof STYLE_KEY_CONVERTERS [ FlexModifierKeyType ] ;
61
+
62
+ export type PaddingLiterals = keyof typeof PADDING_VARIATIONS ;
63
+ export type NativePaddingKeyType = typeof PADDING_VARIATIONS [ PaddingLiterals ] ;
64
+ export type MarginLiterals = keyof typeof MARGIN_VARIATIONS ;
65
+ export type NativeMarginModifierKeyType = typeof MARGIN_VARIATIONS [ MarginLiterals ] ;
66
+ export type FlexLiterals = keyof typeof STYLE_KEY_CONVERTERS ;
67
+ export type NativeFlexModifierKeyType = typeof STYLE_KEY_CONVERTERS [ FlexLiterals ] ;
68
+ export type ColorLiterals = keyof typeof colorsPalette ;
69
+ export type TypographyLiterals = keyof typeof TypographyPresets ;
70
+ export type BorderRadiusLiterals = keyof typeof BorderRadiusesLiterals ;
71
+ export type AlignmentLiterals =
72
+ | 'row' | 'spread'
73
+ | 'center' | 'centerH' | 'centerV'
74
+ | 'left' | 'right' | 'top' | 'bottom' ;
75
+
76
+ export type Modifier < T extends string > = Partial < Record < T , boolean > >
77
+
78
+ export type TypographyModifiers = Modifier < TypographyLiterals > ;
79
+ export type ColorsModifiers = Modifier < ColorLiterals > ;
80
+ export type AlignmentModifiers = Modifier < AlignmentLiterals > ;
81
+ export type PaddingModifiers = Modifier < PaddingLiterals > ;
82
+ export type MarginModifiers = Modifier < MarginLiterals > ;
83
+ export type FlexModifiers = Modifier < FlexLiterals > ;
84
+ export type BorderRadiusModifiers = Modifier < BorderRadiusLiterals > ;
85
+
86
+ export type ContainerModifiers =
87
+ AlignmentModifiers &
88
+ PaddingModifiers &
89
+ MarginModifiers &
90
+ FlexModifiers &
91
+ BorderRadiusModifiers ;
92
+
93
+
68
94
69
95
export function extractColorValue ( props : Dictionary < any > ) {
70
96
// const props = this.getThemeProps();
@@ -233,7 +259,7 @@ export function extractBorderRadiusValue(props: Dictionary<any>) {
233
259
let borderRadius ;
234
260
235
261
const keys = Object . keys ( props ) ;
236
- const radiusProp = keys . find ( prop => BorderRadiuses . getKeysPattern ( ) . test ( prop ) && props [ prop ] ) as keyof typeof BorderRadiusesLiterals ;
262
+ const radiusProp = keys . find ( prop => BorderRadiuses . getKeysPattern ( ) . test ( prop ) && props [ prop ] ) as BorderRadiusLiterals ;
237
263
if ( radiusProp ) {
238
264
borderRadius = BorderRadiuses [ radiusProp ] ;
239
265
}
0 commit comments