Skip to content
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
4 changes: 2 additions & 2 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"dependencies": {
"@apollo/client": "^3.12.4",
"@mui/icons-material": "^6.0.0",
"@mui/material": "^6.0.0",
"@mui/icons-material": "^7.0.0",
"@mui/material": "^7.0.0",
"@types/recharts": "^1.8.10",
"@vitejs/plugin-react": "^2.2.0",
"clsx": "^2.1.1",
Expand Down
2 changes: 2 additions & 0 deletions examples/demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const store = localStorageStore(undefined, 'ECommerce');

const App = () => {
const [themeName] = useStore<ThemeName>('themeName', 'soft');
const singleTheme = themes.find(theme => theme.name === themeName)?.single;
const lightTheme = themes.find(theme => theme.name === themeName)?.light;
const darkTheme = themes.find(theme => theme.name === themeName)?.dark;
return (
Expand All @@ -58,6 +59,7 @@ const App = () => {
layout={Layout}
i18nProvider={i18nProvider}
disableTelemetry
theme={singleTheme}
lightTheme={lightTheme}
darkTheme={darkTheme}
defaultTheme="light"
Expand Down
7 changes: 1 addition & 6 deletions examples/demo/src/categories/CategoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ const CategoryGrid = () => {
<RecordContextProvider key={record.id} value={record}>
<Grid
key={record.id}
xs={12}
sm={6}
md={4}
lg={3}
xl={2}
item
size={{ xs: 12, sm: 6, md: 4, lg: 3, xl: 2 }}
>
<Card>
<CardMedia
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/src/invoices/InvoiceShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ const InvoiceShow = () => {
<Card sx={{ width: 600, margin: 'auto' }}>
<CardContent>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Typography variant="h6" gutterBottom>
Posters Galore
</Typography>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Typography variant="h6" gutterBottom align="right">
Invoice {record.id}
</Typography>
</Grid>
</Grid>
<Grid container spacing={2}>
<Grid item xs={12} container alignContent="flex-end">
<Grid size={{ xs: 12 }} alignContent="flex-end">
<ReferenceField
reference="customers"
source="customer_id"
Expand All @@ -36,7 +36,7 @@ const InvoiceShow = () => {
</Grid>
<Box height={20}>&nbsp;</Box>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Typography variant="h6" gutterBottom align="center">
Date{' '}
</Typography>
Expand All @@ -45,7 +45,7 @@ const InvoiceShow = () => {
</Typography>
</Grid>

<Grid item xs={5}>
<Grid size={{ xs: 5 }}>
<Typography variant="h6" gutterBottom align="center">
Order
</Typography>
Expand Down
10 changes: 9 additions & 1 deletion examples/demo/src/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import AppBar from './AppBar';
import Menu from './Menu';

export default ({ children }: { children: React.ReactNode }) => (
<Layout appBar={AppBar} menu={Menu}>
<Layout
appBar={AppBar}
menu={Menu}
sx={{
backgroundColor: theme =>
// @ts-expect-error TS mixes up the Theme type from all the different versions of MUI in the monorepo
(theme.vars || theme).palette.background.default,
}}
>
{children}
</Layout>
);
12 changes: 12 additions & 0 deletions examples/demo/src/mui.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {} from '@mui/material/themeCssVarsAugmentation';

declare module '@mui/material/styles' {
interface PaletteOptions {
bulkActionsToolbarColor?: string;
bulkActionsToolbarBackgroundColor?: string;
}
interface Palette {
bulkActionsToolbarColor: string;
bulkActionsToolbarBackgroundColor: string;
}
}
12 changes: 6 additions & 6 deletions examples/demo/src/orders/OrderEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,26 @@ const OrderForm = () => {
<Card>
<CardContent>
<Grid container spacing={1}>
<Grid item xs={12} sm={12} md={8}>
<Grid size={{ xs: 12, sm: 12, md: 8 }}>
<Typography variant="h6" gutterBottom>
{translate(
'resources.orders.section.order'
)}
</Typography>
<Grid container>
<Grid item xs={12} sm={12} md={6}>
<Grid size={{ xs: 12, sm: 12, md: 6 }}>
<Labeled source="date">
<DateField source="date" />
</Labeled>
</Grid>
<Grid item xs={12} sm={12} md={6}>
<Grid size={{ xs: 12, sm: 12, md: 6 }}>
<Labeled source="reference">
<TextField source="reference" />
</Labeled>
</Grid>
</Grid>
<Grid container>
<Grid item xs={12} sm={12} md={6}>
<Grid size={{ xs: 12, sm: 12, md: 6 }}>
<SelectInput
source="status"
choices={[
Expand All @@ -125,7 +125,7 @@ const OrderForm = () => {
sx={{ width: '80%' }}
/>
</Grid>
<Grid item xs={12} sm={12} md={6}>
<Grid size={{ xs: 12, sm: 12, md: 6 }}>
<Box mt={2}>
<BooleanInput
row={true}
Expand All @@ -135,7 +135,7 @@ const OrderForm = () => {
</Grid>
</Grid>
</Grid>
<Grid item xs={12} sm={12} md={4}>
<Grid size={{ xs: 12, sm: 12, md: 4 }}>
<Typography variant="h6" gutterBottom>
{translate(
'resources.orders.section.customer'
Expand Down
16 changes: 8 additions & 8 deletions examples/demo/src/products/ProductEditDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { InputAdornment, Grid } from '@mui/material';

export const ProductEditDetails = () => (
<Grid container columnSpacing={2}>
<Grid item xs={12} sm={8}>
<Grid size={{ xs: 12, sm: 8 }}>
<TextInput source="reference" validate={req} />
</Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 12, sm: 4 }}>
<ReferenceInput source="category_id" reference="categories">
<SelectInput optionText="name" validate={req} />
</ReferenceInput>
</Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 12, sm: 4 }}>
<NumberInput
source="width"
InputProps={{
Expand All @@ -29,7 +29,7 @@ export const ProductEditDetails = () => (
validate={req}
/>
</Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 12, sm: 4 }}>
<NumberInput
source="height"
InputProps={{
Expand All @@ -40,8 +40,8 @@ export const ProductEditDetails = () => (
validate={req}
/>
</Grid>
<Grid item xs={0} sm={4}></Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 0, sm: 48 }} />
<Grid size={{ xs: 12, sm: 4 }}>
<NumberInput
source="price"
InputProps={{
Expand All @@ -52,10 +52,10 @@ export const ProductEditDetails = () => (
validate={req}
/>
</Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 12, sm: 4 }}>
<NumberInput source="stock" validate={req} />
</Grid>
<Grid item xs={12} sm={4}>
<Grid size={{ xs: 12, sm: 4 }}>
<NumberInput source="sales" validate={req} />
</Grid>
</Grid>
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/src/reviews/ReviewEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ const ReviewEdit = ({ id, onCancel }: ReviewEditProps) => {
toolbar={<ReviewEditToolbar />}
>
<Grid container rowSpacing={1} mb={1}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Labeled source="customer_id">
<CustomerReferenceField source="customer_id" />
</Labeled>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Labeled label="resources.reviews.fields.product_id">
<ProductReferenceField />
</Labeled>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Labeled>
<DateField source="date" />
</Labeled>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<Labeled label="resources.reviews.fields.rating">
<StarRatingField />
</Labeled>
Expand Down
28 changes: 28 additions & 0 deletions examples/demo/src/themes/cssVariablesTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createTheme, lighten } from '@mui/material';
import { RaThemeOptions } from 'react-admin';

const defaultTheme = createTheme();
const lightTheme: RaThemeOptions = {
palette: {
mode: 'light',
bulkActionsToolbarBackgroundColor: lighten(
defaultTheme.palette.primary.light,
0.8
),
},
};
const darkTheme: RaThemeOptions = {
palette: {
mode: 'dark',
bulkActionsToolbarBackgroundColor: defaultTheme.palette.primary.dark,
},
};

export const cssVariablesTheme = createTheme({
cssVariables: true,
defaultColorScheme: 'light',
colorSchemes: {
light: lightTheme,
dark: darkTheme,
},
});
2 changes: 1 addition & 1 deletion examples/demo/src/themes/softTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const softDarkTheme = {
},
},
MuiFilledInput: {
styleOverrides: undefined,
styleOverrides: {},
},
MuiAppBar: {
styleOverrides: {
Expand Down
15 changes: 11 additions & 4 deletions examples/demo/src/themes/themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

import { softDarkTheme, softLightTheme } from './softTheme';
import { chiptuneTheme } from './chiptuneTheme';
import { cssVariablesTheme } from './cssVariablesTheme';

export type ThemeName =
| 'soft'
Expand All @@ -22,13 +23,15 @@ export type ThemeName =
| 'nano'
| 'radiant'
| 'house'
| 'chiptune';
| 'chiptune'
| 'cssVariables';

export interface Theme {
export type Theme = {
name: ThemeName;
light: RaThemeOptions;
light?: RaThemeOptions;
dark?: RaThemeOptions;
}
single?: RaThemeOptions;
};

const BW_SIDEBAR_OVERRIDE = {
styleOverrides: {
Expand All @@ -45,6 +48,10 @@ const BW_SIDEBAR_OVERRIDE = {

export const themes: Theme[] = [
{ name: 'soft', light: softLightTheme, dark: softDarkTheme },
{
name: 'cssVariables',
single: cssVariablesTheme,
},
{ name: 'default', light: defaultLightTheme, dark: defaultDarkTheme },
{
name: 'B&W',
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/src/visitors/Aside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const EventList = () => {
{translate('resources.customers.fieldGroups.history')}
</Typography>
<Grid container rowSpacing={1} columnSpacing={1}>
<Grid item xs={6} display="flex" gap={1}>
<Grid size={{ xs: 6 }} display="flex" gap={1}>
<AccessTimeIcon fontSize="small" color="disabled" />
<Box flexGrow={1}>
<Typography variant="body2">
Expand All @@ -88,7 +88,7 @@ const EventList = () => {
/>
</Box>
</Grid>
<Grid item xs={6} display="flex" gap={1}>
<Grid size={{ xs: 6 }} display="flex" gap={1}>
{totalOrders! > 0 && record && (
<>
<order.icon
Expand All @@ -115,7 +115,7 @@ const EventList = () => {
</>
)}
</Grid>
<Grid item xs={6} display="flex" gap={1}>
<Grid size={{ xs: 6 }} display="flex" gap={1}>
<AccessTimeIcon fontSize="small" color="disabled" />
<Box flexGrow={1}>
<Typography variant="body2">
Expand All @@ -126,7 +126,7 @@ const EventList = () => {
<DateField record={record} source="last_seen" />
</Box>
</Grid>
<Grid item xs={6} display="flex" gap={1}>
<Grid size={{ xs: 6 }} display="flex" gap={1}>
{totalReviews! > 0 && record && (
<>
<review.icon
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/visitors/VisitorEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const VisitorEdit = () => {
<SimpleForm validate={validateForm}>
<div>
<Grid container width={{ xs: '100%', xl: 800 }} spacing={2}>
<Grid item xs={12} md={8}>
<Grid size={{ xs: 12, md: 8 }}>
<Typography variant="h6" gutterBottom>
{translate(
'resources.customers.fieldGroups.identity'
Expand Down Expand Up @@ -98,7 +98,7 @@ const VisitorEdit = () => {
</Box>
</Box>
</Grid>
<Grid item xs={12} md={4}>
<Grid size={{ xs: 12, md: 4 }}>
<Typography variant="h6" gutterBottom>
{translate(
'resources.customers.fieldGroups.stats'
Expand Down
Loading
Loading