import { useContext } from 'react'

import { ThemeContext } from './../../components/ThemeProvider/ThemeProvider'
import defaultTheme from './../theme/defaultTheme'

type Keys = keyof typeof defaultTheme

export default function styleHandler(target: Keys) {
  let {
    theme: { [target]: __styles },
  }: any = useContext(ThemeContext)

  // console.log(__styles)

  // __styles.replace(/\s+/g, ' ')

  // console.log('before string', __styles)

  // __styles = JSON.stringify(JSON.parse(__styles))
  __styles = JSON.stringify(__styles).replace(/\\n/g, '').replace(/\s\s+/g, ' ')

  // console.log('string', __styles)

  __styles = JSON.parse(__styles)

  // console.log('string', __styles)

  return __styles
}
