From d421a3847af41182de4fea6def2673f59cf2e842 Mon Sep 17 00:00:00 2001 From: Christoph Scheffauer Date: Tue, 25 Feb 2025 20:14:38 +0100 Subject: [PATCH] fix: switch to new js import --- .gitignore | 5 +---- config/storybook/cjs/theme.decorator.jsx | 1 - config/storybook/esm/theme.decorator.jsx | 1 - config/storybook/generateMain.js | 1 - config/storybook/src/theme.decorator.jsx | 3 --- package.json | 9 ++++---- scripts/copyIconsStorybook.js | 19 ----------------- .../ThemeProvider/ThemeProvider.tsx | 21 ++----------------- .../ThemeProvider/ThemeProvider.types.ts | 15 ------------- .../ThemeProvider/ThemeProvider.unit.test.tsx | 1 - .../ThemeProvider.unit.test.tsx.snap | 10 ++------- src/legacy/Lightbox/tests/index.spec.js.snap | 9 ++------ yarn.lock | 20 +++++++++--------- 13 files changed, 21 insertions(+), 94 deletions(-) delete mode 100644 scripts/copyIconsStorybook.js diff --git a/.gitignore b/.gitignore index 2b48d3870b..cb8a56a3a5 100644 --- a/.gitignore +++ b/.gitignore @@ -150,7 +150,4 @@ charts/es/ charts/lib/ charts/css/ charts/yarn.lock -.swc - - -config/storybook/public \ No newline at end of file +.swc \ No newline at end of file diff --git a/config/storybook/cjs/theme.decorator.jsx b/config/storybook/cjs/theme.decorator.jsx index bf54c33994..ce11879ad3 100644 --- a/config/storybook/cjs/theme.decorator.jsx +++ b/config/storybook/cjs/theme.decorator.jsx @@ -18,7 +18,6 @@ const theme = (Story, { globals }) => { { { typescript: { reactDocgen: 'none', }, - staticDirs: ['../public'], webpackFinal: (config) => { config.resolve.alias['@momentum-ui/react-collaboration'] = path.resolve( REPO_ROOT, diff --git a/config/storybook/src/theme.decorator.jsx b/config/storybook/src/theme.decorator.jsx index 55f15d4cea..61c07f032c 100644 --- a/config/storybook/src/theme.decorator.jsx +++ b/config/storybook/src/theme.decorator.jsx @@ -18,9 +18,6 @@ const theme = (Story, { globals }) => { { - try { - fse.copySync(srcDir, destDir, { overwrite: true }); - } catch (err) { - console.error(err); - } -}; - -copyFolderToDest(iconsFolder, storybookPublicDist); -console.log(chalk.gray('Icons have been copied successfully to Storybook public!')); -return; diff --git a/src/components/ThemeProvider/ThemeProvider.tsx b/src/components/ThemeProvider/ThemeProvider.tsx index 89cc5a74a2..853d539157 100644 --- a/src/components/ThemeProvider/ThemeProvider.tsx +++ b/src/components/ThemeProvider/ThemeProvider.tsx @@ -16,7 +16,6 @@ import { ThemeProvider as MdcThemeProvider, IconProvider as MdcIconProvider, } from '@momentum-design/components/dist/react'; -import { inMemoryCache, webAPIIconsCache } from '@momentum-design/components'; import { DEFAULTS, @@ -27,23 +26,10 @@ import { import { Props } from './ThemeProvider.types'; import './ThemeProvider.style.scss'; -interface ThemeProviderExtension { - inMemoryCache: typeof inMemoryCache; - webAPIIconsCache: typeof webAPIIconsCache; -} - /** * Provides a collection of CSSVariables based on a ThemeToken to all child elements inside of a rendered `
` element. */ -const ThemeProvider: FC & ThemeProviderExtension = ({ - children, - id, - style, - theme, - iconUrl, - iconCacheName, - iconCacheStrategy, -}: Props) => { +const ThemeProvider: FC = ({ children, id, style, theme }: Props) => { // TODO: get rid of legacy theme const themeClass = `${THEME_CLASS_PREFIX}-${theme || DEFAULTS.THEME}`; const themeClassStable = `${THEME_CLASS_PREFIX_STABLE}-${theme || DEFAULTS.THEME}`; @@ -53,7 +39,7 @@ const ThemeProvider: FC & ThemeProviderExtension = ({ themeclass={themeClassStable} className={classNames(themeClass, STYLE.typography)} > - +
{children}
@@ -62,7 +48,4 @@ const ThemeProvider: FC & ThemeProviderExtension = ({ ); }; -ThemeProvider.inMemoryCache = inMemoryCache; -ThemeProvider.webAPIIconsCache = webAPIIconsCache; - export default ThemeProvider; diff --git a/src/components/ThemeProvider/ThemeProvider.types.ts b/src/components/ThemeProvider/ThemeProvider.types.ts index 005ddf59e6..1ce7be8287 100644 --- a/src/components/ThemeProvider/ThemeProvider.types.ts +++ b/src/components/ThemeProvider/ThemeProvider.types.ts @@ -49,19 +49,4 @@ export interface Props { * The theme name to provide styles from to all child components. */ theme?: ThemeNames | MDTheme; - - /** - * The URL from where to fetch icons. - */ - iconUrl?: string; - - /** - * The icon cache strategy to use. - */ - iconCacheStrategy?: 'in-memory-cache' | 'web-cache-api'; - - /** - * The icon cache name to use. - */ - iconCacheName?: string; } diff --git a/src/components/ThemeProvider/ThemeProvider.unit.test.tsx b/src/components/ThemeProvider/ThemeProvider.unit.test.tsx index 72272646ef..191b171275 100644 --- a/src/components/ThemeProvider/ThemeProvider.unit.test.tsx +++ b/src/components/ThemeProvider/ThemeProvider.unit.test.tsx @@ -3,7 +3,6 @@ import { mount } from 'enzyme'; import ThemeProvider from './ThemeProvider'; import { - DEFAULTS, STYLE, THEME_CLASS_PREFIX, THEME_CLASS_PREFIX_STABLE, diff --git a/src/components/ThemeProvider/ThemeProvider.unit.test.tsx.snap b/src/components/ThemeProvider/ThemeProvider.unit.test.tsx.snap index 6e19f89f6e..8b986200a3 100644 --- a/src/components/ThemeProvider/ThemeProvider.unit.test.tsx.snap +++ b/src/components/ThemeProvider/ThemeProvider.unit.test.tsx.snap @@ -12,11 +12,8 @@ exports[` snapshot should match snapshot 1`] = ` class="md-theme-darkWebex mds-typography" suppressHydrationWarning={true} > - +
snapshot should match snapshot with style 1`] = ` class="md-theme-darkWebex mds-typography" suppressHydrationWarning={true} > - +
should match SnapShot 1`] = ` - +
@@ -303,11 +301,8 @@ exports[`tests for should match SnapShot 1`] = ` class="md-theme-darkWebex mds-typography" suppressHydrationWarning={true} > - +