Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Rewrite using react hooks, add tests & fix issue where top&bottom bor…
Browse files Browse the repository at this point in the history
…ders not taken into account
  • Loading branch information
rpearce committed Feb 24, 2019
1 parent b62e403 commit c3bcb40
Show file tree
Hide file tree
Showing 37 changed files with 25,794 additions and 19,280 deletions.
26 changes: 26 additions & 0 deletions .all-contributorsrc
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"
]
}
]
}
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 0.25%
ie 11
not op_mini all
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/
docs/
node_modules/
src/
64 changes: 64 additions & 0 deletions .eslintrc
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"
}
}
}
45 changes: 40 additions & 5 deletions .gitignore
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
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

6 changes: 6 additions & 0 deletions .travis.yml
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
31 changes: 31 additions & 0 deletions API.md
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.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Robert Pearce <me@robertwpearce.com> (https://robertwpearce.com)
20 changes: 10 additions & 10 deletions CHANGELOG.md
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
56 changes: 43 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
Expand All @@ -16,31 +22,55 @@ Examples of behavior that contributes to creating a positive environment include

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at me@robertwpearce.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at me@robertwpearce.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
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
```
Loading

0 comments on commit c3bcb40

Please sign in to comment.