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: pass direction to theme provider #1363

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@graasp/query-client": "3.16.0",
"@graasp/sdk": "4.20.0",
"@graasp/translations": "1.32.0",
"@graasp/ui": "4.22.0",
"@graasp/ui": "4.23.0",
"@mui/icons-material": "5.16.4",
"@mui/lab": "5.0.0-alpha.172",
"@mui/material": "5.16.4",
Expand Down
52 changes: 34 additions & 18 deletions src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import { I18nextProvider } from 'react-i18next';
import { BrowserRouter as Router } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';

import { CssBaseline, ThemeProvider } from '@mui/material';
import { CssBaseline } from '@mui/material';

import { theme } from '@graasp/ui';
import { langs } from '@graasp/translations';
import { ThemeProvider } from '@graasp/ui';

import * as Sentry from '@sentry/react';

import i18nConfig from '../config/i18n';
import i18nConfig, { useCommonTranslation } from '../config/i18n';
import {
QueryClientProvider,
ReactQueryDevtools,
hooks,
queryClient,
} from '../config/queryClient';
import App from './App';
Expand All @@ -29,25 +31,39 @@ import { CurrentUserContextProvider } from './context/CurrentUserContext';
import { FilterItemsContextProvider } from './context/FilterItemsContext';
import ModalProviders from './context/ModalProviders';

const ThemeWrapper = () => {
const { i18n } = useCommonTranslation();
const { data: currentMember } = hooks.useCurrentMember();

return (
<ThemeProvider
langs={langs}
languageSelectSx={{ mb: 2, mr: 2 }}
i18n={i18n}
defaultDirection={i18n.dir(currentMember?.extra?.lang)}
>
<CssBaseline />
<ToastContainer stacked position="bottom-left" theme="colored" />
<Router>
<Sentry.ErrorBoundary fallback={<FallbackComponent />}>
<ModalProviders>
<CurrentUserContextProvider>
<FilterItemsContextProvider>
<App />
</FilterItemsContextProvider>
</CurrentUserContextProvider>
</ModalProviders>
</Sentry.ErrorBoundary>
</Router>
</ThemeProvider>
);
};

const Root = (): JSX.Element => (
<HelmetProvider>
<QueryClientProvider client={queryClient}>
<I18nextProvider i18n={i18nConfig}>
<ThemeProvider theme={theme}>
<CssBaseline />
<ToastContainer stacked position="bottom-left" theme="colored" />
<Router>
<Sentry.ErrorBoundary fallback={<FallbackComponent />}>
<ModalProviders>
<CurrentUserContextProvider>
<FilterItemsContextProvider>
<App />
</FilterItemsContextProvider>
</CurrentUserContextProvider>
</ModalProviders>
</Sentry.ErrorBoundary>
</Router>
</ThemeProvider>
<ThemeWrapper />
</I18nextProvider>
{import.meta.env.DEV && import.meta.env.MODE !== 'test' && (
<ReactQueryDevtools position="bottom-left" />
Expand Down
33 changes: 25 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1978,9 +1978,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/ui@npm:4.22.0":
version: 4.22.0
resolution: "@graasp/ui@npm:4.22.0"
"@graasp/ui@npm:4.23.0":
version: 4.23.0
resolution: "@graasp/ui@npm:4.23.0"
dependencies:
"@ag-grid-community/client-side-row-model": "npm:31.3.2"
"@ag-grid-community/react": "npm:^31.3.2"
Expand Down Expand Up @@ -2014,7 +2014,7 @@ __metadata:
react-router-dom: ^6.11.0
stylis: ^4.1.3
stylis-plugin-rtl: ^2.1.1
checksum: 10/af8bcd06fd743d84739bf1c20aaceca67321c12456bcd905e7233d50c51c3fed25da41c835f8e9d1543a26a46f1da851c45222763dcbc7ad884cf0abb61b63d3
checksum: 10/26d99acd179daee8315b632b28590c10b13e991ef6c66fcda916937e6fff6ce6d8f424fdd2499beba6ef0c3f91d705181b73ec6fe0e551d4b50f1615d1fadb64
languageName: node
linkType: hard

Expand Down Expand Up @@ -3565,8 +3565,8 @@ __metadata:
linkType: hard

"@testing-library/jest-dom@npm:^6.4.2":
version: 6.4.8
resolution: "@testing-library/jest-dom@npm:6.4.8"
version: 6.4.6
resolution: "@testing-library/jest-dom@npm:6.4.6"
dependencies:
"@adobe/css-tools": "npm:^4.4.0"
"@babel/runtime": "npm:^7.9.2"
Expand All @@ -3576,7 +3576,24 @@ __metadata:
dom-accessibility-api: "npm:^0.6.3"
lodash: "npm:^4.17.21"
redent: "npm:^3.0.0"
checksum: 10/011e5a309e2cfc0c5cee6454427030d9a5d690df212bedcc78c15ee8d23218c3e51be32617ca879f060445ba0ba38e1b8d224b5ab11444ee076c37ed8c1c123a
peerDependencies:
"@jest/globals": ">= 28"
"@types/bun": "*"
"@types/jest": ">= 28"
jest: ">= 28"
vitest: ">= 0.32"
peerDependenciesMeta:
"@jest/globals":
optional: true
"@types/bun":
optional: true
"@types/jest":
optional: true
jest:
optional: true
vitest:
optional: true
checksum: 10/94fad29d740ff2c34967c644e2481a472aa8eeb1f11cdec5d4f81f14b2576660387551264c0fa718c15bfc61dd342f7621d888fe3e4ba1b7f830fe65bdd37bc8
languageName: node
linkType: hard

Expand Down Expand Up @@ -8137,7 +8154,7 @@ __metadata:
"@graasp/query-client": "npm:3.16.0"
"@graasp/sdk": "npm:4.20.0"
"@graasp/translations": "npm:1.32.0"
"@graasp/ui": "npm:4.22.0"
"@graasp/ui": "npm:4.23.0"
"@mui/icons-material": "npm:5.16.4"
"@mui/lab": "npm:5.0.0-alpha.172"
"@mui/material": "npm:5.16.4"
Expand Down