forked from dabbott/javascript-playgrounds
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.js
47 lines (39 loc) · 1.14 KB
/
player.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
require('./styles/reset.css')
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Player from './components/player/Player'
import { getHashString } from './utils/HashString'
import { prefix, prefixAndApply } from './utils/PrefixInlineStyles'
import VendorComponents from './components/player/VendorComponents'
const style = prefix({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
overflow: 'hidden',
})
const {
id = '0',
width = '210',
platform = 'ios',
scale = '1',
assetRoot = '',
vendorComponents = '[]'
} = getHashString()
const root = (
<div style={style}>
<Player
id={id}
width={parseFloat(width)}
scale={parseFloat(scale)}
platform={platform}
assetRoot={assetRoot}
/>
</div>
)
const mount = document.getElementById('react-root')
// Set mount node to flex in a vendor-prefixed way
prefixAndApply({ display: 'flex' }, mount)
// if we have vendor components, we need to pre-load those
// otherwise, we can just render normally
const components = JSON.parse(vendorComponents)
VendorComponents.load(components, () => ReactDOM.render(root, mount))