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

Commit 1d0ae6b

Browse files
authored
Adds image bundling support. (#8)
1 parent b32c418 commit 1d0ae6b

File tree

9 files changed

+41
-9
lines changed

9 files changed

+41
-9
lines changed

fuse.js

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

44
const DEV_PORT = 4445
@@ -20,7 +20,7 @@ Sparky.task('default', ['copy-html'], () => {
2020
output: `${OUTPUT_DIR}/$name.js`,
2121
target: 'electron',
2222
cache: !isProduction,
23-
plugins: [SVGPlugin(), CSSPlugin()],
23+
plugins: [CSSPlugin(), ImageBase64Plugin({ useDefault: true })],
2424
sourceMaps: true
2525
})
2626

globals.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Tell the TS compiler that it's ok to load these
2+
// types of extensions. FuseBox will do the right thing.
3+
4+
declare module '*.jpeg'
5+
declare module '*.jpg'
6+
declare module '*.gif'
7+
declare module '*.png'
8+
declare module '*.svg'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@
7171
"postinstall": "Used by electron-builder to build native dependencies.",
7272
"start": "Starts the app in dev mode."
7373
},
74-
"version": "0.3.0"
74+
"version": "0.4.0"
7575
}

src/renderer/app/app.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
12
import * as React from 'react'
2-
import { Text, Logo } from '../platform'
3+
import { Text, Logo, FunDog } from '../platform'
34

45
const appStyle = {
56
flex: 1,
@@ -18,12 +19,18 @@ const appStyle = {
1819
cursor: 'default'
1920
}
2021

22+
const textStyle = {
23+
paddingTop: 20,
24+
paddingBottom: 20
25+
}
26+
2127
export class App extends React.Component<{}, {}> {
2228
render() {
2329
return (
2430
<div style={appStyle}>
2531
<Logo />
26-
<Text>Wake up and smell the electrons.</Text>
32+
<Text style={textStyle}>Wake up and smell the electrons.</Text>
33+
<FunDog />
2734
</div>
2835
)
2936
}
21.2 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react'
2+
import dogImage from './fun-dog.jpg'
3+
4+
const style = {
5+
width: '200',
6+
borderStyle: 'solid',
7+
borderWidth: 4,
8+
borderColor: 'white'
9+
}
10+
11+
export function FunDog() {
12+
return <img src={dogImage} style={style} alt="Photo by Braydon Anderson on Unsplash" />
13+
}

src/renderer/platform/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
export * from './text/text'
44
export * from './logo/logo'
5+
export * from './fun-dog/fun-dog'

src/renderer/platform/components/logo/logo.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as React from 'react'
2+
// Just until this ships:
3+
// https://github.com/fuse-box/fuse-box/pull/672
4+
//
5+
// then we can drop the '* as'
6+
import * as icon from './electron-icon.svg'
27

3-
const icon = require('./electron-icon.svg')
48
const style = {
59
width: 80,
610
height: 80,
7-
marginTop: -80,
8-
paddingBottom: 20,
911
animation: 'spin360 infinite 5s linear'
1012
}
1113

src/renderer/platform/components/text/text.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import * as React from 'react'
33
export interface TextProps {
44
text?: string
55
children?: React.ReactNode
6+
style?: any
67
}
78

89
export function Text(props: TextProps) {
910
return (
10-
<div>{props.text || props.children}</div>
11+
<div style={props.style}>{props.text || props.children}</div>
1112
)
1213
}

0 commit comments

Comments
 (0)