From cddb336bb8fce6d438f005292266adb514b72c0e Mon Sep 17 00:00:00 2001 From: Gabriele Petronella Date: Thu, 21 Sep 2023 17:24:48 +0200 Subject: [PATCH 1/2] Add retrocompatible overload for createBentoProvider --- .../bento-design-system/src/BentoProvider.tsx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/bento-design-system/src/BentoProvider.tsx b/packages/bento-design-system/src/BentoProvider.tsx index 0881d869b..3764975b7 100644 --- a/packages/bento-design-system/src/BentoProvider.tsx +++ b/packages/bento-design-system/src/BentoProvider.tsx @@ -49,10 +49,31 @@ type Props = { } & DefaultMessages; export function createBentoProvider( - config: PartialBentoConfig = {}, + config?: PartialBentoConfig, + sprinkles?: SprinklesFn +): (props: Props) => JSX.Element; + +export function createBentoProvider( + config?: PartialBentoConfig, theme?: BentoTheme, - sprinkles: SprinklesFn = bentoSprinkles + sprinkles?: SprinklesFn +): (props: Props) => JSX.Element; + +export function createBentoProvider( + config: PartialBentoConfig = {}, + themeOrSprinkles?: BentoTheme | SprinklesFn, + sprinkles_?: SprinklesFn ) { + let sprinkles: SprinklesFn = bentoSprinkles; + let theme: BentoTheme | undefined = undefined; + if (typeof themeOrSprinkles === "function") { + sprinkles = themeOrSprinkles; + } + if (typeof themeOrSprinkles === "object") { + theme = themeOrSprinkles; + sprinkles = sprinkles_ ?? bentoSprinkles; + } + function OptionalThemeWrapper(props: { children: Children; theme?: BentoTheme }) { if (!props.theme) return <>{props.children}; return {props.children}; From ab63f4e2e550066c9dd31d9f6914ae460f4c0279 Mon Sep 17 00:00:00 2001 From: Federico Ercoles Date: Fri, 22 Sep 2023 10:26:40 +0200 Subject: [PATCH 2/2] Fix stories --- packages/bento-design-system/stories/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/bento-design-system/stories/index.tsx b/packages/bento-design-system/stories/index.tsx index e34c29579..0a1a58646 100644 --- a/packages/bento-design-system/stories/index.tsx +++ b/packages/bento-design-system/stories/index.tsx @@ -19,7 +19,6 @@ export const BentoProvider = createBentoProvider( itemsPerPageOptions: [5, 10, 20, 50], }, }, - undefined, sprinkles );