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

feat: remove mergeThemes API #21278

Merged
merged 9 commits into from
Jan 14, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "remove mergeThemes from public API",
"packageName": "@fluentui/react-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "replace mergeThemes functionality from react-theme",
"packageName": "@fluentui/react-provider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "remove mergeThemes API",
"packageName": "@fluentui/react-theme",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 0 additions & 3 deletions packages/react-components/etc/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ import { MenuTriggerContextProvider } from '@fluentui/react-menu';
import { MenuTriggerProps } from '@fluentui/react-menu';
import { MenuTriggerState } from '@fluentui/react-menu';
import { mergeClasses } from '@fluentui/react-make-styles';
import { mergeThemes } from '@fluentui/react-theme';
import { OnOpenChangeData } from '@fluentui/react-popover';
import { OnVisibleChangeData } from '@fluentui/react-tooltip';
import { OpenPopoverEvents } from '@fluentui/react-popover';
Expand Down Expand Up @@ -743,8 +742,6 @@ export { MenuTriggerState }

export { mergeClasses }

export { mergeThemes }

export { OnOpenChangeData }

export { OnVisibleChangeData }
Expand Down
1 change: 0 additions & 1 deletion packages/react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export {
createHighContrastTheme,
createLightTheme,
createTeamsDarkTheme,
mergeThemes,
teamsDarkTheme,
teamsHighContrastTheme,
teamsLightTheme,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useKeyboardNavAttribute } from '@fluentui/react-tabster';
import { mergeThemes } from '@fluentui/react-theme';
import type { Theme } from '@fluentui/react-theme';
import { useFluent, useTheme } from '@fluentui/react-shared-contexts';
import { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';
import * as React from 'react';
Expand Down Expand Up @@ -44,3 +44,16 @@ export const useFluentProvider = (props: FluentProviderProps, ref: React.Ref<HTM
}),
};
};

function mergeThemes(a: Theme | undefined, b: Partial<Theme> | Theme | undefined): Theme {
// Merge impacts perf: we should like to avoid it if it's possible
if (a && b) {
return { ...a, ...b };
}

if (a) {
return a;
}

return b as Theme;
}
3 changes: 0 additions & 3 deletions packages/react-theme/etc/react-theme.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ export type LineHeightTokens = {
lineHeightHero1000: string;
};

// @public (undocumented)
export function mergeThemes(a: Theme | undefined, b: PartialTheme | Theme | undefined): Theme;

// @public (undocumented)
export type PartialTheme = Partial<Theme>;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint": "just-scripts lint",
"start": "yarn storybook",
"storybook": "start-storybook",
"test": "jest",
"test": "jest --passWithNoTests",
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-theme/src && yarn docs",
"type-check": "tsc -b tsconfig.json"
Expand Down
2 changes: 0 additions & 2 deletions packages/react-theme/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ export * from './createLightTheme';
export * from './createDarkTheme';
export * from './createTeamsDarkTheme';
export * from './createHighContrastTheme';

export { mergeThemes } from './mergeThemes';
21 changes: 0 additions & 21 deletions packages/react-theme/src/utils/mergeThemes.test.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/react-theme/src/utils/mergeThemes.ts

This file was deleted.