-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
117fb00
commit 89459fe
Showing
1 changed file
with
13 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { useCallback, useMemo } from "react"; | ||
import { IStyleFunctionOrObject, IStyleSet } from "@fluentui/react"; | ||
import { IStyleFunctionOrObject } from "@fluentui/react"; | ||
import { | ||
concatStyleSetsWithProps, | ||
concatStyleSets, | ||
IConcatenatedStyleSet, | ||
IStyleSetBase, | ||
} from "@fluentui/merge-styles"; | ||
|
||
export function useMergedStyles<TStylesProps, IStyleSet>( | ||
...styless: (IStyleFunctionOrObject<TStylesProps, IStyleSet> | undefined)[] | ||
): IStyleFunctionOrObject<TStylesProps, IStyleSet> { | ||
export function useMergedStyles<TStylesProps, TStyleSet extends IStyleSetBase>( | ||
...styless: (IStyleFunctionOrObject<TStylesProps, TStyleSet> | undefined)[] | ||
): ( | ||
props: TStylesProps | ||
) => ReturnType<typeof concatStyleSetsWithProps<TStylesProps, TStyleSet>> { | ||
return useCallback( | ||
(props) => { | ||
return concatStyleSetsWithProps(props, ...styless); | ||
}, | ||
// eslint-disable-next-line | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[...styless] | ||
); | ||
} | ||
|
||
export function useMergedStylesPlain( | ||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents | ||
...styless: (IStyleSet | undefined)[] | ||
): IConcatenatedStyleSet<IStyleSet> { | ||
export function useMergedStylesPlain<TStyleSet extends IStyleSetBase>( | ||
...styless: (TStyleSet | undefined)[] | ||
): IConcatenatedStyleSet<TStyleSet> { | ||
return useMemo( | ||
() => concatStyleSets(...styless), | ||
// eslint-disable-next-line | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[...styless] | ||
) as IConcatenatedStyleSet<IStyleSet>; | ||
) as IConcatenatedStyleSet<TStyleSet>; | ||
} |