Commit 5038c09e authored by LexSwed's avatar LexSwed
Browse files

fix: make default theme type available

parent e7a47974
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -72,12 +72,12 @@
    "downshift": "^3.2.10",
    "popper.js": "^1.15.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "styled-components": "5.0.0-beta.6-ej4"
    "react-dom": "^16.8.6"
  },
  "peerDependencies": {
    "react": "16.8",
    "react-dom": "16.8"
    "react": "^16.8",
    "react-dom": "^16.8",
    "styled-components": "^5.*"
  },
  "browserslist": [
    ">1%",
+12 −5
Original line number Diff line number Diff line
import React, { FunctionComponent, Fragment, ComponentProps } from 'react';
import React, { FunctionComponent, Fragment, useState } from 'react';
import { ThemeProvider as StyleProvider } from 'styled-components';
import { theme as defaultTheme, GlobalStyles } from 'utils/theme';
import { theme as defaultTheme, GlobalStyles, ThemeColors, ThemeCore } from 'utils/theme';

export interface DefaultTheme {
  colors: ThemeColors;
  core: ThemeCore;
}

interface Props {
  theme: ComponentProps<typeof StyleProvider>['theme'];
  theme?: DefaultTheme;
}

const ThemeProvider: FunctionComponent<Props> = ({ children, theme = defaultTheme }) => {
const ThemeProvider: FunctionComponent<Props> = ({ children, theme }) => {
  const [mergedTheme] = useState(() => Object.assign(defaultTheme, theme));

  return (
    <StyleProvider theme={theme}>
    <StyleProvider theme={mergedTheme}>
      <Fragment>
        <GlobalStyles />
        {children}
+3 −10
Original line number Diff line number Diff line
import 'styled-components';
import colors from 'utils/theme/colors';
import core from 'utils/theme/core';

export type ThemeColors = typeof colors;

export type ThemeCore = typeof core;
import { DefaultTheme as Theme } from 'components/ThemeProvider';

declare module 'styled-components' {
  export interface DefaultTheme {
    colors: ThemeColors;
    core: ThemeCore;
  }
  // eslint-disable-next-line
  export interface DefaultTheme extends Theme {}
}
+1 −2
Original line number Diff line number Diff line
import { css } from 'styled-components';
import { Padding, Margin, Elevation } from 'types/helpers';
import { cssColors } from './theme';
import { ThemeColors } from 'types/styled';
import { cssColors, ThemeColors } from './theme';

export const spacer = (n: number) => `${n * 8}px`;

+3 −1
Original line number Diff line number Diff line
import { DefaultTheme, createGlobalStyle } from 'styled-components';
import colors from './colors';
import core from './core';
import { ThemeColors, ThemeCore } from 'types/styled';

export type ThemeColors = typeof colors;
export type ThemeCore = typeof core;

const stateReg = /:/g;

Loading