forked from dabbott/javascript-playgrounds
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (43 loc) · 1.15 KB
/
index.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require('./styles/reset.css')
require('./styles/index.css')
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Workspace from './components/workspace/Workspace'
import { getHashString, setHashString } from './utils/HashString'
import DefaultCode from './constants/DefaultCode'
import { prefix, prefixAndApply } from './utils/PrefixInlineStyles'
const style = prefix({
flex: '1 1 auto',
display: 'flex',
alignItems: 'stretch',
minWidth: 0,
minHeight: 0,
overflow: 'hidden',
})
const {
title = '',
code = DefaultCode,
platform = 'ios',
width = '210',
scale = '1',
assetRoot = '',
vendorComponents = '[]'
} = getHashString()
const root = (
<div style={style}>
<Workspace
title={title}
value={code}
platform={platform}
assetRoot={assetRoot}
scale={parseFloat(scale)}
width={parseFloat(width)}
vendorComponents={JSON.parse(vendorComponents)}
onChange={setHashString}
/>
</div>
)
const mount = document.getElementById('react-root')
// Set mount node to flex in a vendor-prefixed way
prefixAndApply({ display: 'flex' }, mount)
ReactDOM.render(root, mount)