Skip to content

Commit

Permalink
feat: initial implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Freisler <jakub@frsource.org>
  • Loading branch information
FRSgit committed Feb 24, 2022
1 parent 62ef779 commit 29257ce
Show file tree
Hide file tree
Showing 15 changed files with 6,961 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
root: true,
plugins: [
'@typescript-eslint',
'eslint-comments'
],
env: {
es6: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-comments/recommended',
'prettier'
],
overrides: [
{
files: ['**.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
project: [
'./tsconfig.json',
'./packages/*/tsconfig.json',
],
tsconfigRootDir: __dirname,
warnOnUnsupportedTypeScriptVersion: false,
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
},
],
};
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github: [FRSOURCE]
patreon: frsource
custom: ['https://www.buymeacoffee.com/FRSOURCE']
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Please complete the following information:**
- OS and version: [e.g. Windows 10 build. 19043.1319]
- Browser and version [e.g. chrome 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Lint
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
cache:
name: CI cache
runs-on: ubuntu-latest
outputs:
yarn-cache-key: ${{ steps.yarn-cache-key.outputs.key }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Remove git auth
run: git config --unset http.https://github.com/.extraheader
- name: Generate yarn cache-key
id: yarn-cache-key
run: echo "::set-output name=key::${{ runner.os }}-yarn-ci-cache-v3-${{ hashFiles('./yarn.lock') }}-${{ hashFiles('**/yarn.lock') }}"
- name: Configure Yarn cache
uses: actions/cache@v2
with:
key: ${{ steps.yarn-cache-key.outputs.key }}
path: |
.yarn
node_modules
- name: Install dependencies
run: yarn --immutable

lint:
name: lint
runs-on: ubuntu-latest
needs: cache
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: remove git auth
run: git config --unset http.https://github.com/.extraheader
- name: Configure Yarn cache
uses: actions/cache@v2
with:
key: ${{ needs.cache.outputs.yarn-cache-key }}
path: |
.yarn
node_modules
- name: Install dependencies
run: yarn --immutable
- name: Lint
run: yarn lint:ci
- name: Prettify
run: yarn prettify:ci

build-and-release:
name: build and release
runs-on: ubuntu-latest
needs: [cache, lint]
steps:
- uses: actions/checkout@v2
with:
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: "0"
- name: Setup git user
run: |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: remove git auth
run: git config --unset http.https://github.com/.extraheader
- name: Configure Yarn cache
uses: actions/cache@v2
with:
key: ${{ needs.cache.outputs.yarn-cache-key }}
path: |
.yarn
node_modules
- name: Install dependencies
run: yarn --immutable
- name: Authenticate with Registry
run: |
echo "registry=http://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: build
run: yarn build
- name: release package
if: ${{ success() && github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main' && github.event_name == 'push' }}
run: yarn release:ci
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79 changes: 77 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,77 @@
# autoresize-textarea
Minimalistic plugin to autosize your textareas 💪
<p align="center">
<a href="https://www.npmjs.com/package/@frsource/autoresize-textarea">
<img src="https://img.shields.io/npm/v/@frsource/autoresize-textarea" alt="NPM version badge">
</a>
<a href="https://bundlephobia.com/result?p=@frsource/autoresize-textarea" title="Visit bundlephobia for more details!">
<img src="https://img.shields.io/bundlephobia/minzip/@frsource/autoresize-textarea" alt="Core bundle size badge. Data from bundlephobia.com">
</a>
<a href="https://github.com/semantic-release/semantic-release">
<img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-relase badge">
</a>
<a href="https://bundlephobia.com/result?p=@frsource/autoresize-textarea">
<img src="https://badgen.net/bundlephobia/tree-shaking/@frsource/autoresize-textarea" alt="Tree shaking supported">
</a>
<a href="https://github.com/FRSOURCE/autoresize-textarea/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/FRSOURCE/autoresize-textarea" alt="license MIT badge">
</a>
</p>

<h1 align="center">Autoresize Textarea - minimalistic plugin to autosize your textareas! 💪</h1>

<p align="center">
<a href="#quick-start">Getting Started</a>
·
<a href="https://www.frsource.org/autoresize-textarea" target="_blank">Demo</a>
.
<a href="#contribution">Contribution</a>
·
<a href="https://github.com/FRSOURCE/autoresize-textarea/issues">File an Issue</a>
·
<a href="#questions">Have a question or an idea?</a>
<br>
</p>

<p align="center">
<br>
<i>Tiny library which make your textareas fluid.
<br>Mobile &amp; desktop-friendly
<br>Performant & small bundle size.
<br>Published as separate bundles for JS ES5 or modern browsers thanks to <a href="https://www.npmjs.com/package/microbundle">microbundle</a>.
<br>Written completely in <a href="https://www.typescriptlang.org">typescript</a>.</i>
<br>Published under [MIT](https://opensource.org/licenses/MIT) license.</i>
<br>
<br>
</p>

## Quick start

### ES/Typescript

```ts
import { attach } from "@frsource/autoresize-textarea";
const textarea = document.querySelector("textarea");
attach(textarea);
```

### UMD

```js
const textarea = document.querySelector("textarea");
window.autoresizeTextarea.attach(textarea);
```

For working example, check out [our demo](https://www.frsource.org/autoresize-textarea).

## Questions

Don’t hesitate to ask a question directly on the [discussions board](https://github.com/FRSOURCE/autoresize-textarea/discussions)!

## Changelog

Changes for every release are documented in the [release notes](https://github.com/FRSOURCE/autoresize-textarea/releases) and [CHANGELOG file](https://github.com/FRSOURCE/autoresize-textarea/tree/master/CHANGELOG.md).

## License

[MIT](https://opensource.org/licenses/MIT)

Copyright (c) 2022-present, Jakub FRS Freisler, FRSOURCE
58 changes: 58 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<html lang="en">
<head>
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.classless.min.css">
<style>
textarea {
resize: vertical;
}
</style>
</head>
<body>
<main>
<section>
<hgroup>
<h1>@frsource/autoresize-textarea</h1>
<h2>Minimalistic plugin to autosize your textareas! 💪</h2>
</hgroup>
<article>
<hgroup>
<h4>Autoresizing, fluid textarea demo</h4>
<h5>Try adding new lines to textarea below</h5>
</hgroup>
<form>
<label>
<textarea rows="1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend commodo interdum. Donec tincidunt consequat semper. Nulla id magna viverra, egestas est sit amet, lacinia felis. Donec ut mauris nunc. Vivamus ex sem, tempor ac felis ut, congue laoreet lectus. Etiam urna augue, iaculis in metus eu, pharetra lobortis tortor.</textarea>
</label>
</form>

<details open>
<summary>ES/TS code example</summary>
<pre><code>&lt;<b>textarea</b> <i>row</i>=<u>"2"</u>&gt;<span style="white-space: normal;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend commodo interdum. Donec tincidunt consequat semper. Nulla id magna viverra, egestas est sit amet, lacinia felis. Donec ut mauris nunc. Vivamus ex sem, tempor ac felis ut, congue laoreet lectus. Etiam urna augue, iaculis in metus eu, pharetra lobortis tortor.</span>&lt;/<b>textarea</b>&gt;

&lt;<b>script</b>&gt;
<b>import</b> { attach } <b>from</b> <u>"@frsource/autoresize-textarea"</u>;
<b>const</b> textarea = document.<i>querySelector</i>(<u>"textarea"</u>);
attach(textarea);
&lt;/<b>script</b>&gt;</code></pre>
</details>

<details>
<summary>UMD code example</summary>
<pre><code>&lt;<b>textarea</b> <i>row</i>=<u>"2"</u>&gt;<span style="white-space: normal;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend commodo interdum. Donec tincidunt consequat semper. Nulla id magna viverra, egestas est sit amet, lacinia felis. Donec ut mauris nunc. Vivamus ex sem, tempor ac felis ut, congue laoreet lectus. Etiam urna augue, iaculis in metus eu, pharetra lobortis tortor.</span>&lt;/<b>textarea</b>&gt;

&lt;<b>script</b>&gt;
<b>const</b> textarea = document.<i>querySelector</i>(<u>"textarea"</u>);
window.autoresizeTextarea.<i>attach</i>(textarea);
&lt;/<b>script</b>&gt;</code></pre>
</details>
</article>
</section>
</main>
<script src="https://unpkg.com/@frsource/autoresize-textarea"></script>
<script src="../dist/index.umd.js"></script>
<script>
const textarea = document.querySelector("textarea");
window.autoresizeTextarea.attach(textarea);
</script>
</body>
</html>
Loading

0 comments on commit 29257ce

Please sign in to comment.