Skip to content

Commit

Permalink
Merge pull request #55 from jonyw4/ToTypescript
Browse files Browse the repository at this point in the history
Update project to typescript
  • Loading branch information
jonyw4 authored Aug 17, 2020
2 parents 543ff7e + 8ccb3ba commit 6f7d763
Show file tree
Hide file tree
Showing 58 changed files with 2,349 additions and 3,528 deletions.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.js

This file was deleted.

30 changes: 30 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
parser: '@typescript-eslint/parser'
env:
browser: true
node: true
es6: true
'jest/globals': true
parserOptions:
ecmaVersion: 2020
sourceType: "module"
ecmaFeatures:
jsx: true
settings:
react:
version: "detect"
extends:
- 'eslint:recommended'
- 'plugin:@typescript-eslint/recommended'
- 'prettier/@typescript-eslint'
- 'plugin:prettier/recommended'
- 'plugin:jest/recommended'
- 'plugin:react/recommended'
- 'plugin:react-hooks/recommended'
plugins:
- '@typescript-eslint'
- 'prettier'
- 'jest'
- 'react'
- 'react-hooks'
rules:
"react/no-children-prop": "off"
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Lint
run: yarn lint
- name: Test
run: yarn test
run: yarn test:ci
- name: Build
run: yarn build
- name: Deploy Package
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
dist
lib
coverage
.rpt2_cache
.rts2_cache_cjs
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "none",
"printWidth": 80,
"singleQuote": true,
"tabWidth": 2
}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Use the official Lokesh's [color-thief](https://github.com/lokesh/color-thief/).
npm i -S color-thief-react
```

```
yarn add color-thief-react
```

## Basic Usage
```jsx
import Color from 'color-thief-react';
Expand All @@ -42,7 +46,7 @@ Return the predominant color of the image. You can use a React component or hook

`src`: **Required**. Link of the image

`format`: Format of the response. Can be 'rgbToString' or 'rgbToArray' or 'hex'
`format`: Format of the response. Can be `rgbString`, `hex` or `rgbArray`. Default is `rgbString`

`crossOrigin`: Tag cross-origin for image

Expand All @@ -54,7 +58,7 @@ import { useColor } from 'color-thief-react'

const { data, loading, error } = useColor(src, format, { crossOrigin, quality})

<div style={{ color: data.vibrant }}>
<div style={{ color: data }}>
Text with the predominant color
</div>
```
Expand All @@ -77,7 +81,7 @@ Return a palette of colors based on the predominance of colors on the image. You

`colorCount`: Count of colors of the palette. Default is 2

`format`: Format of the response. Can be `rgbToString` or `rgbToArray` or `hex`. Default is `rgbToString`
`format`: Format of the response. Can be `rgbString`, `hex` or `rgbArray`. Default is `rgbString`

`crossOrigin`: Tag cross-origin for image

Expand Down
11 changes: 9 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
module.exports = {
coverageDirectory: 'coverage',
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
preset: 'ts-jest',
rootDir: __dirname,
transform: {
'^.+\\.(t|j)s$': 'ts-jest'
},
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/__tests__/.eslintrc.js',
'<rootDir>/__tests__/.eslintrc.js'
],
testEnvironmentOptions: { resources: 'usable' },
testEnvironmentOptions: { resources: 'usable' }
};
64 changes: 28 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,46 @@
"name": "color-thief-react",
"version": "1.0.2",
"description": "A React component with hooks for Color Thief. Grab color palette from an image with javascript",
"main": "dist",
"main": "lib/index.js",
"author": "Jonathan Célio",
"license": "ISC",
"scripts": {
"lint": "eslint 'src/*'",
"test:unit": "jest --collectCoverage",
"test": "jest --collectCoverage | codecov",
"build": "babel src -d dist"
},
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest"
}
"build": "tsc --project tsconfig.build.json",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"test": "jest --collectCoverage",
"test:ci": "jest --collectCoverage && codecov"
},
"dependencies": {
"colorthief": "^2.3.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0"

"colorthief": "2.3.0",
"prop-types": "15.7.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"use-current-effect": "2.1.0"
},
"devDependencies": {
"codecov": "3.7.2",
"husky": "4.2.5",
"semantic-release": "17.1.1",
"@babel/cli": "7.10.5",
"@babel/core": "7.10.5",
"@babel/preset-env": "7.10.4",
"@babel/preset-react": "7.10.4",
"@commitlint/cli": "9.1.1",
"@commitlint/config-conventional": "9.1.1",
"@testing-library/react": "10.4.7",
"babel-eslint": "10.1.0",
"babel-jest": "26.1.0",
"@types/jest": "26.0.10",
"@types/react": "16.9.46",
"@types/react-dom": "16.9.8",
"@typescript-eslint/eslint-plugin": "3.9.0",
"@typescript-eslint/parser": "3.9.0",
"canvas": "2.6.1",
"codecov": "3.7.2",
"coveralls": "3.1.0",
"eslint": "7.5.0",
"eslint-config-airbnb": "18.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "23.19.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-react": "7.20.4",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.20.6",
"eslint-plugin-react-hooks": "4.0.8",
"jest": "26.1.0"
"husky": "4.2.5",
"jest": "26.1.0",
"prettier": "2.0.5",
"semantic-release": "17.1.1",
"ts-jest": "26.2.0",
"typescript": "3.9.7"
},
"keywords": [
"color-thief-react",
Expand All @@ -57,17 +53,13 @@
],
"husky": {
"hooks": {
"pre-commit": "yarn run lint",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"release": {
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
{
"name": "beta",
"prerelease": true
}
"master"
]
},
"commitlint": {
Expand Down
Loading

0 comments on commit 6f7d763

Please sign in to comment.