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

Commit 2ed3f09

Browse files
authored
Merge pull request #118 from skellock/more-refactoring
♻️ Moves main-window and menu up to src
2 parents 4b0c578 + e3492e4 commit 2ed3f09

32 files changed

+70
-71
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ This is a `TypeScript` and `React` starter kit for building Electron apps.
1010

1111
[Check out the docs](https://skellock.github.io/typescript-with-electron-react-kit) for some of the choices and motivations.
1212

13-
1413
### Example
1514

16-
You have to bring your own awesome. But here's a picture* after `npm i` and `npm start` and `npm storybook`...
15+
You have to bring your own awesome. But here's a picture\* after `npm i` and `npm start` and `npm storybook`...
1716

1817
<img src='./docs/demo.gif' width='450' />
1918

20-
><small>* What it looks like moments before you hit the delete button to nuke all the staged features..</small>
21-
19+
> <small>\* What it looks like moments before you hit the delete button to nuke all the staged features..</small>
2220
2321
# Out of the Box
2422

@@ -33,7 +31,7 @@ You have to bring your own awesome. But here's a picture* after `npm i` and `np
3331
* persist application data as JSON
3432
* sane styling defaults on windows, mac, and linux
3533

36-
### Devs Like Nice Things Too 🔨
34+
### Devs Like Nice Things Too 🔨
3735

3836
* super-fast hot reloading 🔥
3937
* lean production bundles
@@ -42,24 +40,22 @@ You have to bring your own awesome. But here's a picture* after `npm i` and `np
4240
* storybook snapshot testing
4341
* code linting & formatting
4442

45-
### Documentation & Samples 🖨
43+
### Documentation & Samples 🖨
4644

4745
* how to quickly jettison parts you don't want
4846
* why we chose the stack we did
4947
* how to structure your electron app
5048
* a simple & co-located approach to building your components
5149

52-
### Not Included 💣
50+
### Not Included 💣
5351

5452
* lock in... keep what works for you, ditch the rest
55-
* state management... `mobx`? / `redux`? ... both awesome. both excluded.
53+
* state management... `mobx`? / `redux`? ... both awesome. both excluded.
5654
* a component toolkit
5755

56+
# License 🎤
5857

59-
# License 🎤
60-
61-
You down with MIT?
62-
58+
You down with MIT?
6359

6460
# Contributors
6561

docs/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
This is a `TypeScript` and `React` starter kit for building Electron apps.
1010

11-
1211
### Why?
1312

1413
I've got dozens of Electron apps started and not finished. They die before they can leave the bikeshed.
1514

1615
This is my attempt to fix that.
1716

18-
1917
### Why Not?
2018

2119
Most other starter kits use things like WebPack, Babel, Flow, and Redux.
@@ -31,10 +29,8 @@ Honestly, these are pretty pro.
3129
* https://github.com/bitjson/typescript-starter
3230
* https://github.com/alexjoverm/typescript-library-starter
3331

34-
They have been influential and instructional. Pretty cool people at the helm too.
35-
32+
They have been influential and instructional. Pretty cool people at the helm too.
3633

3734
### License
3835

3936
MIT. A tip of the hat is always nice, but I'm more interested in hearing what you do with it.
40-

docs/_sidebar.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
- [Home](/)
2-
- [Using](/using)
3-
- [The Stack](/stack)
4-
1+
* [Home](/)
2+
* [Using](/using)
3+
* [The Stack](/stack)

docs/stack.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
Hey, so everyone has their favourites right? Here's a few of mine.
44

5-
65
## Language
76

87
> **typescript**
@@ -11,7 +10,6 @@ Hey, so everyone has their favourites right? Here's a few of mine.
1110

1211
Such a well polished and wonderful typing system. I know this is a stepping stone to a better language, but JavaScript is really comfortable at this point. TypeScript dials the safety part in.
1312

14-
1513
## Language Support
1614

1715
> **tslint**
@@ -28,7 +26,6 @@ A linter with a great set of rules is awesome.
2826

2927
Some automation so I stop checking in crap-looking code.
3028

31-
3229
## Rendering
3330

3431
> **react**, **react-dom**
@@ -37,9 +34,9 @@ Some automation so I stop checking in crap-looking code.
3734

3835
Can't imagine doing web differently to be honest. I'm sure we will soon, but for mid-2017, this is dominating.
3936

40-
I like `preact` as well. I feel like the switching over will be pretty simple and I probably will.
37+
I like `preact` as well. I feel like the switching over will be pretty simple and I probably will.
4138

42-
## Components ##
39+
## Components
4340

4441
> **glamor**
4542
@@ -65,17 +62,17 @@ I've flip-flopped on this quite a bit. We're spoiled by awesome options.
6562

6663
`glamor` nails what I'm looking for:
6764

68-
* objects are first class
69-
* strong on composibility
70-
* performant out of the box (without configuration)
71-
* works well with global styles and things like keyframes
72-
* friendly devs
73-
* a DSL that is true to CSS (especially with child selectors)
74-
* built-in escape hatches
75-
* clear docs with examples, patterns, and advice
76-
* stable-ish API
77-
* TypeScript-friendly
78-
* testability without flushing caches or buffers
65+
* ✅ objects are first class
66+
* ✅ strong on composibility
67+
* ✅ performant out of the box (without configuration)
68+
* ✅ works well with global styles and things like keyframes
69+
* ✅ friendly devs
70+
* ✅ a DSL that is true to CSS (especially with child selectors)
71+
* ✅ built-in escape hatches
72+
* ✅ clear docs with examples, patterns, and advice
73+
* ✅ stable-ish API
74+
* ✅ TypeScript-friendly
75+
* ✅ testability without flushing caches or buffers
7976

8077
My advice? **Don't listen to my advice**. Explore & pick your own. Much, if not most, of your app is UI.
8178

@@ -105,7 +102,6 @@ Brings enter + leave lifecycle events for animations.
105102

106103
Power animation & tweening library.
107104

108-
109105
## Keyboard Support
110106

111107
> **mousetrap**
@@ -116,7 +112,6 @@ The main menu in electron has keyboard accelators, but we still need one in the
116112

117113
Mousetrap fills that gap. It's a pretty decent little library despite not being maintained any more (lol@js). Does the job though. I've tried a couple of others but keep coming back to this one.
118114

119-
120115
## Utilities
121116

122117
> **ramda**
@@ -125,7 +120,6 @@ Mousetrap fills that gap. It's a pretty decent little library despite not being
125120

126121
There's so much awesome packed in here. `pipe` for days. I'll be honest, it took me a long time get comfortable with `ramda`. Nowadays, you can pry it from my cold dead hands. PRECIOUS!!!
127122

128-
129123
## Electron Things
130124

131125
> **electron-builder**
@@ -157,7 +151,6 @@ Persist JSON to the file system.
157151

158152
Persist window coordinates & dimensions to disk to survive restarts.
159153

160-
161154
## Bundler
162155

163156
> **fuse-box**
@@ -168,15 +161,13 @@ Yes, you read that right. Not WebPack. WebPack always rubbed me wrong. Maybe it'
168161

169162
What I do know is, once I started playing with FuseBox, I was sold. I like the devs behind this too.
170163

171-
172164
## Testing
173165

174166
> **jest**
175167
176168
[jest - github](https://github.com/facebook/jest)
177169

178-
Because we're using TypeScript, Jest makes this much easier. Jest comes with mocking and coverage as well.
179-
170+
Because we're using TypeScript, Jest makes this much easier. Jest comes with mocking and coverage as well.
180171

181172
## Compile Time Utilities
182173

@@ -187,7 +178,6 @@ Because we're using TypeScript, Jest makes this much easier. Jest comes with mo
187178

188179
Quality-of-life utilities for npm.
189180

190-
191181
## Docs
192182

193183
> **docsify**

docs/using.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Test Drive
22

3-
Want to try this out? Clone & run. There's a small sample project included.
3+
Want to try this out? Clone & run. There's a small sample project included.
44

55
```sh
66
git clone --depth 1 git@github.com:skellock/typescript-with-electron-react-kit.git
@@ -9,37 +9,58 @@ npm i
99
npm start
1010
```
1111

12-
_Requires `node@>=8.2` and `npm@>=5.3`._ (NOTE: not really, but ya, upgrade ... there's some pretty big bugs in earlier versions)
12+
_Requires `node@>=8.6` and `npm@>=5.4`._ (NOTE: not really, but ya, upgrade ... there's some pretty big bugs in earlier versions)
1313

1414
## Start Your Own Project
1515

1616
Ready to start your project?
1717

18-
I'm still deciding on a simple way, but there will be a script you can run.
18+
This sample app has a few things that should be swapped out for your settings.
1919

20-
```sh
21-
# this does exist yet
22-
npm run time-to-shine
23-
```
20+
#### Reset git
2421

22+
You'll want to start from a fresh source control history.
2523

26-
## Strip It Down to the Bones
24+
* delete the `.git` directory
25+
* re-initialize git by running `git init`
26+
27+
#### Change App Settings
28+
29+
Open `package.json` and change these keys to be your own:
30+
31+
* name
32+
* productName
33+
* description
34+
* license
35+
* author
36+
* repository
37+
* build.mac.category
38+
* build.publish
2739

28-
You can keep the Electron parts but lose the rendering opinions.
40+
#### Change Web Site Menu Item
2941

30-
* delete the directories under `src/renderer`
31-
* change `src/renderer/index.tsx` to point to your new component
42+
Open `src/menu/shared-menu.ts` and change the visit menu item to point to your web site.
3243

44+
## Strip It Down to the Bones
45+
46+
If you're looking for a really fresh start:
47+
48+
* delete the `src/views` directory
49+
* delete the `src/models` directory
50+
* delete the `src/services` directory
51+
* delete the `src/i18n` directory
52+
* delete the `src/app/root-component.tsx` file
53+
* change `src/app/index.tsx` to point to your new root component
3354

3455
## Keep the Meat, Ditch the Fluff
3556

3657
If you want to just remove the examples and continue with the app layout:
3758

38-
* delete `src/renderer/features/example-using-tabs`
39-
* remove corresponding lines from `src/renderer/index.ts`
40-
* remove the same from `src/renderer/app/app.tsx`
41-
* remove the `src/shared/models`
42-
* remove the `src/main/database`
59+
* delete the `src/views/example` directory
60+
* delete the contents of `src/models`
61+
* delete the contents of `src/services`
62+
* create a new react component under `src/views` (i prefer a sub-directory under here)
63+
* open `src/app/root-component.tsx` and point to your new component
4364

4465
Now you're ready to start adding your own features.
4566

@@ -61,7 +82,7 @@ It'll:
6182
* compile the app in production mode
6283
* clean 1 last time.
6384

64-
This is hooked up to a `pre-push` build script. This will help you not check in mistakes. Trust me.
85+
This is hooked up to a `pre-push` build script. This will help you not check in mistakes. Trust me.
6586

6687
If you want to run in `watch` mode for testing while you develop (quite nice!):
6788

@@ -73,7 +94,7 @@ npm run watch:compile
7394
npm run watch:tests
7495
```
7596

76-
Now when you edit your files, it'll recompile & re-run the relevant tests on the fly. And it's quick!
97+
Now when you edit your files, it'll recompile & re-run the relevant tests on the fly. And it's quick!
7798

7899
If you are ready to see how much of your codebase is covered simply run:
79100

@@ -83,7 +104,6 @@ npm run coverage
83104

84105
and check out the output in the coverage folder.
85106

86-
87107
## Writing Components
88108

89109
When you are adding new components to your app you typically will want to write stories in `storybook`. You do this by simply creating a `<component name>.story.tsx` file along side your component and then writing stories that outline the different prop usage and put it in all the states that it could be in. While you are working on the component you will want to run
@@ -94,8 +114,6 @@ npm run storybook
94114

95115
and then switch to the storybook view from the `view` menu in your app so you can get a live preview of the component you are working on.
96116

97-
98-
99117
## Building
100118

101119
To build your apps, first bundle it:

src/app/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// It is responsible for launching a renderer window.
55

66
import { app, dialog, ipcMain } from "electron"
7-
import { createMainWindow, loadURL } from "../views/main-window"
7+
import { createMainWindow, loadURL } from "../main-window"
88
import * as log from "electron-log"
99
import * as isDev from "electron-is-dev"
1010
import { createUpdater } from "../lib/updater"
11-
import { createMenu } from "../views/menu"
11+
import { createMenu } from "../menu"
1212

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

src/app/root-component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as React from "react"
33
import { compose } from "glamor"
44
import { styles, colors } from "../views/theme"
5-
import { WelcomeScreen } from "../views/example-using-tabs/welcome-screen"
5+
import { WelcomeScreen } from "../views/example/welcome-screen"
66

77
const ROOT = compose(styles.fullScreen, {
88
background: colors.window.background,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/views/menu/menu.ts renamed to src/menu/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Menu } from "electron"
22
import { createMacMenu } from "./macos-menu"
33
import { createLinuxMenu } from "./linux-menu"
44
import { createWindowsMenu } from "./windows-menu"
5-
import { isMac, isLinux, isWindows } from "../../lib/platform"
5+
import { isMac, isLinux, isWindows } from "../lib/platform"
66

77
/**
88
* Attaches the menu to the appropriate place.

src/views/menu/shared-menu.ts renamed to src/menu/shared-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { shell, ipcMain } from "electron"
22

33
export function createSharedMenuItems(window: Electron.BrowserWindow) {
44
const visit: Electron.MenuItemConstructorOptions = {
5-
label: "Visit on Github",
5+
label: "On The Web",
66
click() {
77
shell.openExternal("https://github.com/skellock/typescript-with-electron-react-kit")
88
},
File renamed without changes.

0 commit comments

Comments
 (0)