11// @flow
22import * as React from 'react' ;
3- import styled from 'styled-components' ;
3+ import styled , { ThemeProvider } from 'styled-components' ;
44import { camelizeKeys } from 'humps' ;
55import 'whatwg-fetch' ;
66
77import type { Sandbox , Module } from 'common/types' ;
8+ import getTemplateDefinition from 'common/templates' ;
89import Centered from 'app/components/flex/Centered' ;
910import Title from 'app/components/text/Title' ;
1011import SubTitle from 'app/components/text/SubTitle' ;
@@ -15,7 +16,7 @@ import Sidebar from './components/Sidebar';
1516import { getSandboxOptions } from '../common/url' ;
1617import {
1718 findCurrentModule ,
18- findMainModule ,
19+ findMainModule
1920} from 'app/store/entities/sandboxes/modules/selectors' ;
2021
2122const Container = styled . div `
@@ -56,7 +57,7 @@ type State = {
5657 sidebarOpen : boolean ,
5758 autoResize : boolean ,
5859 hideNavigation : boolean ,
59- fontSize : number ,
60+ fontSize : number
6061} ;
6162
6263export default class App extends React . PureComponent < { } , State > {
@@ -71,7 +72,7 @@ export default class App extends React.PureComponent<{}, State> {
7172 isEditorScreen,
7273 autoResize,
7374 hideNavigation,
74- fontSize,
75+ fontSize
7576 } = getSandboxOptions ( document . location . href ) ;
7677
7778 this . state = {
@@ -85,7 +86,7 @@ export default class App extends React.PureComponent<{}, State> {
8586 initialPath,
8687 sidebarOpen : false ,
8788 autoResize,
88- hideNavigation,
89+ hideNavigation
8990 } ;
9091 }
9192
@@ -103,7 +104,7 @@ export default class App extends React.PureComponent<{}, State> {
103104 fetchSandbox = async ( id : string ) => {
104105 try {
105106 const response = await fetch (
106- `${ this . getAppOrigin ( ) } /api/v1/sandboxes/${ id } ` ,
107+ `${ this . getAppOrigin ( ) } /api/v1/sandboxes/${ id } `
107108 )
108109 . then ( res => res . json ( ) )
109110 . then ( camelizeKeys ) ;
@@ -148,7 +149,7 @@ export default class App extends React.PureComponent<{}, State> {
148149 sandbox . modules ,
149150 sandbox . directories ,
150151 currentModulePath ,
151- findMainModule ( sandbox . modules ) ,
152+ findMainModule ( sandbox . modules )
152153 ) ;
153154 } ;
154155
@@ -175,30 +176,37 @@ export default class App extends React.PureComponent<{}, State> {
175176 const { showEditor, showPreview, isInProjectView } = this . state ;
176177
177178 return (
178- < Container >
179- < Header
180- showEditor = { showEditor }
181- showPreview = { showPreview }
182- setEditorView = { this . setEditorView }
183- setPreviewView = { this . setPreviewView }
184- setMixedView = { this . setMixedView }
185- sandbox = { this . state . sandbox }
186- toggleSidebar = { this . toggleSidebar }
187- />
188- < Content
189- showEditor = { showEditor }
190- showPreview = { showPreview }
191- isInProjectView = { isInProjectView }
192- setProjectView = { this . setProjectView }
193- sandbox = { this . state . sandbox }
194- currentModule = { this . getCurrentModuleFromPath ( ) . id }
195- hideNavigation = { this . state . hideNavigation }
196- autoResize = { this . state . autoResize }
197- fontSize = { this . state . fontSize }
198- initialPath = { this . state . initialPath }
199- setCurrentModule = { this . setCurrentModule }
200- />
201- </ Container >
179+ < ThemeProvider
180+ theme = { {
181+ templateColor : getTemplateDefinition ( this . state . sandbox . template )
182+ . color
183+ } }
184+ >
185+ < Container >
186+ < Header
187+ showEditor = { showEditor }
188+ showPreview = { showPreview }
189+ setEditorView = { this . setEditorView }
190+ setPreviewView = { this . setPreviewView }
191+ setMixedView = { this . setMixedView }
192+ sandbox = { this . state . sandbox }
193+ toggleSidebar = { this . toggleSidebar }
194+ />
195+ < Content
196+ showEditor = { showEditor }
197+ showPreview = { showPreview }
198+ isInProjectView = { isInProjectView }
199+ setProjectView = { this . setProjectView }
200+ sandbox = { this . state . sandbox }
201+ currentModule = { this . getCurrentModuleFromPath ( ) . id }
202+ hideNavigation = { this . state . hideNavigation }
203+ autoResize = { this . state . autoResize }
204+ fontSize = { this . state . fontSize }
205+ initialPath = { this . state . initialPath }
206+ setCurrentModule = { this . setCurrentModule }
207+ />
208+ </ Container >
209+ </ ThemeProvider >
202210 ) ;
203211 } ;
204212
0 commit comments