Skip to content

Commit

Permalink
Initial commit (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
magalhini committed Aug 11, 2017
0 parents commit b1a7279
Show file tree
Hide file tree
Showing 14 changed files with 4,905 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react", "es2015"]
}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain
# consistent coding styles between different editors and IDEs.

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"mocha": true
}
}
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Logs
logs
*.log
npm-debug.log*
.DS_Store

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Editors
.idea

# Lib
lib
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- "6"
script:
- npm run lint
- npm run test
- npm run build
- npm run test:examples
branches:
only:
- master
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Reporting Issues and Asking Questions

Before opening an issue, please search the (issue tracker)[https://github.com/Travelport-Ukraine/npm-module-boilerplate/issues] to make sure your issue hasn’t already been reported.

# Sending a Pull Request

For non-trivial changes, please open an issue with a proposal for a new feature or refactoring before starting on the work. We don’t want you to waste your efforts on a pull request that we won’t want to accept.

On the other hand, sometimes the best way to start a conversation is to send a pull request. Use your best judgement!

In general, the contribution workflow looks like this:

- Open a new issue in the (issue tracker)[https://github.com/Travelport-Ukraine/npm-module-boilerplate/issues]
- Fork the repo.
- Create a new feature branch based off the master branch.
- Make sure all tests pass and there are no linting errors.
- Submit a pull request, referencing any issues it addresses.
- Please try to keep your pull request focused in scope and avoid including unrelated commits.

After you have submitted your pull request, we’ll try to get back to you as soon as possible. We may suggest some changes or improvements.

Thank you for contributing!
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Travelport-Ukraine

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.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Why? [![Build Status](https://travis-ci.org/Travelport-Ukraine/npm-module-boilerplate.svg?branch=master)](https://travis-ci.org/Travelport-Ukraine/npm-module-boilerplate)
:page_with_curl: Boilerplate for npm/node module. Write with ES6 - have compatibility with all node versions.

This boilerplate is for people who want write code using all ES6 features ( and stage-2 ) but also want/need backwards compatibility with old node versions.

# Features
* Build with [Babel](https://babeljs.io). (ES6 -> ES5)
* Test with [mocha](https://mochajs.org).
* Cover with [istanbul](https://github.com/gotwarlost/istanbul).
* Check with [eslint](eslint.org).
* Deploy with [Travis](travis-ci.org).

# Commands
- `npm run clean` - Remove `lib/` directory
- `npm test` - Run tests. Tests can be written with ES6 (WOW!)
- `npm test:watch` - You can even re-run tests on file changes!
- `npm run cover` - Yes. You can even cover ES6 code.
- `npm run lint` - We recommend using [airbnb-config](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb). It's fantastic.
- `npm run test:examples` - We recommend writing examples on pure JS for better understanding module usage.
- `npm run build` - Do some magic with ES6 to create ES5 code.
- `npm run prepublish` - Hook for npm. Do all the checks before publishing you module.

# Installation
Just clone this repo and remove `.git` folder.

66 changes: 66 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import ReactDOM from 'react-dom';
import TextFit from '../src/';

class App extends React.Component {
constructor() {
super();
this.state = {
sentence: 'Smaller texts gets the biggest size. The more words you add... the more it will reduce the size of the text based on the maximum cap you set. But you can set a minimum size for a maximum amount of characters, so the text will stop resizing itself once it caps to your needs.',
typed: '',
input: 'Works on contenteditable. Type here!'
};

this.type = this.type.bind(this);
}

type(string, n) {
if (n <= string.length) {
setTimeout(() => {
this.setState({
typed: string.substr(0, n)
});
this.type(string, n+1);
}, Math.floor(Math.random() * 100) - 50);
}
}

componentDidMount() {
this.type(this.state.sentence, 0);
//this.input.focus();
}

restart() {
this.setState({
typed: '',
}, this.type.bind(null, this.state.sentence, 0))
}

render() {
return (
<div>
<span className="description">
Control the size of your paragraphs based on its length. Shorter lines appear larger, longer lines get smaller and smaller until your desired minimum size.
</span>
<h2>Examples:</h2>
<p className="example-desc"><code>Adjust size as you type, set at: max="40" min="16" capAt="80" characters </code></p>
<TextFit className="style textTextFit--editable" min="16" max="40" capAt="80">
<div ref={(input) => this.input = input} onKeyDown={(e) => this.setState({ input: this.input.value })} contentEditable="true">{this.state.input}</div>
</TextFit>
<p className="example-desc"><code>A dynamic example, set at: max="40" min="26" capAt="180"</code></p>
<TextFit className="style" min="26" max="40" capAt="180">
<p>{this.state.typed}</p>
<button onClick={this.restart.bind(this)}>Restart</button>
</TextFit>
<p className="example-desc"><code>Example set at : max="46" min="16" capAt="150"</code></p>
<TextFit className="style quote" min="16" max="46" capAt="150">
<p>“Wise quotes are shorter”</p>
</TextFit>
<p className="example-desc"><code>Example set at : max="46" min="16" capAt="150"</code></p>
<TextFit className="style quote" min="16" max="46" capAt="150">
<p>But they can also be longer... this component allows for automatic fine control. You set where it should cap at.</p>
</TextFit>
</div>
);
}
}
Loading

0 comments on commit b1a7279

Please sign in to comment.