Skip to content

Commit fadf341

Browse files
committed
Another atempt to fix makeStyles typing
fixes #44
1 parent e7afbfa commit fadf341

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "3.0.1",
2+
"version": "3.0.2",
33
"name": "@committed/components",
44
"description": "Committed Component Library",
55
"author": "Committed",

src/hooks/index.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ import {
1212
makeStyles as materialMakeStyles,
1313
} from '@material-ui/styles'
1414

15+
export function useTheme<Theme = CommittedTheme>() {
16+
return materialUseTheme<Theme>()
17+
}
18+
19+
/**
20+
* `makeStyles` where the passed `styles` do not depend on props
21+
*/
22+
export function makeStyles<
23+
Theme = CommittedTheme,
24+
ClassKey extends string = string
25+
>(
26+
style: Styles<Theme, {}, ClassKey>,
27+
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
28+
): (props?: any) => ClassNameMap<ClassKey>
29+
1530
/**
1631
* `makeStyles` where the passed `styles` do depend on props
1732
*/
@@ -25,18 +40,17 @@ export function makeStyles<
2540
): (props: Props) => ClassNameMap<ClassKey>
2641

2742
/**
28-
* `makeStyles` where the passed `styles` do not depend on props
43+
* `makeStyles` where the passed `styles` do depend on props
2944
*/
3045
export function makeStyles<
3146
Theme = CommittedTheme,
47+
Props extends {} = {},
3248
ClassKey extends string = string
3349
>(
34-
style: Styles<Theme, {}, ClassKey>,
50+
styles: Styles<Theme, Props, ClassKey>,
3551
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
36-
): (props?: any) => ClassNameMap<ClassKey> {
37-
return materialMakeStyles<Theme, {}, ClassKey>(style, options)
38-
}
39-
40-
export function useTheme<Theme = CommittedTheme>() {
41-
return materialUseTheme<Theme>()
52+
):
53+
| ((props: Props) => ClassNameMap<ClassKey>)
54+
| ((props?: Props) => ClassNameMap<ClassKey>) {
55+
return materialMakeStyles<Theme, Props, ClassKey>(styles, options)
4256
}

0 commit comments

Comments
 (0)