-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32e8e56
Showing
32 changed files
with
5,096 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
*.js text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Build | ||
dist | ||
lib | ||
.merlin | ||
|
||
# Logs | ||
*.log | ||
npm-debug.log* | ||
yarn-error.log | ||
|
||
# macOS | ||
.*DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "reasonable", | ||
"reason": { | ||
"react-jsx": true | ||
}, | ||
"bs-dependencies": [ | ||
"reason-react", | ||
"reason-js", | ||
"reductive" | ||
], | ||
"sources": [ | ||
{ | ||
"dir": "src", | ||
"subdirs": [ | ||
"components", | ||
"reductive", | ||
"styles" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## Change Log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Calculator in Reason</title> | ||
</head> | ||
<body> | ||
<div class="root"></div> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Neil Kistner <[email protected]> (neilkistner.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "reason-calculator", | ||
"private": true, | ||
"version": "0.0.0", | ||
"repository": "wyze/reason-calculator", | ||
"author": { | ||
"name": "Neil Kistner", | ||
"email": "[email protected]", | ||
"url": "neilkistner.com" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "npm-run-all build:*", | ||
"build:bsb": "bsb -make-world", | ||
"build:webpack": "webpack -p", | ||
"changelog": "changelog-maker --filter-release -- wyze reason-calculator", | ||
"clean": "npm-run-all clean:*", | ||
"clean:bsb": "bsb -clean-world", | ||
"clean:project": "rimraf dist lib .merlin", | ||
"deploy": "surge dist reason-calculator.surge.sh", | ||
"dev": "npm-run-all --parallel dev:*", | ||
"dev:bsb": "npm run build:bsb -- -w", | ||
"dev:webpack": "webpack-dev-server -w", | ||
"np": "np --no-publish --yolo", | ||
"prebuild": "npm run clean", | ||
"predeploy": "npm-run-all build np", | ||
"version": "node scripts/version.js" | ||
}, | ||
"devDependencies": { | ||
"bs-platform": "^1.6.0", | ||
"changelog-maker": "^2.2.5", | ||
"execa": "^0.6.3", | ||
"glamor": "^2.20.24", | ||
"np": "^2.13.1", | ||
"npm-run-all": "^4.0.2", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"read-pkg": "^2.0.0", | ||
"reason-js": "^0.3.0", | ||
"reason-react": "^0.1.0", | ||
"reductive": "git+https://github.com/reasonml/reductive.git", | ||
"rimraf": "^2.6.1", | ||
"surge": "^0.19.0", | ||
"webpack": "^2.3.1", | ||
"webpack-dev-server": "^2.4.2", | ||
"webpack-html-plugin": "^0.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# reason-calculator | ||
|
||
[![Website][website-image]][website-url] | ||
[![dependencies][deps-image]][deps-url] | ||
[![devDependencies][depsdev-image]][depsdev-url] | ||
|
||
> A calculator built with [Reason](https://github.com/facebook/reason) and [reason-react](https://github.com/reasonml/reason-react). | ||
## Live Demo | ||
|
||
https://reason-calculator.surge.sh | ||
|
||
## Setup | ||
|
||
```sh | ||
$ git clone https://github.com/wyze/reason-calculator.git | ||
$ cd reason-calculator | ||
$ yarn # or `npm install` | ||
``` | ||
|
||
## Development | ||
|
||
```sh | ||
$ npm run dev | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
$ npm run build | ||
``` | ||
|
||
## Change Log | ||
|
||
> [Full Change Log](changelog.md) | ||
## License | ||
|
||
MIT © [Neil Kistner](https://neilkistner.com) | ||
|
||
[website-image]: https://img.shields.io/website-up-down-green-red/https/reason-calculator.surge.sh.svg?style=flat-square | ||
[website-url]: https://reason-calculator.surge.sh | ||
|
||
[deps-image]: https://img.shields.io/david/wyze/reason-calculator.svg?style=flat-square | ||
[deps-url]: https://david-dm.org/wyze/reason-calculator | ||
|
||
[depsdev-image]: https://img.shields.io/david/dev/wyze/reason-calculator.svg?style=flat-square | ||
[depsdev-url]: https://david-dm.org/wyze/reason-calculator?type=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const execa = require('execa') | ||
const readFile = require('fs').readFileSync | ||
const readPkg = require('read-pkg') | ||
const writeFile = require('fs').writeFileSync | ||
|
||
// get version from pkg.json | ||
const getVersionAndUrl = | ||
({ repository: { url }, version }) => ({ url, version }) | ||
|
||
// npm run changelog (and grab output) | ||
const getChanges = ({ url, version }) => { | ||
const { stdout } = execa.sync('npm', [ 'run', 'changelog', '--silent' ]) | ||
const changes = stdout.trim().split(' \n') | ||
|
||
return { changes, url, version } | ||
} | ||
|
||
// modify changelog.md | ||
const updateChangelog = ({ changes, url, version }) => { | ||
const file = 'changelog.md' | ||
const changelog = readFile(file).toString().split('\n') | ||
const date = new Date().toJSON().split('T').shift() | ||
const tag = `v${version}` | ||
const repo = url.replace(/\.?git(?!hub)\+?/g, '') | ||
const header = `### [${tag}](${repo}/releases/tag/${tag}) (${date})` | ||
const formatted = [ header, '', ...changes ] | ||
|
||
writeFile( | ||
file, | ||
[ | ||
...changelog.slice(0, 2), | ||
...formatted, | ||
...changelog.slice(1), | ||
].join('\n') | ||
) | ||
|
||
return formatted | ||
} | ||
|
||
// modify readme.md | ||
const updateReadme = formatted => { | ||
const file = 'readme.md' | ||
const readme = readFile(file).toString().split('\n') | ||
const start = '> [Full Change Log](changelog.md)' | ||
const end = '## License' | ||
|
||
writeFile( | ||
file, | ||
[ | ||
...readme.slice(0, readme.indexOf(start) + 2), | ||
...formatted, | ||
...readme.slice(readme.indexOf(end) - 1), | ||
].join('\n') | ||
) | ||
} | ||
|
||
// git add | ||
const runGitAdd = () => { | ||
execa.sync('git', [ 'add', '--all' ]) | ||
} | ||
|
||
readPkg() | ||
.then(getVersionAndUrl) | ||
.then(getChanges) | ||
.then(updateChangelog) | ||
.then(updateReadme) | ||
.then(runGitAdd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module App = { | ||
include ReactRe.Component; | ||
let name = "App"; | ||
|
||
type props = { | ||
dispatch: Store.action => unit, | ||
state: Store.state, | ||
}; | ||
|
||
let className: string = | ||
Styles.make | ||
alignItems::"center" | ||
display::"flex" | ||
flexDirection::"column" | ||
() | ||
|> Styles.className; | ||
|
||
let render { props: { dispatch, state: { operations } } } => { | ||
let output = Operation.getInput operations; | ||
|
||
<main className> | ||
<Hero /> | ||
<Calculator> | ||
<Display output /> | ||
<Buttons dispatch /> | ||
</Calculator> | ||
</main>; | ||
}; | ||
}; | ||
|
||
include ReactRe.CreateComponent App; | ||
|
||
let createElement ::state ::dispatch => wrapProps { dispatch, state }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module ButtonGroup = { | ||
include ReactRe.Component; | ||
let name = "ButtonGroup"; | ||
|
||
type props = { | ||
children: list ReactRe.reactElement, | ||
}; | ||
|
||
let className: string = | ||
Styles.make display::"flex" () |> Styles.className; | ||
|
||
let render { props: { children } } => | ||
<div className> | ||
(ReactRe.listToElement children) | ||
</div>; | ||
}; | ||
|
||
include ReactRe.CreateComponent ButtonGroup; | ||
|
||
let createElement ::children => | ||
wrapProps { children: children } ::children; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Buttons = { | ||
include ReactRe.Component; | ||
let name = "Buttons"; | ||
|
||
type props = { | ||
dispatch: Store.action => unit, | ||
}; | ||
|
||
let render { props: { dispatch } } => | ||
<div> | ||
<ButtonGroup> | ||
<ClearButton dispatch /> | ||
<OperationButton dispatch action=Divide /> | ||
</ButtonGroup> | ||
<ButtonGroup> | ||
<ValueButton dispatch value="7" /> | ||
<ValueButton dispatch value="8" /> | ||
<ValueButton dispatch value="9" /> | ||
<OperationButton dispatch action=Multiply /> | ||
</ButtonGroup> | ||
<ButtonGroup> | ||
<ValueButton dispatch value="4" /> | ||
<ValueButton dispatch value="5" /> | ||
<ValueButton dispatch value="6" /> | ||
<OperationButton dispatch action=Subtract /> | ||
</ButtonGroup> | ||
<ButtonGroup> | ||
<ValueButton dispatch value="1" /> | ||
<ValueButton dispatch value="2" /> | ||
<ValueButton dispatch value="3" /> | ||
<OperationButton dispatch action=Add /> | ||
</ButtonGroup> | ||
<ButtonGroup> | ||
<ValueButton dispatch expand=true value="0" /> | ||
<OperationButton dispatch action=Equals /> | ||
</ButtonGroup> | ||
</div>; | ||
}; | ||
|
||
include ReactRe.CreateComponent Buttons; | ||
|
||
let createElement ::dispatch => wrapProps { dispatch: dispatch }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Calculator = { | ||
include ReactRe.Component; | ||
let name = "Calculator"; | ||
|
||
type props = { | ||
children: list ReactRe.reactElement, | ||
}; | ||
|
||
let className: string = | ||
Styles.make | ||
background::"#838383" | ||
borderRadius::"5px" | ||
overflow::"hidden" | ||
width::"14em" | ||
() | ||
|> Styles.className; | ||
|
||
let render { props: { children } } => | ||
<div className> | ||
(ReactRe.listToElement children) | ||
</div>; | ||
}; | ||
|
||
include ReactRe.CreateComponent Calculator; | ||
|
||
let createElement ::children => wrapProps { children: children } ::children; |
Oops, something went wrong.