Skip to content

Commit

Permalink
[@mantine/styles] Improve MantineThemeOverride type (#1885)
Browse files Browse the repository at this point in the history
- create a named type for `Record<string, ThemeComponent>`
- remove unnecessary code (`fn` was being `Omit`ted twice)
- refactor to use `Partial<Pick<>`
  • Loading branch information
brunocrosier committed Aug 16, 2022
1 parent 486bd30 commit 1ba9fe3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/mantine-styles/src/theme/types/MantineTheme.ts
Expand Up @@ -9,6 +9,7 @@ import type { CSSObject } from '../../tss';

export type LoaderType = 'bars' | 'oval' | 'dots';
export type MantineThemeOther = Record<string, any>;
export type MantineThemeComponents = Record<string, ThemeComponent>;

export interface HeadingStyle {
fontSize: CSSProperties['fontSize'];
Expand Down Expand Up @@ -92,7 +93,7 @@ export interface MantineTheme {
other: MantineThemeOther;
activeStyles: CSSObject;
datesLocale: string;
components: Record<string, ThemeComponent>;
components: MantineThemeComponents;
}

interface ThemeComponent {
Expand All @@ -104,9 +105,6 @@ interface ThemeComponent {
}

export type MantineThemeBase = Omit<MantineTheme, 'fn'>;
export type MantineThemeOverride = DeepPartial<
Omit<MantineThemeBase, 'fn' | 'other' | 'components'>
> & {
other?: MantineThemeOther;
components?: Record<string, ThemeComponent>;
};

export type MantineThemeOverride = DeepPartial<Omit<MantineThemeBase, 'other' | 'components'>> &
Partial<Pick<MantineThemeBase, 'other' | 'components'>>;

0 comments on commit 1ba9fe3

Please sign in to comment.