Skip to content

Commit

Permalink
new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
zehfernandes committed Jun 28, 2017
0 parents commit 2c9ffa7
Show file tree
Hide file tree
Showing 27 changed files with 5,991 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": ["stage-1", "react"],
"plugins": [
["transform-react-jsx", { "pragma": "h" }],
["transform-decorators-legacy"]
]
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
150 changes: 150 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"mocha": true,
"es6": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"restParams": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true
},
"rules": {
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": [2, {"properties": "always"}],
"comma-dangle": [2, "always-multiline"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "smart"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$"],
"indent": [2, 2, { "SwitchCase": 1 }],
"jsx-quotes": [2, "prefer-double"],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 1,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-duplicate-imports": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-else-return": [2],
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": [2],
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-symbol": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-path-concat": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": [2, "except-parens"],
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-constructor": 2,
"no-useless-escape": 2,
"no-whitespace-before-property": 2,
"no-with": 2,
"one-var": [2, { "initialized": "never" }],
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [2, "never"],
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "never"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": ["error", { "anonymous": "ignore", "named": "never" }],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"template-curly-spacing": [2, "never"],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yield-star-spacing": [2, "both"],
"yoda": [2, "never"],
"keyword-spacing": [2, {
"before": false,
"after": true,
"overrides": {
"from": { "before": true },
"return": { "before": true },
"else": { "before": true },
"catch": { "before": true },
"as": { "before": true }
}
}]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist/
39 changes: 39 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CC0 1.0 Universal
==================

Statement of Purpose
---------------------

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights.
--------------------------------
A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. Waiver.
-----------
To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback.
----------------------------
Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.
--------------------------------

a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Usage

First, install [Yarn] for your system (you can replace `yarn` with `npm` below if you don't wish to switch yet)
- `yarn install` Install dependencies.
- `yarn watch` Compile development version and watch for changes. Bundled files will appear in `dist/`.
- `yarn start` Start the desktop app (while watcher is running in another terminal). Use Ctrl-R or Cmd-R to reload the app.
55 changes: 55 additions & 0 deletions app/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { h, Component } from 'preact'
import { ipcRenderer } from 'electron'
import { bind } from 'decko'
import ListMockup from './ListMockup'

export default class App extends Component {
state = { defaults: [], loaded: [], notify: false }

loadItems() {
ipcRenderer.send('load-templates')
ipcRenderer.on('template-list', (store, data) => {
// TODO: Remove hardcode names
this.setState({
defaults: data.defaults,
loaded: data.yourMockups,
})
})

ipcRenderer.on('update-downloaded', () => {
this.setState({
notify: true,
})
})
}

@bind
handleInstall(e) {
ipcRenderer.send('install-update')
}

componentWillMount() {
this.loadItems()
}

render({}, { defaults, loaded, notify }) {
return (
<div>
{notify
? <div className="w-100 pv2 ph4 tc black white pointer" onClick={this.handleInstall} style="background:#1880F9">
<span className="pr1">🎉</span> New version is available
<a href="#" className="pl1 white link">click here to install it</a>
</div>
: null
}
<div className="w-90 center">
<ListMockup name="Default Mockups" items={defaults} />

{loaded.length > 0
? <ListMockup name="Your Mockups" items={loaded} />
: null}
</div>
</div>
)
}
}
62 changes: 62 additions & 0 deletions app/ListMockup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { h, Component } from 'preact'
import { ipcRenderer } from 'electron'
import { bind } from 'decko'

const ListItem = ({ name, thumb, imgSizes, ...props }) => {
return (
<li className="list db fl w-third pr3 pl3 pb3" {...props}>
<img src={thumb} className="img w-100 ba bw1" style="height:134px;" />
<h3 className="db tc ma1 fw4 f5 o-80 mt2" style="letter-spacing:0.05em">
{name}
</h3>
<p className="db tc ma0 pa0 o-40 f6 fw3" style="letter-spacing:0.05em">
{imgSizes}
</p>
</li>
)}

export default class ListMockup extends Component {
constructor() {
super()
}

@bind
handleClick(mock) {
ipcRenderer.send('run-keynote', mock)
console.log(mock)
}

extractImageSize(obj) {
let imgs = obj.map((img) => {
return `${img.width}x${img.height}`
})

return imgs.join(', ')
}

humanizeName(name) {
return name.charAt(0).toUpperCase() + name.replace(/-/g, ' ').slice(1)
}

render({ name, items }) {
return (
<div>
{name
? <h4
className="f6 ttu tracked-mega fw7 pl3 pb2 pt3"
style="color:#C5C5C5"
>
{name}
</h4>
: null }
<ul className="pa0 ma0 list w-100 cf">
{items.map(template => {
let imgSizes = this.extractImageSize(template.images)
let name = this.humanizeName(template.name)
return <ListItem name={name} imgSizes={imgSizes} thumb={template.mockup.path} onClick={() => this.handleClick(template)} />
})}
</ul>
</div>
)
}
}
Binary file added app/assets/icon.icns
Binary file not shown.
Binary file added app/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/mockups/mockup-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/mockups/mockup-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/mockups/mockup-side-by-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions app/assets/templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"defaults": [
{
"name": "mobile",
"category": "default",
"images": [{ "x": 780, "y": 208, "width": 360, "height": 640 }],
"mockup": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080,
"path": "mockups/mockup-mobile.png"
}
},
{
"name": "desktop",
"category": "default",
"images": [{ "x": 350, "y": 130, "width": 1204, "height": 753 }],
"mockup": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080,
"path": "mockups/mockup-desktop.png"
}
},
{
"name": "side-by-side",
"category": "default",
"images": [
{ "x": 273, "y": 137, "width": 1204, "height": 753 },
{ "x": 1483, "y": 428, "width": 297, "height": 640 }
],
"mockup": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080,
"path": "mockups/mockup-side-by-side.png"
}
}
]
}
5 changes: 5 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { h, render } from 'preact';
import App from './App';
import { ipcRenderer } from 'electron'

render(<App />, document.body);
Binary file added build/icon.icns
Binary file not shown.
Loading

0 comments on commit 2c9ffa7

Please sign in to comment.