Skip to content

Commit 817690d

Browse files
committed
Adds new starter example
1 parent 0b214b3 commit 817690d

File tree

8 files changed

+158
-60
lines changed

8 files changed

+158
-60
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
["@babel/preset-env", { "targets": { "node": "current" } }],
3+
["@babel/preset-env", { "targets": { "node": "12" } }],
44
"@babel/preset-typescript",
55
"@babel/preset-react"
66
],

package-lock.json

+49-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"dependencies": {
1414
"@nodegui/nodegui": "^0.3.1",
1515
"@nodegui/react-nodegui": "^0.1.9",
16+
"chrome-launcher": "^0.12.0",
17+
"open": "^7.0.0",
1618
"react": "^16.9.0"
1719
},
1820
"devDependencies": {

src/app.tsx

+27-50
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,42 @@
1-
import {
2-
View,
3-
Text,
4-
Window,
5-
Image,
6-
ScrollArea,
7-
hot
8-
} from "@nodegui/react-nodegui";
9-
import path from "path";
1+
import { Text, Window, hot, View } from "@nodegui/react-nodegui";
102
import React from "react";
11-
import { AspectRatioMode } from "@nodegui/nodegui";
12-
import { MyText } from "./components/mytext";
13-
import imageUrl from "../assets/nodegui.jpg";
3+
import { StepOne } from "./components/stepone";
4+
import { StepTwo } from "./components/steptwo";
145

15-
const distImgUrl = path.resolve(__dirname, imageUrl);
16-
const minSize = { width: 500, height: 400 };
6+
const minSize = { width: 500, height: 500 };
177

188
class App extends React.Component {
199
render() {
2010
return (
21-
<>
22-
<Window minSize={minSize} styleSheet={styleSheet}>
23-
<Text>Yo!!</Text>
24-
</Window>
25-
<Window minSize={minSize} styleSheet={styleSheet}>
26-
<ScrollArea style={`height: '100%';width: '100%';`}>
27-
<View id="container">
28-
<Text style="font-size: 15px; font-weight: bold; margin-bottom: 20px;">
29-
Testing
30-
</Text>
31-
<MyText />
32-
<Image
33-
style={imageStyle}
34-
src={distImgUrl}
35-
aspectRatioMode={AspectRatioMode.KeepAspectRatio}
36-
/>
37-
</View>
38-
</ScrollArea>
39-
</Window>
40-
</>
11+
<Window windowTitle="Hello 👋🏽" minSize={minSize} styleSheet={styleSheet}>
12+
<View style={containerStyle}>
13+
<Text id="welcome-text">Welcome to NodeGui 🐕</Text>
14+
<Text id="step-1">1. Play around</Text>
15+
<StepOne />
16+
<Text id="step-2">2. Debug</Text>
17+
<StepTwo />
18+
</View>
19+
</Window>
4120
);
4221
}
4322
}
4423

45-
const imageStyle = `
46-
height: "700px";
47-
width: "700px";
48-
qproperty-alignment: 'AlignHCenter';
49-
`;
24+
const containerStyle = `
25+
flex: 1;
26+
`;
5027

5128
const styleSheet = `
52-
#container {
53-
flex: 1;
54-
min-height: 0;
55-
min-width: 0;
56-
width: '900';
57-
height: '900';
58-
flex-direction: column;
59-
align-items: 'center';
60-
justify-content: 'center';
61-
background-color: 'grey';
62-
}
29+
#welcome-text {
30+
font-size: 24px;
31+
padding-top: 20px;
32+
qproperty-alignment: 'AlignHCenter';
33+
}
34+
35+
#step-1, #step-2 {
36+
font-size: 18px;
37+
padding-top: 10px;
38+
padding-horizontal: 20px;
39+
}
6340
`;
6441

6542
export default hot(App);

src/components/mytext.tsx

-6
This file was deleted.

src/components/stepone.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Text, View } from "@nodegui/react-nodegui";
2+
import React from "react";
3+
4+
export function StepOne() {
5+
return (
6+
<View style={containerStyle}>
7+
<Text wordWrap={true}>
8+
Edit App.tsx to make changes to this screen. Then come back to see your
9+
changes. Changes should reflect live thanks to Hot Reloading. 🔥
10+
</Text>
11+
<Text>
12+
{`
13+
<p style="color: #6200ee;">
14+
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
15+
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
16+
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
17+
You can even use <i><strong>Rich Html</strong></i> text like this if you want 😎.
18+
</p>
19+
<hr />
20+
`}
21+
</Text>
22+
</View>
23+
);
24+
}
25+
26+
const containerStyle = `
27+
margin-horizontal: 20px;
28+
padding-horizontal: 10px;
29+
`;

src/components/steptwo.tsx

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { Text, View, Button } from "@nodegui/react-nodegui";
2+
import { QPushButtonEvents } from "@nodegui/nodegui";
3+
import React from "react";
4+
import open from "open";
5+
6+
const buttonEventHandler = {
7+
[QPushButtonEvents.clicked]: () => {
8+
open("https://react.nodegui.org").catch(console.log);
9+
}
10+
};
11+
12+
export function StepTwo() {
13+
return (
14+
<View>
15+
<Text style={textStyle} wordWrap={true}>
16+
{`
17+
<ol>
18+
<li>
19+
Open chrome and navigate to <code>chrome://inspect</code>. You should see a target below with your app.
20+
</li>
21+
<br/>
22+
<li>
23+
Next click on "<code>Open dedicated DevTools for Node</code>"
24+
</li>
25+
<br/>
26+
<li>
27+
On the dedicated devtools. Click on <code> Source > Node > "Your node process" </code>
28+
</li>
29+
</ol>
30+
`}
31+
</Text>
32+
<Button
33+
style={btnStyle}
34+
on={buttonEventHandler}
35+
text={`Open React NodeGui docs`}
36+
></Button>
37+
</View>
38+
);
39+
}
40+
41+
const textStyle = `
42+
padding-right: 20px;
43+
`;
44+
45+
const btnStyle = `
46+
margin-horizontal: 20px;
47+
height: 40px;
48+
`;

src/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Renderer } from "@nodegui/react-nodegui";
22
import React from "react";
33
import App from "./app";
44

5+
process.title = "My NodeGui App";
56
Renderer.render(<App />);
67
// This is for hot reloading (this will be stripped off in production by webpack)
78
if (module.hot) {
8-
module.hot.accept(["./app"], () => {
9+
module.hot.accept(["./app"], function() {
910
Renderer.forceUpdate();
1011
});
1112
}

0 commit comments

Comments
 (0)