Skip to content

Commit

Permalink
refactor: clean up unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa committed Feb 3, 2025
1 parent 29364e3 commit 4204364
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion env.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const config = {
JS_FILE_VAR: 'JS_FILE_VAR_VALUE_FOR_EXAMPLE_APP',
};

module.exports = config;
export default config;
3 changes: 1 addition & 2 deletions example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { APP_INIT_ERROR, APP_READY, initialize } from '@edx/frontend-platform';
import { subscribe } from '@edx/frontend-platform/pubSub';
import { Routes, Route } from 'react-router-dom';

import './index.scss';
import ExamplePage from './ExamplePage';
import AuthenticatedPage from './AuthenticatedPage';

import './index.scss';

subscribe(APP_READY, () => {
ReactDOM.render(
<AppProvider>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
"i18n_extract": "fedx-scripts formatjs extract",
"snapshot": "fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io",
"start": "fedx-scripts webpack-dev-server --progress",
"test": "fedx-scripts jest --coverage",
"test:watch": "npm run test -- --watch"
},
Expand Down
6 changes: 3 additions & 3 deletions src/react/hooks/paragon/useParagonThemeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ const useParagonThemeCore = ({
return;

Check warning on line 77 in src/react/hooks/paragon/useParagonThemeCore.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeCore.js#L75-L77

Added lines #L75 - L77 were not covered by tests
}
const paragonThemeAccessor = isBrandOverride ? 'brand' : 'paragon';
const themeUrls = PARAGON_THEME?.[paragonThemeAccessor]?.themeUrls ?? {};
if (themeUrls.core) {
const coreThemeFallbackUrl = fallbackThemeUrl(themeUrls.core.fileName);
const core = PARAGON_THEME?.[paragonThemeAccessor]?.themeUrls?.core ?? {};
if (core) {
const coreThemeFallbackUrl = fallbackThemeUrl(core.fileName);
logInfo(`Falling back to locally installed core theme CSS: ${coreThemeFallbackUrl}`);
coreThemeLink = createCoreThemeLink(coreThemeFallbackUrl, { isFallbackThemeUrl: true, isBrandOverride });
const otherExistingLinks = getExistingCoreThemeLinks(isBrandOverride);
Expand Down
2 changes: 2 additions & 0 deletions src/react/hooks/paragon/useParagonThemeUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const useParagonThemeUrls = (config) => useMemo(() => {
const defaultThemeVariants = paragonThemeUrls.defaults;

// Local versions of @openedx/paragon and @edx/brand
// these are only used when passed into handleVersionSubstitution
// which does not attempt substitution using falsy value
const localParagonVersion = PARAGON_THEME?.paragon?.version;
const localBrandVersion = PARAGON_THEME?.brand?.version;

Expand Down
14 changes: 7 additions & 7 deletions src/react/hooks/paragon/useParagonThemeVariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const useParagonThemeVariants = ({
const [isBrandThemeVariantLoaded, setIsBrandThemeVariantLoaded] = useState(false);

useEffect(() => {
const someFn = (colorSchemeQuery) => {
const changeColorShceme = (colorSchemeQuery) => {
onDarkModeSystemPreferenceChange(colorSchemeQuery.matches);
};
const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');
if (colorSchemeQuery) {
colorSchemeQuery.addEventListener('change', someFn);
colorSchemeQuery.addEventListener('change', changeColorShceme);
}
return () => {
if (colorSchemeQuery) {
colorSchemeQuery.removeEventListener('change', someFn);
colorSchemeQuery.removeEventListener('change', changeColorShceme);
}
};
}, [onDarkModeSystemPreferenceChange]);
Expand All @@ -49,7 +49,7 @@ const useParagonThemeVariants = ({
document.querySelector('html').removeAttribute(htmlDataThemeVariantAttr);
};
}
return () => {}; // no-op
return () => {}; // Cleanup: no action needed when theme variant is not set
}, [themeVariants, currentThemeVariant]);

useEffect(() => {
Expand Down Expand Up @@ -127,9 +127,9 @@ const useParagonThemeVariants = ({
return;

Check warning on line 127 in src/react/hooks/paragon/useParagonThemeVariants.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeVariants.js#L125-L127

Added lines #L125 - L127 were not covered by tests
}
const paragonThemeAccessor = isBrandOverride ? 'brand' : 'paragon';
const themeUrls = PARAGON_THEME?.[paragonThemeAccessor]?.themeUrls ?? {};
if (themeUrls.variants && themeUrls.variants[themeVariant]) {
const themeVariantFallbackUrl = fallbackThemeUrl(themeUrls.variants[themeVariant].fileName);
const variants = PARAGON_THEME?.[paragonThemeAccessor]?.themeUrls?.variants ?? {};
if (variants[themeVariant]) {
const themeVariantFallbackUrl = fallbackThemeUrl(variants[themeVariant].fileName);
logInfo(`Falling back to locally installed theme variant (${themeVariant}) CSS: ${themeVariantFallbackUrl}`);
themeVariantLink = createThemeVariantLink(themeVariantFallbackUrl, {
isFallbackThemeUrl: true,
Expand Down
5 changes: 0 additions & 5 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ module.exports = createConfig('webpack-dev', {
'@edx/frontend-platform': path.resolve(__dirname, 'src'),
},
},
devServer: {
static: {
directory: path.resolve(__dirname, 'example/dist'),
},
},
});

0 comments on commit 4204364

Please sign in to comment.