Skip to content

Commit

Permalink
Adjust BW theme error color
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Feb 25, 2025
1 parent c3d60d4 commit 0fcfb7c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/demo/src/reviews/RejectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const RejectButton = () => {
{
mutationMode: 'undoable',
onSuccess: () => {
notify('resources.reviews.notification.rejected_success', {
notify('resources.reviews.notifications.rejected_success', {
type: 'info',
undoable: true,
});
redirectTo('/reviews');
},
onError: () => {
notify('resources.reviews.notification.rejected_error', {
notify('resources.reviews.notifications.rejected_error', {
type: 'error',
});
},
Expand Down
19 changes: 14 additions & 5 deletions packages/ra-ui-materialui/src/layout/Notification.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,28 @@ export const Basic = () => (
</Wrapper>
);

const TypeNotification = () => {
const TypeNotification = ({ type }) => {
const notify = useNotify();
React.useEffect(() => {
notify('hello, world', { type: 'warning' });
}, [notify]);
notify('hello, world', { type });
}, [notify, type]);
return null;
};

export const Type = () => (
export const Type = ({ type }) => (
<Wrapper>
<TypeNotification />
<TypeNotification type={type} />
</Wrapper>
);
Type.args = {
type: 'warning',
};
Type.argTypes = {
type: {
control: { type: 'select' },
options: ['info', 'warning', 'error', 'success'],
},
};

const MultilineNotification = () => {
const notify = useNotify();
Expand Down
47 changes: 47 additions & 0 deletions packages/ra-ui-materialui/src/theme/bwTheme.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';
import { Resource } from 'ra-core';
import fakerestDataProvider from 'ra-data-fakerest';
import englishTranslations from 'ra-language-english';
import polyglotI18nProvider from 'ra-i18n-polyglot';

import { AdminContext } from '../AdminContext';
import { AdminUI } from '../AdminUI';
import { ListGuesser } from '../list';
import { EditGuesser } from '../detail';
import { bwLightTheme, bwDarkTheme } from './bwTheme';
import { testData } from './testData';

export default {
title: 'ra-ui-materialui/theme/BW',
};

export const BW = () => (
<AdminContext
dataProvider={fakerestDataProvider(testData)}
lightTheme={bwLightTheme}
darkTheme={bwDarkTheme}
defaultTheme="light"
i18nProvider={polyglotI18nProvider(() => englishTranslations, 'en')}
>
<AdminUI>
<Resource
name="products"
list={ListGuesser}
edit={EditGuesser}
recordRepresentation="name"
/>
<Resource
name="categories"
list={ListGuesser}
edit={EditGuesser}
recordRepresentation="name"
/>
<Resource
name="tags"
list={ListGuesser}
edit={EditGuesser}
recordRepresentation="name"
/>
</AdminUI>
</AdminContext>
);
25 changes: 20 additions & 5 deletions packages/ra-ui-materialui/src/theme/bwTheme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
amber,
common,
deepOrange,
green,
grey,
lightBlue,
Expand All @@ -27,16 +28,16 @@ const createBWTheme = (mode: 'light' | 'dark'): RaThemeOptions => {
main: isDarkMode ? grey['100'] : grey['800'],
},
success: {
main: green['900'],
main: isDarkMode ? green['500'] : green['900'],
},
error: {
main: red['900'],
main: isDarkMode ? deepOrange['600'] : red['900'],
},
info: {
main: lightBlue['900'],
main: isDarkMode ? lightBlue['500'] : lightBlue['900'],
},
warning: {
main: amber['900'],
main: isDarkMode ? amber['500'] : amber['900'],
},
divider: GREY,
background: {
Expand Down Expand Up @@ -171,13 +172,27 @@ const createBWTheme = (mode: 'light' | 'dark'): RaThemeOptions => {
root: {
textTransform: 'none',
boxShadow: 'none',
'&.MuiButton-outlined': {
'&.MuiButton-outlinedPrimary': {
'--variant-outlinedBorder': GREY,
'&:hover': {
backgroundColor: GREY,
'--variant-outlinedBorder': GREY,
},
},
'&.MuiButton-outlinedError': {
'--variant-outlinedBorder': isDarkMode
? deepOrange['600']
: red['900'],
'&:hover': {
backgroundColor: isDarkMode
? deepOrange['600']
: red['900'],
color: common['white'],
'--variant-outlinedBorder': isDarkMode
? deepOrange['600']
: red['900'],
},
},
},
sizeSmall: {
padding: '4px 12px',
Expand Down

0 comments on commit 0fcfb7c

Please sign in to comment.