Skip to content

Commit 2600c2c

Browse files
Update ComponentStyles type to override selectors w/ typed keys (#1613)
1 parent d6d8509 commit 2600c2c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

index.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ type PolymorphicBoxPropsOrTokens<T extends Components = Components> = Omit<
337337
TokenizableProps
338338
> & { [key in TokenizableProps]?: string }
339339

340-
export type StyleProps<T extends Components = Components> = {
341-
[key in ComponentPseudoSelectors<T>]: PolymorphicBoxPropsOrTokens<T>
342-
} & PolymorphicBoxPropsOrTokens<T>
340+
export type StyleProps<T extends Components = Components> = Omit<PolymorphicBoxPropsOrTokens<T>, 'selectors'> & {
341+
selectors: Partial<{
342+
[key in ComponentPseudoSelectors<T>]: PolymorphicBoxPropsOrTokens<T>
343+
}>
344+
}
343345

344346
export type ComponentStyle<T extends Components = Components> = {
345347
baseStyle?: Partial<StyleProps<T>>

index.test-d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ const themeOverridesOrAdditions: ThemeOverrides = {
3434
primary: {
3535
color: 'white',
3636
backgroundColor: '#fc7ef8',
37-
_hover: {
38-
backgroundColor: '#fc03f0'
39-
},
40-
_focus: {
41-
boxShadow: '0 0 0 2px #fccafa'
37+
selectors: {
38+
_hover: {
39+
backgroundColor: '#fc03f0'
40+
},
41+
_focus: {
42+
boxShadow: '0 0 0 2px #fccafa'
43+
}
4244
}
4345
},
4446
warning: {

0 commit comments

Comments
 (0)