Skip to content

Commit

Permalink
fix(ThemeProvider): changed theme to config prop name (#1528)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandr Isaev <[email protected]>
  • Loading branch information
IsaevAlexandr and IsaevAlexandr authored Apr 19, 2024
1 parent ba77921 commit 62431ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 13 additions & 4 deletions src/components/layout/LayoutProvider/LayoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {useCurrentActiveMediaQuery} from '../hooks/useCurrentActiveMediaQuery';
import type {LayoutTheme, MediaType, RecursivePartial} from '../types';
import {makeLayoutDefaultTheme} from '../utils/makeLayoutDefaultTheme';

export interface LayoutProviderProps {
theme?: RecursivePartial<LayoutTheme>;
export interface PrivateLayoutProviderProps {
config?: RecursivePartial<LayoutTheme>;
/**
* During ssr you can override default (`s`) media screen size if needed
*/
Expand All @@ -17,9 +17,9 @@ export interface LayoutProviderProps {

export function PrivateLayoutProvider({
children,
theme: override,
config: override,
initialMediaQuery,
}: LayoutProviderProps) {
}: PrivateLayoutProviderProps) {
const theme = React.useMemo(() => makeLayoutDefaultTheme({override}), [override]);
const activeMediaQuery = useCurrentActiveMediaQuery(theme.breakpoints, initialMediaQuery);

Expand All @@ -35,6 +35,15 @@ export function PrivateLayoutProvider({
);
}

interface LayoutProviderProps {
theme?: RecursivePartial<LayoutTheme>;
/**
* During ssr you can override default (`s`) media screen size if needed
*/
initialMediaQuery?: MediaType;
children: React.ReactNode;
}

/**
* @deprecated - already used as part of ThemeProvider. To override layout theme use `layout` prop
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function Title({title}: {title?: string}) {
);
}

export const LayoutPresenter = ({children, title, theme}: LayoutPresenterProps) => {
export const LayoutPresenter = ({children, title, theme: config}: LayoutPresenterProps) => {
return (
<ThemeProvider layout={{theme}}>
<ThemeProvider layout={{config}}>
<Title title={title} />
<div
style={{
Expand Down
4 changes: 2 additions & 2 deletions src/components/theme/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import {PrivateLayoutProvider} from '../layout/LayoutProvider/LayoutProvider';
import type {LayoutProviderProps} from '../layout/LayoutProvider/LayoutProvider';
import type {PrivateLayoutProviderProps} from '../layout/LayoutProvider/LayoutProvider';
import {block} from '../utils/cn';

import {ThemeContext} from './ThemeContext';
Expand All @@ -28,7 +28,7 @@ export interface ThemeProviderProps extends React.PropsWithChildren<{}> {
nativeScrollbar?: boolean;
scoped?: boolean;
rootClassName?: string;
layout?: Omit<LayoutProviderProps, 'children'>;
layout?: Omit<PrivateLayoutProviderProps, 'children'>;
}

export function ThemeProvider({
Expand Down

0 comments on commit 62431ca

Please sign in to comment.