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

Commit 22efc1d

Browse files
authored
Merge pull request #38 from skellock/glamor
Winner by TKO.... glamor!
2 parents a958edb + 4f1a8c0 commit 22efc1d

File tree

36 files changed

+351
-257
lines changed

36 files changed

+351
-257
lines changed

docs/stack.md

+42-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,50 @@ Some automation so I stop checking in crap-looking code.
2727
2828
Can't imagine doing web differently to be honest. I'm sure we will soon, but for mid-2017, this is dominating.
2929

30-
> **vanilla react**
30+
I like `preact` as well. I feel like the switching over will be pretty simple and I probably will.
3131

32-
There are lot of great libraries out there for UI. This intentionally uses none of them. Don't hestitate to bring one in and use it if that's how you roll.
3332

34-
I'm keep it straight-up react here because some types of apps I'd will be using webgl, pixi, or are pure svg interfaces.
33+
## Component Styling ##
34+
35+
> **glamor**
36+
37+
The winner is:
38+
39+
* ~vanilla css~
40+
* ~sass~
41+
* ~css modules~
42+
* ~diy~
43+
* ~radium~
44+
* ~aphrodite~
45+
* ~styletron~
46+
* ~styled-components~
47+
* ~typestyle~
48+
* ~emotion~
49+
* ~glam~
50+
* ~glamorous~
51+
* `glamor`!
52+
53+
I've flip-flopped on this quite a bit. We're spoiled by awesome options.
54+
55+
`glamor` nails what I'm looking for:
56+
57+
* ✅ objects are first class
58+
* ✅ strong on composibility
59+
* ✅ performant out of the box (without configuration)
60+
* ✅ works well with global styles and things like keyframes
61+
* ✅ friendly devs
62+
* ✅ a DSL that is true to CSS (especially with child selectors)
63+
* ✅ built-in escape hatches
64+
* ✅ clear docs with examples, patterns, and advice
65+
* ✅ stable-ish API
66+
* ✅ TypeScript-friendly
67+
* ✅ testability without flushing caches or buffers
68+
69+
My advice? **Don't listen to my advice**. Explore & pick your own. Much, if not most, of your app is UI.
70+
71+
Start your app only when your gut says, "You'll fuck this up long before your styling lib gives out."
72+
73+
`glamor` gives me that vibe. 💃
3574

3675

3776
## State Management

package-lock.json

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

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"electron-log": "2.2.7",
4242
"electron-store": "1.2.0",
4343
"electron-updater": "2.8.2",
44+
"glamor": "2.20.39",
4445
"mobx": "3.2.2",
4546
"mobx-react": "4.2.2",
4647
"mobx-state-tree": "0.9.5",

src/renderer/features/app/app.css

-8
This file was deleted.

src/renderer/features/app/app.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import * as React from 'react'
2-
import { CSSProperties } from 'react'
32
import { WelcomeScreen } from '..'
4-
import './reset.css'
5-
import './app.css'
3+
import { styles, cssProps, colors } from '../../platform'
4+
import { css, compose } from 'glamor'
65

7-
// this is in place to claim 100% of the viewport and not scroll.
8-
const rootStyle: CSSProperties = { overflow: 'hidden', height: '100vh', display: 'flex' }
6+
const ROOT = compose(
7+
styles.fullScreen,
8+
cssProps({
9+
backgroundColor: colors.background,
10+
}),
11+
)
912

1013
export class App extends React.Component<{}, {}> {
1114
render() {
1215
return (
13-
<div style={rootStyle}>
16+
<div {...css(ROOT)}>
1417
<WelcomeScreen />
1518
</div>
1619
)

src/renderer/features/app/reset.css

-76
This file was deleted.

src/renderer/features/example-using-tabs/dog-tab/dog-tab.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import * as React from 'react'
2-
import { CSSProperties } from 'react'
3-
import { Text, CenteredContent, spacing } from '../../../platform'
4-
import { FunDog } from '../fun-dog/fun-dog'
5-
import { Logo } from '../logo/logo'
2+
import { Text, CenteredContent, spacing, cssProps } from '../../../platform'
3+
import { FunDog } from '../fun-dog'
4+
import { Logo } from '../logo'
65

7-
const TEXT_STYLE: CSSProperties = {
6+
const TEXT_STYLE = cssProps({
87
paddingTop: spacing.medium,
98
paddingBottom: spacing.medium,
10-
}
9+
})
1110

12-
export class DogTab extends React.Component<{}, {}> {
11+
export class DogTab extends React.PureComponent<{}, {}> {
1312
render() {
1413
return (
1514
<CenteredContent>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dog-tab'
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import * as React from 'react'
22
import dogImage from './fun-dog.jpg'
3+
import { cssProps } from '../../../platform'
4+
import { css } from 'glamor'
35

4-
const style = { width: 300, borderStyle: 'solid', borderWidth: 1 }
6+
const ROOT = cssProps({
7+
width: 300,
8+
borderStyle: 'solid',
9+
borderWidth: 1,
10+
})
511

612
export function FunDog() {
7-
return <img draggable={false} src={dogImage} style={style} />
13+
return <img draggable={false} src={dogImage} {...css(ROOT)} />
814
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './fun-dog'

src/renderer/features/example-using-tabs/header/header.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import * as React from 'react'
2-
import { CSSProperties } from 'react'
3-
import { Text, spacing, colors, fontSizes } from '../../../platform'
2+
import { Text, spacing, colors, fontSizes, styles, cssProps } from '../../../platform'
43
import { isMac } from '../../../../shared'
54
import { remote } from 'electron'
5+
import { compose } from 'glamor'
66

7-
const ROOT_STYLE: CSSProperties = {
8-
WebkitAppRegion: 'drag',
9-
textAlign: 'center',
10-
paddingTop: spacing.verySmall,
11-
backgroundColor: colors.headerBg,
12-
fontSize: fontSizes.small,
13-
}
7+
const ROOT = compose(
8+
styles.windowDrag,
9+
cssProps({
10+
textAlign: 'center',
11+
paddingTop: spacing.verySmall,
12+
backgroundColor: colors.headerBg,
13+
fontSize: fontSizes.small,
14+
}),
15+
)
1416

1517
const title = remote.require('../package.json').name
1618

1719
export function Header() {
1820
if (isMac()) {
1921
return (
20-
<Text style={ROOT_STYLE}>
22+
<Text style={ROOT}>
2123
{title}
2224
</Text>
2325
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './header'
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './welcome-screen/welcome-screen'
1+
export * from './welcome-screen'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './logo'
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import * as React from 'react'
2-
import { CSSProperties } from 'react'
2+
import { cssProps, animations } from '../../../platform'
33
import icon from './electron-icon.svg'
4+
import { css } from 'glamor'
45

5-
const style: CSSProperties = { width: 80, height: 80, animation: 'spin360 infinite 5s linear' }
6+
const ROOT = cssProps({
7+
width: 80,
8+
height: 80,
9+
animation: `${animations.spin360} infinite 5s linear`,
10+
})
611

712
export function Logo() {
8-
return <img draggable={false} src={icon} style={style} />
13+
return <img draggable={false} src={icon} {...css(ROOT)} />
914
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './long-tab'

0 commit comments

Comments
 (0)