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

Commit b32c418

Browse files
authored
Adds svg support. (#7)
1 parent 4477efc commit b32c418

File tree

7 files changed

+38
-20
lines changed

7 files changed

+38
-20
lines changed

fuse.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { FuseBox, CSSPlugin, Sparky } = require('fuse-box')
1+
const { FuseBox, CSSPlugin, Sparky, SVGPlugin } = require('fuse-box')
22
const { spawn } = require('child_process')
33

44
const DEV_PORT = 4445
@@ -9,9 +9,7 @@ const isProduction = process.env.NODE_ENV === 'production'
99

1010
// copy the renderer's html file into the right place
1111
Sparky.task('copy-html', () => {
12-
return Sparky
13-
.src('src/renderer/{index.html,*.css}')
14-
.dest(`${OUTPUT_DIR}/$name`)
12+
return Sparky.src('src/renderer/{index.html,*.css}').dest(`${OUTPUT_DIR}/$name`)
1513
})
1614

1715
// the default task
@@ -22,6 +20,7 @@ Sparky.task('default', ['copy-html'], () => {
2220
output: `${OUTPUT_DIR}/$name.js`,
2321
target: 'electron',
2422
cache: !isProduction,
23+
plugins: [SVGPlugin(), CSSPlugin()],
2524
sourceMaps: true
2625
})
2726

@@ -31,20 +30,15 @@ Sparky.task('default', ['copy-html'], () => {
3130
}
3231

3332
// bundle the electron main code
34-
const mainBundle = fuse
35-
.bundle('main')
36-
.instructions('> [main/main.ts]')
33+
const mainBundle = fuse.bundle('main').instructions('> [main/main.ts]')
3734

3835
// and watch unless we're bundling for production
3936
if (!isProduction) {
4037
mainBundle.watch()
4138
}
4239

4340
// bundle the electron renderer code
44-
const rendererBundle = fuse
45-
.bundle('renderer')
46-
.plugin(CSSPlugin())
47-
.instructions('> [renderer/index.tsx]')
41+
const rendererBundle = fuse.bundle('renderer').instructions('> [renderer/index.tsx]')
4842

4943
// and watch & hot reload unless we're bundling for production
5044
if (!isProduction) {
@@ -53,12 +47,10 @@ Sparky.task('default', ['copy-html'], () => {
5347
}
5448

5549
// when we are finished bundling...
56-
return fuse
57-
.run()
58-
.then(() => {
59-
if (!isProduction) {
60-
// startup electron
61-
spawn('node', [`${__dirname}/node_modules/electron/cli.js`, __dirname], { stdio: 'inherit' })
62-
}
63-
})
50+
return fuse.run().then(() => {
51+
if (!isProduction) {
52+
// startup electron
53+
spawn('node', [`${__dirname}/node_modules/electron/cli.js`, __dirname], { stdio: 'inherit' })
54+
}
55+
})
6456
})

src/renderer/app/app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { Text } from '../platform'
2+
import { Text, Logo } from '../platform'
33

44
const appStyle = {
55
flex: 1,
@@ -22,6 +22,7 @@ export class App extends React.Component<{}, {}> {
2222
render() {
2323
return (
2424
<div style={appStyle}>
25+
<Logo />
2526
<Text>Wake up and smell the electrons.</Text>
2627
</div>
2728
)

src/renderer/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>Welcome</title>
88
<style>
99
@import url('./reset.css');
10+
@import url('./keyframes.css');
1011
</style>
1112
</head>
1213

src/renderer/keyframes.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@keyframes spin360 {
2+
from {
3+
transform: rotate(0deg);
4+
}
5+
to {
6+
transform: rotate(360deg);
7+
}
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// exports all the components
22

33
export * from './text/text'
4+
export * from './logo/logo'
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as React from 'react'
2+
3+
const icon = require('./electron-icon.svg')
4+
const style = {
5+
width: 80,
6+
height: 80,
7+
marginTop: -80,
8+
paddingBottom: 20,
9+
animation: 'spin360 infinite 5s linear'
10+
}
11+
12+
export function Logo() {
13+
return <img src={icon} style={style} />
14+
}

0 commit comments

Comments
 (0)