Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: web utility props #1907

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 87 additions & 24 deletions packages/styled/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,23 +927,51 @@ export type UtilityProps<
Extract<keyof GetRNStyles<GenericComponentStyles>, string>
>]?: LastPart<key> extends keyof PropertyTokenType
? PropertyTokenType[LastPart<key>] extends 'sizes'
?
| WithSizeNegativeValue<GSConfig['tokens']>
| ExtendRNStyle<GetRNStyles<GenericComponentStyles>, LastPart<key>>
? key extends `$web-${string}`
? WithSizeNegativeValue<GSConfig['tokens']> | (string & {})
:
| WithSizeNegativeValue<GSConfig['tokens']>
| ExtendRNStyle<GenericComponentStyles, LastPart<key>>
: PropertyTokenType[LastPart<key>] extends 'space'
?
| WithNegativeValue<
StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
? key extends `$web-${string}`
?
| WithNegativeValue<
StringifyToken<
//@ts-ignore
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
>
>
| (string & {})
:
| WithNegativeValue<
StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
>
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
LastPart<key>
>
>
| ExtendRNStyle<GetRNStyles<GenericComponentStyles>, LastPart<key>>
: PropertyTokenType[LastPart<key>] extends keyof GSConfig['tokens']
?
| StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
>
| ExtendRNStyle<GetRNStyles<GenericComponentStyles>, LastPart<key>>
? key extends `$web-${string}`
?
| (string & {})
| StringifyToken<
//@ts-ignore
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
LastPart<key>
>
:
| StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[LastPart<key>]]
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
LastPart<key>
>
: LastPart<key> extends keyof GetRNStyles<GenericComponentStyles>
? GetRNStyles<GenericComponentStyles>[LastPart<key>]
: never
Expand All @@ -957,21 +985,56 @@ export type UtilityProps<
>]?: LastPart<key> extends keyof Aliases
? Aliases[LastPart<key>] extends keyof GetRNStyles<GenericComponentStyles>
? PropertyTokenType[Aliases[LastPart<key>]] extends 'sizes'
?
| WithSizeNegativeValue<GSConfig['tokens']>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
Aliases[LastPart<key>]
>
? key extends `$web-${string}`
?
| (string & {})
| WithSizeNegativeValue<GSConfig['tokens']>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
//@ts-ignore
Aliases[LastPart<key>]
>
:
| WithSizeNegativeValue<GSConfig['tokens']>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
Aliases[LastPart<key>]
>
: PropertyTokenType[Aliases[LastPart<key>]] extends 'space'
?
| WithNegativeValue<
StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[Aliases[LastPart<key>]]]
? key extends `$web-${string}`
?
| (string & {})
| WithNegativeValue<
StringifyToken<
//@ts-ignore
keyof GSConfig['tokens'][PropertyTokenType[Aliases[LastPart<key>]]]
>
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
//@ts-ignore
Aliases[LastPart<key>]
>
:
| WithNegativeValue<
StringifyToken<
keyof GSConfig['tokens'][PropertyTokenType[Aliases[LastPart<key>]]]
>
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
Aliases[LastPart<key>]
>
: key extends `$web-${string}`
?
| (string & {})
| StringifyToken<
//@ts-ignore
keyof GSConfig['tokens'][PropertyTokenType[Aliases[LastPart<key>]]]
>
| ExtendRNStyle<
GetRNStyles<GenericComponentStyles>,
//@ts-ignore
Aliases[LastPart<key>]
>
:
Expand Down
Loading