From 4fc4b14fe7956adaf31d050dcfb70735a7b5a9dc Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 18 Aug 2018 21:31:06 +0200 Subject: [PATCH] Added svg resistor --- package-lock.json | 561 ++++++++++++++++++++++++++++ package.json | 1 + public/resistor.svg | 186 +++++++++ src/components/Resistor/index.js | 340 +++++++++++++---- src/components/Resistor/resistor.js | 50 +++ src/components/Resistor/result.js | 152 ++++++-- 6 files changed, 1188 insertions(+), 102 deletions(-) create mode 100644 public/resistor.svg create mode 100644 src/components/Resistor/resistor.js diff --git a/package-lock.json b/package-lock.json index fc6f8f3..5c47075 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,184 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@svgr/cli": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@svgr/cli/-/cli-2.2.0.tgz", + "integrity": "sha512-vwqhkwNIZ1amBRx+jFhYMytlhjPBTpgu8IeyBzzbqpCxcsh2KMe8sNWv6w9NsMr3Jehm0z2xy0iTMdVLl/bVSg==", + "dev": true, + "requires": { + "@svgr/core": "^2.2.0", + "chalk": "^2.4.1", + "commander": "^2.17.1", + "glob": "^7.1.2", + "lodash": "^4.17.10", + "output-file-sync": "^2.0.1", + "recursive-readdir": "^2.2.2" + }, + "dependencies": { + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", + "dev": true + }, + "recursive-readdir": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", + "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==", + "dev": true, + "requires": { + "minimatch": "3.0.4" + } + } + } + }, + "@svgr/core": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@svgr/core/-/core-2.2.0.tgz", + "integrity": "sha512-c7Nq4oXlze6YiXBb8E9NLfuZbNzI4QPjFnf4sigqFQST5NaFaWWOaaOu7yCxkZWFC7u995y0rwt+v26ghco9pQ==", + "dev": true, + "requires": { + "cosmiconfig": "^5.0.6", + "h2x-core": "^1.0.0", + "h2x-plugin-jsx": "^1.0.0", + "lodash": "^4.17.10", + "prettier": "^1.14.2", + "svgo": "^1.0.5" + }, + "dependencies": { + "coa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.1.tgz", + "integrity": "sha512-5wfTTO8E2/ja4jFSxePXlG5nRu5bBtL/r1HCIpJW/lzT6yDtKl0u0Z4o/Vpz32IpKmBn7HerheEZQgA9N2DarQ==", + "dev": true, + "requires": { + "q": "^1.1.2" + } + }, + "cosmiconfig": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz", + "integrity": "sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==", + "dev": true, + "requires": { + "is-directory": "^0.3.1", + "js-yaml": "^3.9.0", + "parse-json": "^4.0.0" + } + }, + "css-select": { + "version": "1.3.0-rc0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.3.0-rc0.tgz", + "integrity": "sha1-b5MZaqrnN2ZuoQNqjLFKj8t6kjE=", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "2.1", + "domutils": "1.5.1", + "nth-check": "^1.0.1" + } + }, + "csso": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/csso/-/csso-3.5.1.tgz", + "integrity": "sha512-vrqULLffYU1Q2tLdJvaCYbONStnfkfimRxXNaGjxMldI0C7JPBC4rB1RyjhfdZ4m1frm8pM9uRPKH3d2knZ8gg==", + "dev": true, + "requires": { + "css-tree": "1.0.0-alpha.29" + }, + "dependencies": { + "css-tree": { + "version": "1.0.0-alpha.29", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.29.tgz", + "integrity": "sha512-sRNb1XydwkW9IOci6iB2xmy8IGCj6r/fr+JWitvJ2JxQRPzN3T4AGGVWCMlVmVwM1gtgALJRmGIlWv5ppnGGkg==", + "dev": true, + "requires": { + "mdn-data": "~1.1.0", + "source-map": "^0.5.3" + } + } + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "svgo": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.0.5.tgz", + "integrity": "sha512-nYrifviB77aNKDNKKyuay3M9aYiK6Hv5gJVDdjj2ZXTQmI8WZc8+UPLR5IpVlktJfSu3co/4XcWgrgI6seGBPg==", + "dev": true, + "requires": { + "coa": "~2.0.1", + "colors": "~1.1.2", + "css-select": "~1.3.0-rc0", + "css-select-base-adapter": "~0.1.0", + "css-tree": "1.0.0-alpha25", + "css-url-regex": "^1.1.0", + "csso": "^3.5.0", + "js-yaml": "~3.10.0", + "mkdirp": "~0.5.1", + "object.values": "^1.0.4", + "sax": "~1.2.4", + "stable": "~0.1.6", + "unquote": "~1.1.1", + "util.promisify": "~1.0.0" + }, + "dependencies": { + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", + "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + } + } + } + } + }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -402,6 +580,12 @@ "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=" }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1479,6 +1663,12 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, + "browser-process-hrtime": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz", + "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=", + "dev": true + }, "browser-resolve": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", @@ -2325,6 +2515,12 @@ "nth-check": "~1.0.1" } }, + "css-select-base-adapter": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.0.tgz", + "integrity": "sha1-AQKz0UYw34bD65+p9UVicBBs+ZA=", + "dev": true + }, "css-selector-tokenizer": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.7.0.tgz", @@ -2347,6 +2543,30 @@ } } }, + "css-tree": { + "version": "1.0.0-alpha25", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha25.tgz", + "integrity": "sha512-XC6xLW/JqIGirnZuUWHXCHRaAjje2b3OIB0Vj5RIJo6mIi/AdJo30quQl5LxUl0gkXDIrTrFGbMlcZjyFplz1A==", + "dev": true, + "requires": { + "mdn-data": "^1.0.0", + "source-map": "^0.5.3" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "css-url-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/css-url-regex/-/css-url-regex-1.1.0.tgz", + "integrity": "sha1-g4NCMMyfdMRX3lnuvRVD/uuDt+w=", + "dev": true + }, "css-what": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", @@ -2507,6 +2727,39 @@ "assert-plus": "^1.0.0" } }, + "data-urls": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.0.0.tgz", + "integrity": "sha512-ai40PPQR0Fn1lD2PPie79CibnlMN2AYiDhwFX/rZHVsxbs5kNJSjegqXIprhouGXlRdEnfybva7kqRGnB6mypA==", + "dev": true, + "requires": { + "abab": "^1.0.4", + "whatwg-mimetype": "^2.0.0", + "whatwg-url": "^6.4.0" + }, + "dependencies": { + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "whatwg-url": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", + "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + } + } + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -2770,6 +3023,15 @@ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=" }, + "domexception": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", + "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", + "dev": true, + "requires": { + "webidl-conversions": "^4.0.2" + } + }, "domhandler": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.1.0.tgz", @@ -4579,6 +4841,152 @@ "duplexer": "^0.1.1" } }, + "h2x-core": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-core/-/h2x-core-1.0.0.tgz", + "integrity": "sha1-UTX9oahojryM4kUNifHcaDdRHns=", + "dev": true, + "requires": { + "h2x-generate": "^1.0.0", + "h2x-parse": "^1.0.0", + "h2x-traverse": "^1.0.0" + } + }, + "h2x-generate": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-generate/-/h2x-generate-1.0.0.tgz", + "integrity": "sha1-cugCDs7ePlifesq4HoWoNGzFQSY=", + "dev": true, + "requires": { + "h2x-traverse": "^1.0.0" + } + }, + "h2x-parse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-parse/-/h2x-parse-1.0.0.tgz", + "integrity": "sha1-PTd2QtbV9eP6mUDjYg8Rui0HLpk=", + "dev": true, + "requires": { + "h2x-types": "^1.0.0", + "jsdom": "^11.10.0" + }, + "dependencies": { + "abab": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", + "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==", + "dev": true + }, + "acorn-globals": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz", + "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", + "dev": true, + "requires": { + "acorn": "^5.0.0" + } + }, + "cssstyle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.0.0.tgz", + "integrity": "sha512-Bpuh47j2mRMY60X90mXaJAEtJwxvA2roZzbgwAXYhMbmwmakdRr4Cq9L5SkleKJNLOKqHIa2YWyOXDX3VgggSQ==", + "dev": true, + "requires": { + "cssom": "0.3.x" + } + }, + "jsdom": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.12.0.tgz", + "integrity": "sha512-y8Px43oyiBM13Zc1z780FrfNLJCXTL40EWlty/LXUtcjykRBNgLlCjWXpfSPBl2iv+N7koQN+dvqszHZgT/Fjw==", + "dev": true, + "requires": { + "abab": "^2.0.0", + "acorn": "^5.5.3", + "acorn-globals": "^4.1.0", + "array-equal": "^1.0.0", + "cssom": ">= 0.3.2 < 0.4.0", + "cssstyle": "^1.0.0", + "data-urls": "^1.0.0", + "domexception": "^1.0.1", + "escodegen": "^1.9.1", + "html-encoding-sniffer": "^1.0.2", + "left-pad": "^1.3.0", + "nwsapi": "^2.0.7", + "parse5": "4.0.0", + "pn": "^1.1.0", + "request": "^2.87.0", + "request-promise-native": "^1.0.5", + "sax": "^1.2.4", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.3.4", + "w3c-hr-time": "^1.0.1", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.3", + "whatwg-mimetype": "^2.1.0", + "whatwg-url": "^6.4.1", + "ws": "^5.2.0", + "xml-name-validator": "^3.0.0" + } + }, + "parse5": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", + "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==", + "dev": true + }, + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "whatwg-url": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", + "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", + "dev": true + } + } + }, + "h2x-plugin-jsx": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-plugin-jsx/-/h2x-plugin-jsx-1.0.0.tgz", + "integrity": "sha1-kwfMWNdb0kH2wlrvFSUB/aK99D0=", + "dev": true, + "requires": { + "h2x-types": "^1.0.0" + } + }, + "h2x-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-traverse/-/h2x-traverse-1.0.0.tgz", + "integrity": "sha1-b2UdQfFOO0Ni6iqQkhOkNRGYLeE=", + "dev": true, + "requires": { + "h2x-types": "^1.0.0" + } + }, + "h2x-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/h2x-types/-/h2x-types-1.0.0.tgz", + "integrity": "sha1-SCKBb/3fUeSjg6oAWUdw6M4jDR8=", + "dev": true + }, "handle-thing": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz", @@ -6308,6 +6716,12 @@ "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==" }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -6419,6 +6833,12 @@ "invert-kv": "^1.0.0" } }, + "left-pad": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", + "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", + "dev": true + }, "leven": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", @@ -6560,6 +6980,12 @@ "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=" }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", + "dev": true + }, "lodash.template": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", @@ -6698,6 +7124,12 @@ "inherits": "^2.0.1" } }, + "mdn-data": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", + "integrity": "sha512-FSYbp3lyKjyj3E7fMl6rYvUdX0FBXaluGqlFoYESWQlyUTq8R+wp0rkFxoYFqZlHCvsUXGjyJmLQSnXToYhOSA==", + "dev": true + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -7070,6 +7502,12 @@ "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz", "integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ==" }, + "nwsapi": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", + "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "dev": true + }, "oauth-sign": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", @@ -7150,6 +7588,16 @@ "has": "^1.0.1" } }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -7167,6 +7615,18 @@ "isobject": "^3.0.1" } }, + "object.values": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.0.4.tgz", + "integrity": "sha1-5STaCbT2b/Bd9FdUbscqyZ8TBpo=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.6.1", + "function-bind": "^1.1.0", + "has": "^1.0.1" + } + }, "obuf": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", @@ -7269,6 +7729,17 @@ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, + "output-file-sync": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-2.0.1.tgz", + "integrity": "sha512-mDho4qm7WgIXIGf4eYU1RHN2UU5tPfVYVSRwDJw0uTmj35DQUt/eNp19N7v6T3SrR0ESTEf2up2CGO73qI35zQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "is-plain-obj": "^1.1.0", + "mkdirp": "^0.5.1" + } + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -7483,6 +7954,12 @@ "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" }, + "pn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", + "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==", + "dev": true + }, "popper.js": { "version": "1.14.3", "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.3.tgz", @@ -8669,6 +9146,12 @@ "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=" }, + "prettier": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.2.tgz", + "integrity": "sha512-McHPg0n1pIke+A/4VcaS2en+pTNjy4xF+Uuq86u/5dyDO59/TtFZtQ708QIRkEZ3qwKz3GVkVa6mpxK/CpB8Rg==", + "dev": true + }, "pretty-bytes": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz", @@ -8765,6 +9248,12 @@ "randombytes": "^2.0.1" } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", @@ -9667,6 +10156,26 @@ } } }, + "request-promise-core": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", + "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", + "dev": true, + "requires": { + "lodash": "^4.13.1" + } + }, + "request-promise-native": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz", + "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=", + "dev": true, + "requires": { + "request-promise-core": "1.1.1", + "stealthy-require": "^1.1.0", + "tough-cookie": ">=2.3.3" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -10324,6 +10833,12 @@ "tweetnacl": "~0.14.0" } }, + "stable": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", + "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", + "dev": true + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -10348,6 +10863,12 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true + }, "stream-browserify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", @@ -10864,6 +11385,12 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "unquote": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unquote/-/unquote-1.1.1.tgz", + "integrity": "sha1-j97XMk7G6IoP+LkF58CYzcCG1UQ=", + "dev": true + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -11015,6 +11542,16 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "util.promisify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", + "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "object.getownpropertydescriptors": "^2.0.3" + } + }, "utila": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", @@ -11072,6 +11609,15 @@ "indexof": "0.0.1" } }, + "w3c-hr-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", + "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "dev": true, + "requires": { + "browser-process-hrtime": "^0.1.2" + } + }, "walker": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", @@ -11548,6 +12094,12 @@ "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" }, + "whatwg-mimetype": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz", + "integrity": "sha512-FKxhYLytBQiUKjkYteN71fAUA3g6KpNXoho1isLiLSB3N1G4F35Q5vUxWfKFhBwi5IWF27VE6WxhrnnC+m0Mew==", + "dev": true + }, "whatwg-url": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-4.8.0.tgz", @@ -11660,6 +12212,15 @@ "signal-exit": "^3.0.2" } }, + "ws": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + }, "xdg-basedir": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", diff --git a/package.json b/package.json index 014f181..c61a304 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "eject": "react-scripts eject" }, "devDependencies": { + "@svgr/cli": "^2.2.0", "eslint": "^4.19.1", "eslint-config-airbnb": "^17.1.0", "eslint-plugin-import": "^2.14.0", diff --git a/public/resistor.svg b/public/resistor.svg new file mode 100644 index 0000000..37eb851 --- /dev/null +++ b/public/resistor.svg @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/Resistor/index.js b/src/components/Resistor/index.js index b04beec..9fad70f 100644 --- a/src/components/Resistor/index.js +++ b/src/components/Resistor/index.js @@ -6,7 +6,8 @@ import { FormGroup, Label, Input, - Button + Button, + FormFeedback } from 'reactstrap'; import Result from './result' @@ -19,7 +20,11 @@ class Resistor extends Component { this.state = { powerSource: 12, powerLed: 3.3, - ledConsumption: 200, + ledConsumption: 20, + + powerSourceError: false, + powerLedError: false, + ledConsumptionError: false, showResult: false, @@ -52,24 +57,136 @@ class Resistor extends Component { 9.10 ] }, - factors: [ //À factoriser via un for 0 -> 12 - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000, - 10000000000, - 100000000000, - 1000000000000 + factors: [ + { + factor: 0.01, + colorLabel: 'Argent', + color: '#ccc', + factorLabel: 'x0.01' + }, + { + factor: 0.1, + colorLabel: 'or', + color: '#cd9932', + factorLabel: 'x0.1' + }, + { + factor: 1, + colorLabel: 'noir', + color: '#000', + factorLabel: 'x1' + }, + { + factor: 10, + colorLabel: 'marron', + color: '#663331', + factorLabel: 'x10' + }, + { + factor: 100, + colorLabel: 'rouge', + color: '#fd0000', + factorLabel: 'x100' + }, + { + factor: 1000, + colorLabel: 'orange', + color: '#ff6600', + factorLabel: 'x1 k' + }, + { + factor: 10000, + colorLabel: 'jaune', + color: '#ffff00', + factorLabel: 'x10 k' + }, + { + factor: 100000, + colorLabel: 'vert', + color: '#33cb33', + factorLabel: 'x100 k' + }, + { + factor: 1000000, + colorLabel: 'bleu', + color: '#6666ff', + factorLabel: 'x1 M' + }, + { + factor: 10000000, + colorLabel: 'violet', + color: '#cd66ff', + factorLabel: 'x10 M' + }, + { + factor: 100000000, + colorLabel: 'gris', + color: '#939393', + factorLabel: 'x100 M' + }, + { + factor: 1000000000, + colorLabel: 'blanc', + color: '#fff', + factorLabel: 'x1 G' + }, + ], + byColor: [ + { + colorLabel: 'black', + color: '#000', + value: 0 + }, + { + colorLabel: 'brown', + color: '#663331', + value: 1 + }, + { + colorLabel: 'red', + color: '#fd0000', + value: 2 + }, + { + colorLabel: 'orange', + color: '#ff6600', + value: 3 + }, + { + colorLabel: 'yellow', + color: '#ffff00', + value: 4 + }, + { + colorLabel: 'green', + color: '#33cb33', + value: 5 + }, + { + colorLabel: 'blue', + color: '#6666ff', + value: 6 + }, + { + colorLabel: 'violet', + color: '#cd66ff', + value: 7 + }, + { + colorLabel: 'grey', + color: '#939393', + value: 8 + }, + { + colorLabel: 'white', + color: '#fff', + value: 9 + }, ] } this.handleChange = this.handleChange.bind(this); + this.checkForm = this.checkForm.bind(this); this.submit = this.submit.bind(this); } @@ -84,9 +201,50 @@ class Resistor extends Component { }); } - submit() { + checkForm() { + let isOk = true; + let powerSourceError = false; + let powerLedError = false; + let ledConsumptionError = false; + + if ( this.state.powerSource <= 0 ) + { + powerSourceError = true; + } + + if ( this.state.powerLed <= 0 || this.state.powerLed > this.state.powerSource ) + { + powerLedError = true; + } + + if ( this.state.ledConsumption <= 0 ) + { + ledConsumptionError = true; + } + + if ( powerSourceError === true + || powerLedError === true + || ledConsumptionError === true + ){ + isOk = false; + } + this.setState({ - showResult: true + powerSourceError, + powerLedError, + ledConsumptionError + }) + + return isOk; + } + + submit() { + let showResult = this.checkForm(); + + console.log(showResult); + + this.setState({ + showResult }) } @@ -95,70 +253,92 @@ class Resistor extends Component {

Calcul de la valeur d'une résistance

- - - - - + + + + + + + {this.state.powerSourceError ? + (Vous devez saisir un nombre positif) + : (null) + } + + + + + + + + + {this.state.powerLedError ? + (Vous devez saisir un nombre positif et inférieur à votre alimentation) + : (null) + } + + + + + + + + + {this.state.ledConsumptionError ? + (Vous devez saisir un nombre positif) + : (null) + } + + + + + + + + + + + { + this.state.showResult ? + + : + (null) + } - - - - - - - - - - - - - - - - - - - - - - { - this.state.showResult ? - - : - (null) - }
); } diff --git a/src/components/Resistor/resistor.js b/src/components/Resistor/resistor.js new file mode 100644 index 0000000..fa9f6cd --- /dev/null +++ b/src/components/Resistor/resistor.js @@ -0,0 +1,50 @@ +import React from 'react'; + +const Resistor = props => ( + + + + + + + + + +); + +export default Resistor; diff --git a/src/components/Resistor/result.js b/src/components/Resistor/result.js index f9ed433..4316be3 100644 --- a/src/components/Resistor/result.js +++ b/src/components/Resistor/result.js @@ -2,7 +2,10 @@ import React, { Component } from 'react'; import { Row, Col, + ListGroup, + ListGroupItem } from 'reactstrap'; +import Resistor from './resistor'; class Result extends Component { state = {}; @@ -11,45 +14,110 @@ class Result extends Component { super(props); this.state = { + series: this.props.series, + factors: this.props.factors, powerSource: this.props.powerSource, powerLed: this.props.powerLed, ledConsumption: this.props.ledConsumption, + colors: this.props.colors, perfectMatch: null, - overR: null, - underR: null, - series: this.props.series, - factors: this.props.factors - }; + // First resistor before the perfect value + underR: null, + underRColors: [ + 'red', + 'red' + ], + underRRingTwo: { + color: 'red' + }, + underRFactor: null, + + // First resistor after the perfect value + overR: null, + overRRingOne: { + color: 'red' + }, + overRRingTwo: { + color: 'red' + }, + overRFactor: null, + }; } componentDidMount = () => { const perfectMatch = Math.round( 1000 * ((this.state.powerSource - this.state.powerLed ) / ( this.props.ledConsumption/1000))) / 1000; let overR = null; - let beforeR = null; + let underR = null; + let underRFactor = null; + let overRFactor = null; + let underRColors = []; + let overRColors = []; - for( let iFactor = 0 ; iFactor < this.state.factors.length ; iFactor += 1 ) { - const factor = this.state.factors[iFactor]; - for( let iSerie = 0 ; iSerie < this.state.series.e24.length ; iSerie += 1 ) { - const currentR = this.state.series.e24[iSerie] * factor; + if ( perfectMatch > 0 ) + { + for( let iFactor = 0 ; iFactor < this.state.factors.length ; iFactor += 1 ) { + const factorDetails = this.state.factors[iFactor]; + const factor = factorDetails.factor; + for( let iSerie = 0 ; iSerie < this.state.series.e24.length ; iSerie += 1 ) { + const currentR = this.state.series.e24[iSerie] * factor; - if ( currentR > perfectMatch ) { - overR = currentR; - console.log( overR); + if ( currentR >= perfectMatch ) { + overR = currentR; + overRFactor = factorDetails; + break; + } + + underR = currentR; + } + underRFactor = factorDetails; + + if ( overR) + { break; } - - beforeR = currentR; } - if ( overR) - { - break; + + if ( overR === perfectMatch ){ + underR = null; + overR = null; + underRFactor = null; + overRFactor = null; } } - this.setState({perfectMatch, overR, underR: beforeR}); + // Extract colors from resistors + if ( underR ) { + for ( let i = 0 ; i < 2 ; i += 1) { + for ( let j = 0 ; j < this.state.colors.length ; j += 1) { + if ( this.state.colors[j].value === Number(underR.toString()[i]) ) { + underRColors[i] = this.state.colors[j].color; + break; + } + } + } + } + if ( overR ) { + for ( let i = 0 ; i < 2 ; i += 1) { + for ( let j = 0 ; j < this.state.colors.length ; j += 1) { + if ( this.state.colors[j].value === Number(overR.toString()[i]) ) { + overRColors[i] = this.state.colors[j].color; + break; + } + } + } + } + this.setState({ + perfectMatch, + overR, + overRFactor, + underR, + underRFactor, + underRColors, + overRColors + }); } render() { @@ -58,9 +126,49 @@ class Result extends Component { Vous devez mettre une résistance de {this.state.perfectMatch}Ω. - - Les 2 résistances standard les plus proches sont {this.state.underR}Ω et {this.state.overR}Ω. - + { this.state.overR ? + ( + + Cette résistance n'existant pas dans la série e24 vous pouvez opter pour l'une des résistances suivante : + + {this.state.underR ? + ( + + + + {this.state.underR}Ω + {' '} + ({this.state.underR / this.state.underRFactor.factor} {this.state.underRFactor.factorLabel}Ω) + + + + + + + ) + : (null) + } + {this.state.overR ? + ( + + + + {this.state.overR}Ω + {' '} + ({this.state.overR / this.state.overRFactor.factor} {this.state.overRFactor.factorLabel}Ω) + + + + + + + ) + : (null) + } + + + ) : (null) + } ) }