Skip to content

Commit 30a7a47

Browse files
authored
Merge pull request #92 from back4app/add-cloud-code-page
Add cloud code page
2 parents bddd242 + efd75e2 commit 30a7a47

35 files changed

+1207
-6
lines changed

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,18 @@
4646
"html-webpack-plugin": "^3.2.0",
4747
"jquery": "^3.2.1",
4848
"json-file-plus": "^3.2.0",
49+
"jstree": "^3.3.5",
4950
"lodash": "^4.17.10",
5051
"material-design-iconic-font": "^2.2.0",
5152
"package-json": "^4.0.1",
5253
"passport": "^0.3.2",
5354
"passport-local": "^1.0.0",
5455
"popper.js": "^1.12.9",
56+
"react-file-reader": "^1.1.4",
57+
"react-syntax-highlighter": "^9.0.0",
5558
"react-tabs": "^2.2.2",
59+
"sweetalert2": "^7.28.10",
60+
"sweetalert2-react-content": "^1.0.1",
5661
"whatwg-fetch": "^2.0.3"
5762
},
5863
"devDependencies": {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
import React from 'react';
9+
import Field from 'components/Field/Field.react';
10+
import B4AAlert from 'components/B4AAlert/B4AAlert.react';
11+
12+
export const component = B4AAlert;
13+
14+
export const demos = [
15+
{
16+
render: () => (
17+
<Field
18+
label={<B4AAlert title='This is my text.' description='This is my description.' />}
19+
input={null} />
20+
)
21+
}, {
22+
render: () => (
23+
<Field
24+
label={<B4AAlert show={false} title='This is my text.' description='This is my description.' />}
25+
input={null} />
26+
)
27+
}, {
28+
render: () => (
29+
<Field
30+
label={<B4AAlert show={true} title='This is my text.' description='This is my description.' />}
31+
input={null} />
32+
)
33+
},
34+
];
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
import { centered } from 'components/Field/Field.scss';
9+
import PropTypes from 'lib/PropTypes';
10+
import React from 'react';
11+
import styles from 'components/B4AAlert/B4AAlert.scss';
12+
13+
export default class B4AAlert extends React.Component {
14+
constructor() {
15+
super()
16+
17+
this.state = {
18+
show: false
19+
}
20+
}
21+
22+
componentWillMount() {
23+
if (typeof this.props.show !== 'undefined')
24+
return this.setState({ show: this.props.show })
25+
this.setState({ show: true })
26+
}
27+
28+
async onClose() {
29+
await this.setState({ show: false })
30+
this.props.handlerCloseEvent && this.props.handlerCloseEvent(this.props.title)
31+
}
32+
33+
render() {
34+
let padding = (this.props.padding || 20) + 'px';
35+
return this.state.show && (
36+
<div
37+
className={styles.label}
38+
style={{ padding }}>
39+
<div
40+
className={styles.title} >
41+
{this.props.title}
42+
<a
43+
className={`zmdi zmdi-close ${styles.close}`}
44+
onClick={this.onClose.bind(this)}>
45+
</a>
46+
</div>
47+
{this.props.description ? <div className={styles.description}>{this.props.description}</div> : null}
48+
</div>
49+
);
50+
}
51+
}
52+
53+
B4AAlert.PropTypes = {
54+
title: PropTypes.node.describe(
55+
'The main title/node of the label.'
56+
),
57+
description: PropTypes.node.describe(
58+
'The secondary title/node of the label.'
59+
),
60+
padding: PropTypes.number.describe(
61+
'Allows you to override the left-right padding of the label.'
62+
),
63+
handlerCloseEvent: PropTypes.func.describe(
64+
'Handler event function to close alert'
65+
)
66+
};

src/components/B4AAlert/B4AAlert.scss

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
@import 'stylesheets/globals.scss';
9+
10+
.label {
11+
font-family: Noto Sans;
12+
font-size: 14px;
13+
line-height: 32px;
14+
margin-bottom: 22px;
15+
border-radius: 4px;
16+
border: solid 1px #bcdff1;
17+
background-color: #d9edf7;
18+
color: #31708f;
19+
20+
.close {
21+
float: right;
22+
width: 14px;
23+
height: 14px;
24+
font-size: 16px;
25+
margin-top: -10px;
26+
margin-right: -10px;
27+
}
28+
29+
p {
30+
height: fit-content;
31+
margin-bottom: 0px;
32+
}
33+
}
34+
35+
.title {
36+
font-weight: bold;
37+
}
38+
39+
40+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
import React from 'react';
9+
import B4ACloudCodeView from 'components/B4ACloudCodeView/B4ACloudCodeView.react';
10+
11+
export const component = B4ACloudCodeView;
12+
13+
export const demos = [
14+
{
15+
render() {
16+
return (
17+
<B4ACloudCodeView source={this.props.source} extension='js' />
18+
)
19+
}
20+
}
21+
];
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import SyntaxHighlighter from 'react-syntax-highlighter';
3+
import style from 'react-syntax-highlighter/styles/hljs/tomorrow-night-eighties';
4+
5+
export default class B4ACloudCodeView extends React.Component {
6+
constructor(props){
7+
super(props);
8+
}
9+
10+
extensionDecoder() {
11+
if (this.props.extension)
12+
switch (this.props.extension) {
13+
case 'js':
14+
return 'javascript'
15+
case 'ejs':
16+
return 'html'
17+
default:
18+
// css, html, ...
19+
return this.props.extension
20+
}
21+
return 'javascript'
22+
}
23+
24+
25+
render() {
26+
if (style.hljs) {
27+
style.hljs.background = "#0c2337"
28+
style.hljs.height = '100%'
29+
style.hljs.padding = '1em 0.5em'
30+
}
31+
return <SyntaxHighlighter
32+
showLineNumbers={true}
33+
lineNumberStyle={{
34+
"padding-right": 10,
35+
"color": "rgb(169, 183, 198, 0.3)"
36+
}}
37+
wrapLines={true}
38+
language={this.extensionDecoder()}
39+
style={style}>
40+
{this.props.source}
41+
</SyntaxHighlighter>;
42+
}
43+
}

src/components/B4ACloudCodeView/B4ACloudCodeView.scss

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
import React from 'react';
9+
import B4ACodeTree from 'components/B4ACodeTree/B4ACodeTree.react';
10+
11+
let source = {"tree":[{"text":"cloud","state":{"opened":true},"type":"folder","children":[{"text":"newFile.js","data":{"code":"data:plain/text;base64,Y29uc29sZS5sb2coIm5ldyBmaWxlIik7Cg=="}}]},{"text":"public","state":{"opened":true},"type":"folder","children":[{"text":"render.html","data":{"code":"data:plain/text;base64,ZXJyb3Igd2l0aCBzdGF0dXM9NTAwIGFuZCBib2R5PSJUeXBlRXJyb3I6IF9lcnJvcnMyLmRlZmF1bHQgaXMgbm90IGEgY29uc3RydWN0b3I8YnI+ICZuYnNwOyAmbmJzcDthdCAvaG9tZS9iYWNrNGFwcC9zY20vYmFjazRhcHAtY2xpLXNlcnZlci9saWIvYmFjay9CYWNrNGFwcFZlbmRvckFkYXB0ZXIuanM6MTE2OjIxPGJyPiAmbmJzcDsgJm5ic3A7YXQgdHJ5Q2F0Y2hlciAoL2hvbWUvYmFjazRhcHAvc2NtL2JhY2s0YXBwLWNsaS1zZXJ2ZXIvbm9kZV9tb2R1bGVzL2JsdWViaXJkL2pzL3JlbGVhc2UvdXRpbC5qczoxNjoyMyk8YnI+ICZuYnNwOyAmbmJzcDthdCBQcm9taXNlLl9zZXR0bGVQcm9taXNlRnJvbUhhbmRsZXIgKC9ob21lL2JhY2s0YXBwL3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L3NjbS9iYWNrNGFwcC1jbGktc2VydmVyL25vZGVfbW9kdWxlcy9ibHVlYmlyZC9qcy9yZWxlYXNlL2FzeW5jLmpzOjE3OjE0KTxicj4gJm5ic3A7ICZuYnNwO2F0IHJ1bkNhbGxiYWNrICh0aW1lcnMuanM6NjM3OjIwKTxicj4gJm5ic3A7ICZuYnNwO2F0IHRyeU9uSW1tZWRpYXRlICh0aW1lcnMuanM6NjEwOjUpPGJyPiAmbmJzcDsgJm5ic3A7YXQgcHJvY2Vzc0ltbWVkaWF0ZSBbYXMgX2ltbWVkaWF0ZUNhbGxiYWNrXSAodGltZXJzLmpzOjU4Mjo1KVxuIgo="}}]}]}
12+
13+
class Demo extends React.Component {
14+
constructor() {
15+
super();
16+
this.state = { value: null };
17+
}
18+
19+
render() {
20+
return <B4ACodeTree files={source.tree} />
21+
}
22+
}
23+
24+
export const component = B4ACodeTree;
25+
26+
export const demos = [
27+
{
28+
name: 'Code Tree',
29+
render: () => ( <Demo /> )
30+
}
31+
];

0 commit comments

Comments
 (0)