Skip to content

Commit

Permalink
v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondermarin committed Oct 11, 2020
1 parent fda0555 commit 988ceda
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 384 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-color-palette",
"version": "2.0.2",
"version": "2.0.3",
"private": false,
"description": "Color picker for React",
"author": "Wondermarin",
Expand Down Expand Up @@ -31,9 +31,6 @@
"build": "tsc",
"test": "jest"
},
"dependencies": {
"canvas": "^2.6.1"
},
"peerDependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand All @@ -60,12 +57,14 @@
"eslint-plugin-react": "^7.21.4",
"eslint-plugin-react-hooks": "^4.1.2",
"jest": "^26.5.2",
"jest-canvas-mock": "^2.3.0",
"jest-styled-components": "^7.0.3",
"prettier": "^2.1.2",
"react-test-renderer": "^16.13.1",
"typescript": "3.9.7"
},
"jest": {
"rootDir": "lib"
"rootDir": "lib",
"setupFiles": ["jest-canvas-mock"]
}
}
8 changes: 5 additions & 3 deletions src/utils/toHex/toHex.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { createCanvas } from "canvas";

/**
* Converts 3 digit HEX and HTML Color Names to 6 digit HEX.
* @param color 3 digit HEX or HTML Color Names.
*/
export function toHex(color: string): string {
const ctx = createCanvas(1, 1).getContext("2d");
const ctx = document.createElement("canvas").getContext("2d");

if (!ctx) {
throw new Error("2d context not supported or canvas already initialized");
}

ctx.fillStyle = color;

Expand Down
Loading

0 comments on commit 988ceda

Please sign in to comment.