Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #374 from gluestack/release/@gluestack-style/react…
Browse files Browse the repository at this point in the history
…@0.2.19

Release/@gluestack style/[email protected]
  • Loading branch information
ankit-tailor authored Sep 1, 2023
2 parents 76f32c1 + fcf32ce commit 3575891
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gluestack-style/react",
"description": "A universal & performant styling library for React Native, Next.js & React",
"version": "0.2.18",
"version": "0.2.19",
"keywords": [
"React Native",
"Next.js",
Expand Down
118 changes: 79 additions & 39 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,19 @@ export type Aliases = GSConfig['aliases'];
export type Components = GSConfig['components'];
export type IMediaQueries = keyof GSConfig['tokens']['mediaQueries'];

export type SxStyleProps<GenericComponentStyles, Variants, P> = {
sx?: SxProps<GenericComponentStyles, Variants, P> & {
[Key in `@${IMediaQueries}`]?: SxProps<GenericComponentStyles, Variants, P>;
export type SxStyleProps<
GenericComponentStyles,
Variants,
GenericComponentProps
> = {
sx?: SxProps<GenericComponentStyles, Variants, GenericComponentProps> & {
[Key in `@${IMediaQueries}`]?: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps,
'',
Key
>;
};
};

Expand Down Expand Up @@ -259,7 +269,9 @@ export type StyledThemeProps<
[Key in `@${IMediaQueries}`]: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps
GenericComponentProps,
'',
Key
>;
} & {
variants: VariantType<
Expand Down Expand Up @@ -287,63 +299,83 @@ type StylePropsType<GenericComponentStyles = AliasesProps, PLATFORM = ''> =
AliasesProps<RNStyles<GenericComponentStyles>>)
| (PLATFORM extends '_web' ? TokenizedRNStyleProps<CSSProperties> : {});

type PassingPropsType<GenericComponentStyles, Variants, GenericComponentProps> =
{
props?: Partial<
GenericComponentProps &
RNStyles<GenericComponentStyles> &
AliasesProps<RNStyles<GenericComponentStyles>> & {
as?: any;
} & {
[Key in keyof MergeNested<
VariantType<
Variants,
GenericComponentStyles,
GenericComponentProps
>,
GlobalVariants
>]?: keyof MergeNested<
VariantType<
Variants,
GenericComponentStyles,
GenericComponentProps
>,
GlobalVariants
>[Key];
}
>;
};
type PassingPropsType<
GenericComponentStyles,
Variants,
GenericComponentProps,
MediaQuery
> = MediaQuery extends ''
? {
props?: Partial<
GenericComponentProps &
RNStyles<GenericComponentStyles> &
AliasesProps<RNStyles<GenericComponentStyles>> & {
as?: any;
} & {
[Key in keyof MergeNested<
VariantType<
Variants,
GenericComponentStyles,
GenericComponentProps
>,
GlobalVariants
>]?: keyof MergeNested<
VariantType<
Variants,
GenericComponentStyles,
GenericComponentProps
>,
GlobalVariants
>[Key];
}
>;
}
: {};

export type SxProps<
GenericComponentStyles = AliasesProps,
Variants = unknown,
GenericComponentProps = unknown,
PLATFORM = ''
PLATFORM = '',
MediaQuery = ''
> = Partial<
StylePropsType<GenericComponentStyles, PLATFORM> &
PassingPropsType<GenericComponentStyles, Variants, GenericComponentProps>
PassingPropsType<
GenericComponentStyles,
Variants,
GenericComponentProps,
MediaQuery
>
> & {
[Key in `_${COLORMODES}`]?: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps,
PLATFORM
PLATFORM,
MediaQuery
>;
} & {
[Key in `:${IState}`]?: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps,
PLATFORM
PLATFORM,
MediaQuery
>;
} & {
[Key in `_${PLATFORMS}`]?: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps,
Key
Key,
MediaQuery
> &
PassingPropsType<GenericComponentStyles, Variants, GenericComponentProps> &
PassingPropsType<
GenericComponentStyles,
Variants,
GenericComponentProps,
MediaQuery
> &
Partial<{
[key: string]: any;
}>;
Expand All @@ -352,9 +384,15 @@ export type SxProps<
RNStyledProps,
Variants,
GenericComponentProps,
PLATFORM
PLATFORM,
MediaQuery
> &
PassingPropsType<GenericComponentStyles, Variants, GenericComponentProps> &
PassingPropsType<
GenericComponentStyles,
Variants,
GenericComponentProps,
MediaQuery
> &
Partial<{
[key: string]: any;
}>;
Expand All @@ -372,7 +410,9 @@ export type VariantType<
[K in `@${IMediaQueries}`]?: SxProps<
GenericComponentStyles,
Variants,
GenericComponentProps
GenericComponentProps,
'',
K
>;
}
>;
Expand Down

0 comments on commit 3575891

Please sign in to comment.