Skip to content

Commit

Permalink
moved to camel case, fix teml strings
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Dec 13, 2016
1 parent 7777970 commit 08dfa82
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"electron-config": "^0.2.1",
"electron-context-menu": "^0.7.0",
"electron-debug": "^1.0.1",
"es6-template-strings": "^2.0.1",
"folder-walker": "^3.0.0",
"format-duration": "^1.0.0",
"insert-css": "^1.1.0",
Expand Down
6 changes: 5 additions & 1 deletion renderer/views/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const html = require('choo/html')
const compile = require('es6-template-strings/compile')
const resolve = require('es6-template-strings/resolve')

This comment has been minimized.

Copy link
@ungoldman

ungoldman Dec 13, 2016

Member

@bcomnes why more deps? what does this achieve sir?

This comment has been minimized.

Copy link
@bcomnes

bcomnes Dec 13, 2016

Author Contributor

Basically, it enables template strings in externally parsed files. You can read in some arbitrary string that contains ${whatever} from disk or whatever, and then render it like a template or tagged template string. It's kind of pointless to do that here since the file has no ${blocks}so maybe this was kinda dumb/pointless. But in general I like the idea of being able to do CSSinJS with external css template files, and this pattern makes that work.

This comment has been minimized.

Copy link
@ungoldman

ungoldman Dec 13, 2016

Member

hmm alright... but I feel like if we're using external css files, we might as well just use css variables and not add another layer of complexity/abstraction.

This comment has been minimized.

Copy link
@bcomnes

bcomnes Dec 13, 2016

Author Contributor

Ok I admit it, I was drinking.

const icon = require('../icon')

const css = require('csjs')
const fs = require('fs')
const path = require('path')
const insert = require('insert-css')
const rawCSS = fs.readFileSync(path.join(__dirname, 'index.css'), 'utf8')
const buttonCSS = css`${rawCSS}`
const compiled = compile(rawCSS)
const buttonCSS = css.apply(null, resolve(compiled, {}))

insert(css.getCss(buttonCSS))

function button (onclick, iconName, disabled) {
Expand Down
4 changes: 2 additions & 2 deletions renderer/views/components/form-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const css = require('csjs')
const insert = require('insert-css')

const style = css`
.form-control {
.formControl {
display: inline-block;
width: 100%;
min-height: 25px;
Expand All @@ -15,7 +15,7 @@ const style = css`
outline: none;
}
.form-control:focus {
.formControl:focus {
border-color: var(--focus-input-color);
box-shadow: 0 0 0 1px var(--focus-input-color);
}
Expand Down
4 changes: 2 additions & 2 deletions renderer/views/components/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const insert = require('insert-css')
const fcStyle = require('./form-control').style

const style = css`
.search-input {
.searchInput {
width: auto;
padding: 1px 5px;
vertical-align: middle;
Expand All @@ -18,7 +18,7 @@ function search (oninput) {
return html`
<input
type="text"
class="${style['search-input']} ${fcStyle['form-control']}"
class="${style.searchInput} ${fcStyle.formControl}"
placeholder="Search"
oninput=${oninput}>
`
Expand Down
6 changes: 3 additions & 3 deletions renderer/views/components/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ const fd = require('format-duration')
const css = require('csjs')
const insert = require('insert-css')
const style = css`
.media-list {
.mediaList {
table-layout: fixed;
}
.media-list .time {
.mediaList .time {
text-align: right;
}
`

insert(css.getCss(style))

module.exports = (state, prev, send) => html`
<table class="${style['media-list']} table-striped">
<table class="${style.mediaList} table-striped">
<thead>
<tr>
<th>Title</th>
Expand Down
4 changes: 2 additions & 2 deletions renderer/views/components/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const insert = require('insert-css')
const assign = Object.assign

const style = css`
.volume-control {
.volumeControl {
position: relative;
display: inline-block;
vertical-align: middle;
Expand All @@ -27,7 +27,7 @@ function volume (value, oninput, opts) {
const { min, max, step, style } = opts
return html`
<input type="range"
class="${style['volume-control']}"
class="${style.volumeControl}"
min="${min}" max="${max}" step="${step}"
oninput=${oninput}
value="${value}">
Expand Down
2 changes: 1 addition & 1 deletion renderer/views/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function preferences (state, prev, send) {
<div class="form-group">
<label>Library Folder Path</label>
<input type="text"
class="${fcStyle['form-control']}"
class="${fcStyle.formControl}"
onclick=${showDialog}
value="${state.config.music}">
</div>
Expand Down

0 comments on commit 08dfa82

Please sign in to comment.