This repository has been archived by the owner on Jun 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite using react hooks, add tests & fix issue where top&bottom bor…
…ders not taken into account
- Loading branch information
Showing
37 changed files
with
25,794 additions
and
19,280 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,26 @@ | ||
{ | ||
"projectName": "react-expanding-textarea", | ||
"projectOwner": "rpearce", | ||
"repoType": "github", | ||
"repoHost": "https://github.com", | ||
"files": [ | ||
"README.md" | ||
], | ||
"imageSize": 100, | ||
"commit": true, | ||
"contributors": [ | ||
{ | ||
"login": "rpearce", | ||
"name": "Robert Pearce", | ||
"avatar_url": "https://avatars2.githubusercontent.com/u/592876?v=4", | ||
"profile": "https://robertwpearce.com", | ||
"contributions": [ | ||
"code", | ||
"doc", | ||
"example", | ||
"ideas", | ||
"test" | ||
] | ||
} | ||
] | ||
} |
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,3 @@ | ||
> 0.25% | ||
ie 11 | ||
not op_mini all |
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,4 @@ | ||
coverage/ | ||
docs/ | ||
node_modules/ | ||
src/ |
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,64 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react", | ||
"react-hooks" | ||
], | ||
"rules": { | ||
"array-bracket-spacing": [ "error", "always" ], | ||
"arrow-spacing": [ "error" ], | ||
"block-spacing": [ "error" ], | ||
"camelcase": [ "error" ], | ||
"comma-dangle": [ "error", "never" ], | ||
"computed-property-spacing": [ "error", "never" ], | ||
"curly": [ "error", "all" ], | ||
"eol-last": [ "error", "always" ], | ||
"eqeqeq": [ "error", "always", { "null": "ignore" } ], | ||
"func-call-spacing": [ "error", "never" ], | ||
"indent": [ "error", 2 ], | ||
"linebreak-style": [ "error", "unix" ], | ||
"no-console": "off", | ||
"no-else-return": [ "error" ], | ||
"no-empty-function": [ "error" ], | ||
"no-extra-parens": [ "error" ], | ||
"no-lone-blocks": [ "error" ], | ||
"no-multi-assign": [ "error" ], | ||
"no-multiple-empty-lines": [2, { "max": 1, "maxEOF": 1 }], | ||
"no-new": [ "error" ], | ||
"no-new-func": [ "error" ], | ||
"no-param-reassign": [ "error" ], | ||
"no-return-assign": [ "error" ], | ||
"no-sequences": [ "error" ], | ||
"no-trailing-spaces": [ "error" ], | ||
"no-useless-return": [ "error" ], | ||
"no-void": [ "error" ], | ||
"no-with": [ "error" ], | ||
"object-curly-spacing": [ "error", "always" ], | ||
"quotes": [ "error", "single" ], | ||
"react-hooks/rules-of-hooks": "error", | ||
"react/jsx-no-undef": "error", | ||
"react/jsx-uses-react": "error", | ||
"react/jsx-uses-vars": "error", | ||
"react/prop-types": 0, | ||
"semi": [ "error", "never" ], | ||
"yoda": [ "error" ] | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "16" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,29 +1,64 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# 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 | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next | ||
|
||
lib/ | ||
src/ | ||
*.tmp |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
language: node_js | ||
node_js: | ||
- "11" | ||
cache: yarn | ||
after_success: | ||
- npm run coverage |
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,31 @@ | ||
# API Documentation | ||
|
||
## Installation | ||
Install the package: | ||
``` | ||
$ npm install --save react-expanding-textarea | ||
``` | ||
|
||
## Usage | ||
Use this exactly like you would a normal `<textarea>`; the only | ||
difference is that it is doing some simple expanding work behind the scenes for you! | ||
```js | ||
import Textarea from 'react-expanding-textarea' | ||
|
||
const handleChange = (e) => { | ||
console.log('Changed value to: ', e.target.value) | ||
} | ||
|
||
const myComponent = () => | ||
<Textarea | ||
maxLength="3000" | ||
className="textarea" | ||
name="post[notes]" | ||
placeholder="Notes" | ||
onChange={ handleChange } /> | ||
``` | ||
|
||
### `rows` | ||
If you pass a `rows` prop, then this component will perform a calculation based | ||
on computed `lineHeight`, `paddingTop` and `paddingBottom` to deduce what the | ||
minimum height-in-rows the component should be. |
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 @@ | ||
Robert Pearce <me@robertwpearce.com> (https://robertwpearce.com) |
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
# changelog | ||
all notable changes to this project will be documented in this file. | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
the format is based on [keep a changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [semantic versioning](http://semver.org/spec/v2.0.0.html). | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.2.0] - 2018-08-08 | ||
|
||
### added / fixed | ||
- addressed #14 where the `rows` attribute was being disregarded. Now, it | ||
### Added / Fixed | ||
* addressed #14 where the `rows` attribute was being disregarded. Now, it | ||
provides a means to provide a minimum/default number of `rows`. This is a | ||
minorversion bump because it will cause the component to behave differently | ||
for existing folks and is really more of an addition than a fix. | ||
|
||
## [0.1.10] - 2018-04-29 | ||
|
||
### fixed | ||
- fixed #10 where a change in the value prop was not recalculating the size | ||
### Fixed | ||
* fixed #10 where a change in the value prop was not recalculating the size | ||
|
||
## [0.1.9] - 2017-10-05 | ||
|
||
### fixed | ||
- support for react v16 | ||
### Fixed | ||
* support for react v16 |
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
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,45 @@ | ||
# Contributing | ||
|
||
1. Check out the [issues](https://github.com/rpearce/react-expanding-textarea/issues) | ||
1. [Fork](https://guides.github.com/activities/forking/) this repository | ||
1. [Clone](https://help.github.com/articles/cloning-a-repository/) your fork | ||
1. Add the upstream project (this one) as a git remote: | ||
``` | ||
$ git remote add upstream git@github.com:rpearce/react-expanding-textarea.git | ||
$ git fetch upstream | ||
$ git rebase upstream/master | ||
``` | ||
1. Check out a feature branch | ||
``` | ||
$ git checkout -b my-feature | ||
``` | ||
1. Make your changes | ||
1. Push your branch to your GitHub repo | ||
``` | ||
$ git push origin my-feature | ||
``` | ||
1. Create a [pull request](https://help.github.com/articles/about-pull-requests/) | ||
from your branch to this repo's `master` branch | ||
1. When all is merged, pull down the upstream changes to your master | ||
``` | ||
$ git fetch upstream | ||
$ git merge upstream/master | ||
``` | ||
1. Delete your feature branch (locally and then on GitHub) | ||
``` | ||
$ git branch -D my-feature | ||
$ git push origin :my-feature | ||
``` | ||
|
||
## Testing | ||
Tests are located in the `test/` folder. Here's how to run them: | ||
|
||
``` | ||
$ yarn test | ||
``` | ||
|
||
To test in watch mode: | ||
|
||
``` | ||
$ yarn test --watch | ||
``` |
Oops, something went wrong.