summaryrefslogtreecommitdiff
path: root/src/demo-component.js
blob: 15fe3ed38a8448316601a541526e01a6601364f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// In production, it's worth configuring things
// to handle the `css` prop at build time
/** @jsx jsx */
import { jsx } from '@emotion/core'
import { SunlightTheme } from './sunlight-theme'
import { css } from '@emotion/core'
import colormap from 'colormap'

const containerStyle = ({ colours }) => css`
  color: ${colours.main};
`

const mainRange = colormap({
  colormap: 'autumn',
  nshades: 11,
  format: 'hex',
  alpha: 1
})

const colourMiddleware = theme => {
  return {
    ...theme,
    colours: {
      main: mainRange[theme.lightLevel]
    }
  }
}

export const DemoComponent = ({ children }) => {
  return (
    <SunlightTheme middleware={[colourMiddleware]}>
      <div css={containerStyle}>{children}</div>
    </SunlightTheme>
  )
}