import React from 'react'
import { 
  ThemeProvider as ThemeProviderStyledComponents 
} from 'styled-components'
import { GlobalStyle, THEME } from '../../styles'

type ThemeProviderProps = {
  theme?: typeof THEME
  defaultGlogalStyle?: boolean
}

export const ThemeProvider: React.FC<ThemeProviderProps> = ({
  children,
  theme = THEME,
  defaultGlogalStyle,
}) => {
  return (
    <ThemeProviderStyledComponents theme={theme}>
      { defaultGlogalStyle && <GlobalStyle /> }
      { children }
    </ThemeProviderStyledComponents>
  )
}