Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 1a3d683

Browse files
committed
♻️ Refactors the src structure
1 parent 692ee7c commit 1a3d683

File tree

88 files changed

+115
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+115
-116
lines changed

src/renderer/platform/components/storybook/index.ts renamed to .storybook/views/index.ts

File renamed without changes.

src/renderer/platform/components/storybook/storybook-group.tsx renamed to .storybook/views/storybook-group.tsx

File renamed without changes.

src/renderer/platform/components/storybook/storybook-label.tsx renamed to .storybook/views/storybook-label.tsx

File renamed without changes.

src/renderer/platform/components/storybook/storybook-story.tsx renamed to .storybook/views/storybook-story.tsx

File renamed without changes.

.storybook/webpack.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
const path = require('path')
2-
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js')
1+
const path = require("path")
2+
const genDefaultConfig = require("@storybook/react/dist/server/config/defaults/webpack.config.js")
33

44
module.exports = (config, env) => {
55
const myConfig = genDefaultConfig(config, env)
66

77
myConfig.module.rules.push({
88
test: /\.tsx?$/,
9-
loader: 'ts-loader',
9+
loader: "ts-loader",
1010
exclude: /node_modules/,
11-
include: path.resolve(__dirname, '..', 'src'),
11+
include: [path.resolve(__dirname, "..", "src"), path.resolve(__dirname, "views")],
1212
})
13-
14-
myConfig.resolve.extensions.unshift('.tsx')
15-
myConfig.resolve.extensions.unshift('.ts')
13+
14+
myConfig.resolve.extensions.unshift(".tsx")
15+
myConfig.resolve.extensions.unshift(".ts")
1616

1717
return myConfig
1818
}

fuse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const isProduction = process.env.NODE_ENV === "production"
1010

1111
// copy the renderer's html file into the right place
1212
Sparky.task("copy-html", () => {
13-
return Sparky.src("src/renderer/index.html").dest(`${OUTPUT_DIR}/$name`)
13+
return Sparky.src("src/app/index.html").dest(`${OUTPUT_DIR}/$name`)
1414
})
1515

1616
// the default task
@@ -32,7 +32,7 @@ Sparky.task("default", ["copy-html"], () => {
3232
}
3333

3434
// bundle the electron main code
35-
const mainBundle = fuse.bundle("main").instructions("> [main/main.ts]")
35+
const mainBundle = fuse.bundle("main").instructions("> [app/main.ts]")
3636

3737
// and watch unless we're bundling for production
3838
if (!isProduction) {
@@ -42,7 +42,7 @@ Sparky.task("default", ["copy-html"], () => {
4242
// bundle the electron renderer code
4343
const rendererBundle = fuse
4444
.bundle("renderer")
45-
.instructions("> [renderer/index.tsx] +fuse-box-css")
45+
.instructions("> [app/index.tsx] +fuse-box-css")
4646
.plugin(CSSPlugin())
4747
.plugin(CopyPlugin({ useDefault: false, files: ASSETS, dest: "assets", resolve: "assets/" }))
4848

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript-with-electron-react-kit",
33
"productName": "Sweet Sweet App",
44
"main": "out/main.js",
5-
"version": "1.0.0",
5+
"version": "2.0.0",
66
"description": "An electron starter project.",
77
"license": "MIT",
88
"private": true,

src/app/index.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This is the entry point for the renderer process.
2+
//
3+
// Here we disable a few electron settings and mount the root component.
4+
import * as React from "react"
5+
import * as ReactDOM from "react-dom"
6+
import { RootComponent } from "./root-component"
7+
import { webFrame } from "electron"
8+
import { css } from "glamor"
9+
10+
/**
11+
* CSS reset
12+
*/
13+
import "glamor/reset"
14+
15+
/**
16+
* Electron-focused CSS resets
17+
*/
18+
css.global("html, body", {
19+
// turn off text highlighting
20+
userSelect: "none",
21+
22+
// reset the cursor pointer
23+
cursor: "default",
24+
25+
// font
26+
font: "caption",
27+
28+
// text rendering
29+
WebkitFontSmoothing: "subpixel-antialiased",
30+
textRendering: "optimizeLegibility",
31+
})
32+
33+
/**
34+
* Zooming resets
35+
*/
36+
webFrame.setVisualZoomLevelLimits(1, 1)
37+
webFrame.setLayoutZoomLevelLimits(0, 0)
38+
39+
/**
40+
* Drag and drop resets
41+
*/
42+
document.addEventListener("dragover", event => event.preventDefault())
43+
document.addEventListener("drop", event => event.preventDefault())
44+
45+
// mount the root component
46+
ReactDOM.render(<RootComponent />, document.getElementById("root"))

src/main/main.ts renamed to src/app/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
// This is the main process entry point. It is the
2+
// first file that is run on startup.
3+
//
4+
// It is responsible for launching a renderer window.
5+
16
import { app, dialog, ipcMain } from "electron"
2-
import { createMainWindow } from "./main-window/main-window"
3-
import { loadURL } from "./main-window/load-url"
7+
import { createMainWindow, loadURL } from "../views/main-window"
48
import * as log from "electron-log"
59
import * as isDev from "electron-is-dev"
6-
import { createUpdater } from "./updater/updater"
7-
import { createMenu } from "./menu/menu"
10+
import { createUpdater } from "../lib/updater"
11+
import { createMenu } from "../views/menu"
812

913
// set proper logging level
1014
log.transports.file.level = isDev ? false : "info"

0 commit comments

Comments
 (0)