Skip to content

Commit

Permalink
feat(DEV-13429): add spacing token
Browse files Browse the repository at this point in the history
  • Loading branch information
saladNights committed Dec 17, 2024
1 parent 4914388 commit 3cd040a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/sdk-react/src/core/theme/monite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ThemeConfig } from '@/core/theme/types';
export const getTheme = (theme: ThemeConfig) => {
return {
borderRadius: theme.borderRadius || 3,
spacing: theme.spacing || 24,

colors: {
primary: theme.colors?.primary || '#3737FF',
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-react/src/core/theme/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type TypographyStyle = {

export type ThemeConfig = {
borderRadius?: number;
spacing?: number;

colors?: {
primary?: string;
Expand Down
37 changes: 17 additions & 20 deletions packages/sdk-react/src/utils/storybook-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { apiVersion } from '@/api/api-version';
import { useMoniteContext } from '@/core/context/MoniteContext';
import { MoniteProvider, MoniteSettings } from '@/core/context/MoniteProvider';
import { messages as enLocaleMessages } from '@/core/i18n/locales/en/messages';
import { ThemeConfig } from '@/core/theme/types';
import { entityIds } from '@/mocks/entities';
import { css, Global } from '@emotion/react';
import { setupI18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { createTheme, ThemeOptions, ThemeProvider } from '@mui/material';
import { ThemeProviderProps } from '@mui/material/styles/ThemeProvider';
import { ThemeProvider } from '@mui/material';
import { deepmerge } from '@mui/utils';

Check failure on line 12 in packages/sdk-react/src/utils/storybook-utils.tsx

View workflow job for this annotation

GitHub Actions / Linting

'@mui/utils' should be listed in the project's dependencies. Run 'npm i -S @mui/utils' to add it
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -63,7 +63,7 @@ export const withGlobalStorybookDecorator = (

export const GlobalStorybookDecorator = (props: {
children: ReactNode;
theme?: ThemeOptions;
theme?: ThemeConfig;
monite?: MoniteSettings;
}) => {
const apiUrl = 'https://api.sandbox.monite.com/v1';
Expand Down Expand Up @@ -95,24 +95,21 @@ export const GlobalStorybookDecorator = (props: {
[]
);

const muiTheme = createTheme(props.theme);
const defaultThemeConfig: ThemeConfig = {
borderRadius: 10,

const backgroundColor =
muiTheme.palette?.mode === 'light'
? '#FFFFFF'
: muiTheme.palette?.background?.default;
colors: {
primary: '#000000',
},
};

return (
<>
<Global
styles={css`
body {
background-color: ${backgroundColor} !important;
}
`}
/>
<FallbackProviders theme={muiTheme}>
<MoniteProvider monite={props.monite ?? monite} theme={muiTheme}>
<FallbackProviders theme={deepmerge(defaultThemeConfig, props.theme)}>
<MoniteProvider
monite={props.monite ?? monite}
theme={deepmerge(defaultThemeConfig, props.theme)}
>
<MoniteReactQueryDevtools />
{props.children}
</MoniteProvider>
Expand All @@ -134,10 +131,10 @@ const MoniteReactQueryDevtools = () => {
*/
function FallbackProviders({
children,
theme,
theme = {},
}: {
children: ReactNode;
theme: ThemeProviderProps['theme'];
theme?: ThemeConfig;
}) {
const i18n = useMemo(() => {
return setupI18n({
Expand Down

0 comments on commit 3cd040a

Please sign in to comment.