From 65220cc8db0d7c63f49627526466d54969958fe1 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Fri, 29 Mar 2019 00:35:56 -0700 Subject: Init commit --- src/demo-component.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/demo-component.js (limited to 'src/demo-component.js') diff --git a/src/demo-component.js b/src/demo-component.js new file mode 100644 index 0000000..ee83d83 --- /dev/null +++ b/src/demo-component.js @@ -0,0 +1,38 @@ +import React from 'react' +import { useSunlight } from './use-sunlight' +import colormap from 'colormap' + +const mainRange = colormap({ + colormap: 'autumn', + nshades: 10, + format: 'hex', + alpha: 1 +}) + +const backgroundRange = colormap({ + colormap: 'winter', + nshades: 10, + format: 'hex', + alpha: 1 +}) + +const sunlightToTheme = sunlightLevel => ({ + main: mainRange[sunlightLevel], + background: backgroundRange[sunlightLevel] +}) + +const sunlightToStyle = theme => ({ + background: theme.background, + color: theme.main, + minHeight: '500px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center' +}) + +export const DemoComponent = ({ children }) => { + const [sunlight] = useSunlight() + const theme = sunlightToTheme(sunlight) + const style = sunlightToStyle(theme) + return
{children}
+} -- cgit v1.2.3