-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fix default theme and store #575
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import { AdminContext, defaultI18nProvider } from 'react-admin'; | ||
import { | ||
AdminContext, | ||
defaultI18nProvider, | ||
/* tree-shaking no-side-effects-when-called */ localStorageStore, | ||
} from 'react-admin'; | ||
|
||
import type { ComponentType } from 'react'; | ||
import type { AdminProps } from 'react-admin'; | ||
|
@@ -12,8 +16,8 @@ import { | |
Error as DefaultError, | ||
Layout, | ||
LoginPage, | ||
darkTheme, | ||
lightTheme, | ||
darkTheme as defaultDarkTheme, | ||
lightTheme as defaultLightTheme, | ||
} from '../layout/index.js'; | ||
import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from '../types.js'; | ||
|
||
|
@@ -24,6 +28,8 @@ export interface AdminGuesserProps extends AdminProps { | |
includeDeprecated?: boolean; | ||
} | ||
|
||
const defaultStore = localStorageStore(); | ||
|
||
const AdminGuesser = ({ | ||
// Props for SchemaAnalyzerContext | ||
schemaAnalyzer, | ||
|
@@ -33,7 +39,7 @@ const AdminGuesser = ({ | |
basename, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
error = DefaultError as any, | ||
store, | ||
store = defaultStore, | ||
dataProvider, | ||
i18nProvider = defaultI18nProvider, | ||
authProvider, | ||
|
@@ -42,7 +48,8 @@ const AdminGuesser = ({ | |
layout = Layout, | ||
loginPage = LoginPage, | ||
loading: loadingPage, | ||
theme = lightTheme, | ||
theme = defaultLightTheme, | ||
darkTheme = defaultDarkTheme, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a bug here - the dark theme couldn't be overridden |
||
// Other props | ||
children, | ||
...rest | ||
|
@@ -98,7 +105,6 @@ const AdminGuesser = ({ | |
queryClient={queryClient} | ||
theme={theme} | ||
darkTheme={darkTheme} | ||
lightTheme={lightTheme} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
defaultTheme={defaultTheme}> | ||
<IntrospectionContext.Provider value={introspectionContext}> | ||
<SchemaAnalyzerContext.Provider value={schemaAnalyzer}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ export const darkTheme: RaThemeOptions = { | |
}, | ||
}, | ||
}, | ||
MuiFilledInput: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The custom |
||
styleOverrides: undefined, | ||
}, | ||
}, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React-admin defines the default store in
react-adminù 's
Admincomponent. Since
AdminGuesserrelies on the lower-level
AdminContext`, we have to repeat the same initialization.