@thednp/color-picker 1.0.1 → 2.0.0-alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.eslintrc.cjs +199 -0
  2. package/.lgtm.yml +9 -0
  3. package/.prettierrc.json +15 -0
  4. package/.stylelintrc.json +236 -0
  5. package/LICENSE +0 -0
  6. package/README.md +55 -72
  7. package/compile.js +48 -0
  8. package/cypress/e2e/color-palette.cy.ts +128 -0
  9. package/cypress/e2e/color-picker.cy.ts +920 -0
  10. package/cypress/fixtures/colorNamesFrench.js +3 -0
  11. package/cypress/fixtures/componentLabelsFrench.js +21 -0
  12. package/cypress/fixtures/format.js +3 -0
  13. package/cypress/fixtures/getCEMarkup.js +29 -0
  14. package/cypress/fixtures/getMarkup.js +28 -0
  15. package/cypress/fixtures/getRandomInt.js +6 -0
  16. package/cypress/fixtures/sampleWebcolors.js +18 -0
  17. package/cypress/fixtures/testSample.js +8 -0
  18. package/cypress/plugins/esbuild-istanbul.ts +50 -0
  19. package/cypress/plugins/tsCompile.ts +34 -0
  20. package/cypress/support/commands.ts +0 -0
  21. package/cypress/support/e2e.ts +21 -0
  22. package/cypress/test.html +23 -0
  23. package/cypress.config.ts +29 -0
  24. package/dist/css/color-picker.css +16 -40
  25. package/dist/css/color-picker.min.css +2 -2
  26. package/dist/css/color-picker.rtl.css +16 -40
  27. package/dist/css/color-picker.rtl.min.css +2 -2
  28. package/dist/js/color-picker.cjs +8 -0
  29. package/dist/js/color-picker.cjs.map +1 -0
  30. package/dist/js/color-picker.d.ts +278 -0
  31. package/dist/js/color-picker.js +5 -3570
  32. package/dist/js/color-picker.js.map +1 -0
  33. package/dist/js/color-picker.mjs +2631 -0
  34. package/dist/js/color-picker.mjs.map +1 -0
  35. package/dts.config.ts +15 -0
  36. package/package.json +64 -74
  37. package/src/scss/_variables.scss +0 -1
  38. package/src/scss/color-picker.rtl.scss +4 -0
  39. package/src/scss/color-picker.scss +80 -40
  40. package/src/ts/colorPalette.ts +89 -0
  41. package/src/{js/color-picker.js → ts/index.ts} +489 -486
  42. package/src/ts/interface/colorPickerLabels.ts +20 -0
  43. package/src/ts/interface/colorPickerOptions.ts +11 -0
  44. package/src/ts/interface/paletteOptions.ts +6 -0
  45. package/src/ts/util/colorNames.ts +21 -0
  46. package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
  47. package/src/ts/util/getColorControls.ts +90 -0
  48. package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
  49. package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
  50. package/src/ts/util/isValidJSON.ts +19 -0
  51. package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +57 -48
  52. package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
  53. package/tsconfig.json +29 -0
  54. package/vite.config.ts +34 -0
  55. package/dist/js/color-esm.js +0 -1164
  56. package/dist/js/color-esm.min.js +0 -2
  57. package/dist/js/color-palette-esm.js +0 -1235
  58. package/dist/js/color-palette-esm.min.js +0 -2
  59. package/dist/js/color-palette.js +0 -1243
  60. package/dist/js/color-palette.min.js +0 -2
  61. package/dist/js/color-picker-element-esm.js +0 -3718
  62. package/dist/js/color-picker-element-esm.min.js +0 -2
  63. package/dist/js/color-picker-element.js +0 -3726
  64. package/dist/js/color-picker-element.min.js +0 -2
  65. package/dist/js/color-picker-esm.js +0 -3565
  66. package/dist/js/color-picker-esm.min.js +0 -2
  67. package/dist/js/color-picker.min.js +0 -2
  68. package/dist/js/color.js +0 -1172
  69. package/dist/js/color.min.js +0 -2
  70. package/src/js/color-palette.js +0 -75
  71. package/src/js/color-picker-element.js +0 -107
  72. package/src/js/color.js +0 -1104
  73. package/src/js/index.js +0 -8
  74. package/src/js/util/colorNames.js +0 -6
  75. package/src/js/util/getColorControls.js +0 -103
  76. package/src/js/util/isValidJSON.js +0 -13
  77. package/src/js/util/nonColors.js +0 -5
  78. package/src/js/util/roundPart.js +0 -9
  79. package/src/js/util/setCSSProperties.js +0 -12
  80. package/src/js/util/tabindex.js +0 -3
  81. package/src/js/util/toggleCEAttr.js +0 -70
  82. package/src/js/util/version.js +0 -5
  83. package/src/js/version.js +0 -5
  84. package/types/cp.d.ts +0 -558
  85. package/types/index.d.ts +0 -44
  86. package/types/source/source.ts +0 -4
  87. package/types/source/types.d.ts +0 -92
package/.eslintrc.cjs ADDED
@@ -0,0 +1,199 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es6: true,
5
+ },
6
+ extends: ['plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking'],
7
+ parser: '@typescript-eslint/parser',
8
+ parserOptions: {
9
+ project: 'tsconfig.json',
10
+ sourceType: 'module',
11
+ },
12
+ plugins: [
13
+ 'eslint-plugin-jsdoc',
14
+ 'eslint-plugin-prefer-arrow',
15
+ // "eslint-plugin-react",
16
+ '@typescript-eslint',
17
+ 'prettier',
18
+ ],
19
+ root: true,
20
+ rules: {
21
+ 'prettier/prettier': 'error',
22
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
23
+ '@typescript-eslint/array-type': [
24
+ 'error',
25
+ {
26
+ default: 'array',
27
+ },
28
+ ],
29
+ '@typescript-eslint/ban-types': [
30
+ 'error',
31
+ {
32
+ types: {
33
+ Object: {
34
+ message: 'Avoid using the `Object` type. Did you mean `object`?',
35
+ },
36
+ Function: {
37
+ message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
38
+ },
39
+ Boolean: {
40
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
41
+ },
42
+ Number: {
43
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
44
+ },
45
+ String: {
46
+ message: 'Avoid using the `String` type. Did you mean `string`?',
47
+ },
48
+ Symbol: {
49
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
50
+ },
51
+ },
52
+ },
53
+ ],
54
+ '@typescript-eslint/unbound-method': 'off',
55
+ '@typescript-eslint/consistent-type-assertions': 'error',
56
+ '@typescript-eslint/dot-notation': 'error',
57
+ '@typescript-eslint/explicit-function-return-type': 'off',
58
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
59
+ '@typescript-eslint/indent': 'off',
60
+ '@typescript-eslint/member-delimiter-style': [
61
+ 'off',
62
+ {
63
+ multiline: {
64
+ delimiter: 'none',
65
+ requireLast: true,
66
+ },
67
+ singleline: {
68
+ delimiter: 'semi',
69
+ requireLast: false,
70
+ },
71
+ },
72
+ ],
73
+ '@typescript-eslint/naming-convention': 'off', // error
74
+ '@typescript-eslint/no-empty-function': 'error',
75
+ '@typescript-eslint/no-empty-interface': 'error',
76
+ '@typescript-eslint/no-explicit-any': 'off',
77
+ '@typescript-eslint/no-misused-new': 'error',
78
+ '@typescript-eslint/no-namespace': 'error',
79
+ '@typescript-eslint/no-parameter-properties': 'off',
80
+ '@typescript-eslint/no-shadow': [
81
+ 'error',
82
+ {
83
+ hoist: 'all',
84
+ },
85
+ ],
86
+ '@typescript-eslint/no-unused-expressions': 'error',
87
+ '@typescript-eslint/no-use-before-define': 'off',
88
+ '@typescript-eslint/no-var-requires': 'error',
89
+ '@typescript-eslint/prefer-for-of': 'error',
90
+ '@typescript-eslint/prefer-function-type': 'error',
91
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
92
+ '@typescript-eslint/quotes': 'off',
93
+ '@typescript-eslint/semi': ['off', null],
94
+ '@typescript-eslint/triple-slash-reference': [
95
+ 'error',
96
+ {
97
+ path: 'always',
98
+ types: 'prefer-import',
99
+ lib: 'always',
100
+ },
101
+ ],
102
+ '@typescript-eslint/type-annotation-spacing': 'off',
103
+ '@typescript-eslint/typedef': 'off',
104
+ '@typescript-eslint/unified-signatures': 'error',
105
+ 'arrow-parens': ['off', 'always'],
106
+ 'brace-style': ['off', 'off'],
107
+ 'comma-dangle': 'off',
108
+ complexity: 'off',
109
+ 'constructor-super': 'error',
110
+ 'dot-notation': 'off',
111
+ 'eol-last': 'off',
112
+ eqeqeq: ['error', 'smart'],
113
+ 'guard-for-in': 'error',
114
+ 'id-denylist': [
115
+ 'error',
116
+ 'any',
117
+ 'Number',
118
+ 'number',
119
+ 'String',
120
+ 'string',
121
+ 'Boolean',
122
+ 'boolean',
123
+ 'Undefined',
124
+ 'undefined',
125
+ ],
126
+ 'id-match': 'error',
127
+ indent: 'off',
128
+ 'jsdoc/check-alignment': 'error',
129
+ 'jsdoc/check-indentation': 'error',
130
+ // 'jsdoc/newline-after-description': 'error',
131
+ 'linebreak-style': 'off',
132
+ 'max-classes-per-file': ['error', 1],
133
+ 'max-len': 'off',
134
+ 'new-parens': 'off',
135
+ 'newline-per-chained-call': 'off',
136
+ 'no-bitwise': 'error',
137
+ 'no-caller': 'error',
138
+ 'no-cond-assign': 'error',
139
+ 'no-console': 'error',
140
+ 'no-debugger': 'error',
141
+ 'no-empty': 'error',
142
+ 'no-empty-function': 'off',
143
+ 'no-eval': 'error',
144
+ 'no-extra-semi': 'off',
145
+ 'no-fallthrough': 'off',
146
+ 'no-invalid-this': 'off',
147
+ 'no-irregular-whitespace': 'off',
148
+ 'no-multiple-empty-lines': 'off',
149
+ 'no-new-wrappers': 'error',
150
+ 'no-shadow': 'off',
151
+ 'no-throw-literal': 'error',
152
+ 'no-trailing-spaces': 'off',
153
+ 'no-undef-init': 'error',
154
+ 'no-underscore-dangle': 'off',
155
+ 'no-unsafe-finally': 'error',
156
+ 'no-unused-expressions': 'off',
157
+ 'no-unused-labels': 'error',
158
+ 'no-use-before-define': 'off',
159
+ 'no-var': 'error',
160
+ 'object-shorthand': 'error',
161
+ 'one-var': ['error', 'never'],
162
+ 'padded-blocks': [
163
+ 'off',
164
+ {
165
+ blocks: 'never',
166
+ },
167
+ {
168
+ allowSingleLineBlocks: true,
169
+ },
170
+ ],
171
+ 'prefer-arrow/prefer-arrow-functions': 'error',
172
+ 'prefer-const': 'error',
173
+ 'quote-props': 'off',
174
+ quotes: 'off',
175
+ radix: 'error',
176
+ // "react/jsx-curly-spacing": "off",
177
+ // "react/jsx-equals-spacing": "off",
178
+ // "react/jsx-tag-spacing": [
179
+ // "off",
180
+ // {
181
+ // "afterOpening": "allow",
182
+ // "closingSlash": "allow"
183
+ // }
184
+ // ],
185
+ // "react/jsx-wrap-multilines": "off",
186
+ semi: 'off',
187
+ 'space-before-function-paren': 'off',
188
+ 'space-in-parens': ['off', 'never'],
189
+ 'spaced-comment': [
190
+ 'error',
191
+ 'always',
192
+ {
193
+ markers: ['/'],
194
+ },
195
+ ],
196
+ 'use-isnan': 'error',
197
+ 'valid-typeof': 'off',
198
+ },
199
+ };
package/.lgtm.yml ADDED
@@ -0,0 +1,9 @@
1
+ extraction:
2
+ typescript:
3
+ index:
4
+ exclude:
5
+ - coverage
6
+ - cypress
7
+ - docs
8
+ - experiments
9
+ - node_modules
@@ -0,0 +1,15 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSpacing": true,
4
+ "endOfLine": "lf",
5
+ "bracketSameLine": false,
6
+ "jsxSingleQuote": false,
7
+ "printWidth": 120,
8
+ "proseWrap": "preserve",
9
+ "quoteProps": "as-needed",
10
+ "semi": true,
11
+ "singleQuote": true,
12
+ "tabWidth": 2,
13
+ "trailingComma": "all",
14
+ "useTabs": false
15
+ }
@@ -0,0 +1,236 @@
1
+ {
2
+ "plugins": [
3
+ "stylelint-scss",
4
+ "stylelint-order"
5
+ ],
6
+ "extends": ["stylelint-config-standard-scss"],
7
+ "rules": {
8
+ "color-named": "never",
9
+ "declaration-block-no-duplicate-properties": true,
10
+ "no-descending-specificity": null,
11
+ "color-function-notation": null,
12
+ "block-no-empty": true,
13
+ "color-hex-length": "short",
14
+ "color-no-invalid-hex": true,
15
+ "max-nesting-depth": 4,
16
+ "selector-max-compound-selectors": 5,
17
+ "order/properties-order": [
18
+ "position",
19
+ "top",
20
+ "right",
21
+ "bottom",
22
+ "left",
23
+ "z-index",
24
+ "box-sizing",
25
+ "display",
26
+ "flex",
27
+ "flex-align",
28
+ "flex-basis",
29
+ "flex-direction",
30
+ "flex-wrap",
31
+ "flex-flow",
32
+ "flex-grow",
33
+ "flex-order",
34
+ "flex-pack",
35
+ "align-items",
36
+ "align-self",
37
+ "justify-content",
38
+ "float",
39
+ "width",
40
+ "min-width",
41
+ "max-width",
42
+ "height",
43
+ "min-height",
44
+ "max-height",
45
+ "padding",
46
+ "padding-top",
47
+ "padding-right",
48
+ "padding-bottom",
49
+ "padding-left",
50
+ "margin",
51
+ "margin-top",
52
+ "margin-right",
53
+ "margin-bottom",
54
+ "margin-left",
55
+ "overflow",
56
+ "overflow-x",
57
+ "overflow-y",
58
+ "-webkit-overflow-scrolling",
59
+ "-ms-overflow-style",
60
+ "clip",
61
+ "clear",
62
+ "font",
63
+ "font-family",
64
+ "font-size",
65
+ "font-style",
66
+ "font-weight",
67
+ "font-variant",
68
+ "font-size-adjust",
69
+ "font-stretch",
70
+ "font-effect",
71
+ "font-emphasize",
72
+ "font-emphasize-position",
73
+ "font-emphasize-style",
74
+ "font-smooth",
75
+ "hyphens",
76
+ "line-height",
77
+ "color",
78
+ "text-align",
79
+ "text-align-last",
80
+ "text-emphasis",
81
+ "text-emphasis-color",
82
+ "text-emphasis-style",
83
+ "text-emphasis-position",
84
+ "text-decoration",
85
+ "text-indent",
86
+ "text-justify",
87
+ "text-outline",
88
+ "text-overflow",
89
+ "text-overflow-ellipsis",
90
+ "text-overflow-mode",
91
+ "text-shadow",
92
+ "text-transform",
93
+ "text-wrap",
94
+ "-webkit-text-size-adjust",
95
+ "-ms-text-size-adjust",
96
+ "letter-spacing",
97
+ "word-break",
98
+ "word-spacing",
99
+ "word-wrap",
100
+ "overflow-wrap",
101
+ "tab-size",
102
+ "white-space",
103
+ "vertical-align",
104
+ "list-style",
105
+ "list-style-position",
106
+ "list-style-type",
107
+ "list-style-image",
108
+ "pointer-events",
109
+ "touch-action",
110
+ "cursor",
111
+ "visibility",
112
+ "zoom",
113
+ "table-layout",
114
+ "empty-cells",
115
+ "caption-side",
116
+ "border-spacing",
117
+ "border-collapse",
118
+ "content",
119
+ "quotes",
120
+ "counter-reset",
121
+ "counter-increment",
122
+ "resize",
123
+ "user-select",
124
+ "nav-index",
125
+ "nav-up",
126
+ "nav-right",
127
+ "nav-down",
128
+ "nav-left",
129
+ "background",
130
+ "background-color",
131
+ "background-image",
132
+ "filter",
133
+ "background-repeat",
134
+ "background-attachment",
135
+ "background-position",
136
+ "background-position-x",
137
+ "background-position-y",
138
+ "background-clip",
139
+ "background-origin",
140
+ "background-size",
141
+ "border",
142
+ "border-color",
143
+ "border-style",
144
+ "border-width",
145
+ "border-top",
146
+ "border-top-color",
147
+ "border-top-style",
148
+ "border-top-width",
149
+ "border-right",
150
+ "border-right-color",
151
+ "border-right-style",
152
+ "border-right-width",
153
+ "border-bottom",
154
+ "border-bottom-color",
155
+ "border-bottom-style",
156
+ "border-bottom-width",
157
+ "border-left",
158
+ "border-left-color",
159
+ "border-left-style",
160
+ "border-left-width",
161
+ "border-radius",
162
+ "border-top-left-radius",
163
+ "border-top-right-radius",
164
+ "border-bottom-right-radius",
165
+ "border-bottom-left-radius",
166
+ "border-image",
167
+ "border-image-source",
168
+ "border-image-slice",
169
+ "border-image-width",
170
+ "border-image-outset",
171
+ "border-image-repeat",
172
+ "outline",
173
+ "outline-width",
174
+ "outline-style",
175
+ "outline-color",
176
+ "outline-offset",
177
+ "box-shadow",
178
+ "opacity",
179
+ "-ms-interpolation-mode",
180
+ "transition",
181
+ "transition-delay",
182
+ "transition-timing-function",
183
+ "transition-duration",
184
+ "transition-property",
185
+ "transform",
186
+ "transform-origin",
187
+ "animation",
188
+ "animation-name",
189
+ "animation-duration",
190
+ "animation-play-state",
191
+ "animation-timing-function",
192
+ "animation-delay",
193
+ "animation-iteration-count",
194
+ "animation-direction"
195
+ ],
196
+ "function-url-no-scheme-relative": true,
197
+ "function-url-quotes": "always",
198
+ "length-zero-no-unit": true,
199
+ "property-no-unknown": true,
200
+ "property-no-vendor-prefix": true,
201
+ "scss/dollar-variable-colon-space-before": "never",
202
+ "scss/selector-no-redundant-nesting-selector": true,
203
+ "shorthand-property-no-redundant-values": true,
204
+ "unit-allowed-list": [
205
+ "ch",
206
+ "em",
207
+ "ex",
208
+ "rem",
209
+ "cm",
210
+ "in",
211
+ "mm",
212
+ "pc",
213
+ "pt",
214
+ "px",
215
+ "q",
216
+ "vh",
217
+ "vw",
218
+ "vmin",
219
+ "vmax",
220
+ "fr",
221
+ "deg",
222
+ "grad",
223
+ "rad",
224
+ "turn",
225
+ "ms",
226
+ "s",
227
+ "Hz",
228
+ "kHz",
229
+ "dpi",
230
+ "dpcm",
231
+ "dppx",
232
+ "%"
233
+ ],
234
+ "value-no-vendor-prefix": true
235
+ }
236
+ }
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,42 +1,47 @@
1
1
  ## ColorPicker
2
+
2
3
  [![Coverage Status](https://coveralls.io/repos/github/thednp/color-picker/badge.svg)](https://coveralls.io/github/thednp/color-picker)
3
4
  [![ci](https://github.com/thednp/color-picker/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/color-picker/actions/workflows/ci.yml)
4
- [![NPM Version](https://img.shields.io/npm/v/@thednp/color-picker.svg)](https://www.npmjs.com/package/@thednp/color-picker)
5
- [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/color-picker.svg)](http://npm-stat.com/charts.html?package=@thednp/color-picker)
6
5
  [![jsDeliver](https://img.shields.io/jsdelivr/npm/hw/@thednp/color-picker)](https://www.jsdelivr.com/package/npm/@thednp/color-picker)
7
- ![cypress version](https://img.shields.io/badge/cypress-9.7.0-brightgreen)
8
- ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
6
+ [![NPM Version](https://img.shields.io/npm/v/@thednp/color-picker.svg)](https://www.npmjs.com/package/@thednp/color-picker)
7
+ [![typescript version](https://img.shields.io/badge/typescript-5.1.3-brightgreen)](https://www.typescriptlang.org/)
8
+ [![eslint version](https://img.shields.io/badge/eslint-8.42.0-brightgreen)](https://github.com/eslint)
9
+ [![prettier version](https://img.shields.io/badge/prettier-2.8.8-brightgreen)](https://prettier.io/)
10
+ [![cypress version](https://img.shields.io/badge/cypress-12.14.0-brightgreen)](https://cypress.io/)
11
+ [![vite version](https://img.shields.io/badge/vite-4.3.9-brightgreen)](https://github.com/vitejs)
9
12
 
10
- The feature rich **ColorPicker** component for the modern web built with TypeScript definitions, Cypress tested, WAI-ARIA compliant and lots of goodies. In addition, it features its own version of [TinyColor](https://github.com/bgrins/TinyColor) called simply `Color`.
13
+ The feature rich **ColorPicker** component for the modern web, sourced with TypeScript, Cypress tested, WAI-ARIA compliant and lots of goodies. In addition, it features its own version of [TinyColor](https://github.com/bgrins/TinyColor) called simply [Color](http://github.com/thednp/color).
11
14
 
12
15
  **ColorPicker** can use existing colour palettes or generate custom ones via DATA API configuration. If you want to play, check out [this codepen](https://codepen.io/thednp/pen/WNdRWPN) I've setup for you. Have fun!
13
16
 
14
17
  [![image](./docs/img/color-picker.png)](http://thednp.github.io/color-picker)
15
18
 
16
-
17
19
  ## Highlights
18
- * Accessibility Focus for WAI-ARIA compliance
19
- * ES6+ sources with TypeScript definitions
20
- * Framework agnostic and flexible design
21
- * Supporting HEX(a), RGB(a), HSL(a) and HWB, the last three also in CSS4 Color Module flavours
22
- * Supports keyboard and touch events
23
- * Automatic repositioning of the popup dropdown on show / window scroll
24
- * SCSS sources with minimal style required
25
- * Right To Left Languages Supported
26
- * light footprint, `10kb` in size when minified and gZipped
27
20
 
21
+ - Accessibility Focus for WAI-ARIA compliance
22
+ - TypeScript sourced code base
23
+ - Framework agnostic and flexible design
24
+ - Supporting HEX(a), RGB(a), HSL(a) and HWB, the last three also in CSS4 Color Module flavours
25
+ - Supports keyboard and touch events
26
+ - Automatic repositioning of the popup dropdown on show / window scroll
27
+ - SCSS sources with minimal style required
28
+ - Cypress tested
29
+ - Right To Left Languages Supported
30
+ - light footprint, `10kb` in size when minified and gZipped
28
31
 
29
32
  ## Wiki
33
+
30
34
  For an in depth guide on all things **ColorPicker**, check out the wiki pages:
31
- * [Home](https://github.com/thednp/color-picker/wiki) - the **ColorPicker** wiki home.
32
- * [NPM](https://github.com/thednp/color-picker/wiki/NPM) - quick installation guide.
33
- * [CDN Link](https://github.com/thednp/color-picker/wiki/CDN) - quick implementation guide.
34
- * [Usage](https://github.com/thednp/color-picker/wiki/Usage) - an in-depth browser usage.
35
- * [ES6+](https://github.com/thednp/color-picker/wiki/ES6) - your usual quick ES6+ guide.
36
- * [Node.js](https://github.com/thednp/color-picker/wiki/Node.js) - is this a thing?
37
35
 
36
+ - [Home](https://github.com/thednp/color-picker/wiki) - the **ColorPicker** wiki home.
37
+ - [NPM](https://github.com/thednp/color-picker/wiki/NPM) - quick installation guide.
38
+ - [CDN Link](https://github.com/thednp/color-picker/wiki/CDN) - quick implementation guide.
39
+ - [Usage](https://github.com/thednp/color-picker/wiki/Usage) - an in-depth browser usage.
40
+ - [ES6+](https://github.com/thednp/color-picker/wiki/ES6) - your usual quick ES6+ guide.
41
+ - [Node.js](https://github.com/thednp/color-picker/wiki/Node.js) - is this a thing?
38
42
 
39
43
  ## NPM
44
+
40
45
  You can install **ColorPicker** through NPM:
41
46
 
42
47
  ```
@@ -44,87 +49,65 @@ $ npm install @thednp/color-picker
44
49
  ```
45
50
 
46
51
  ## Browser Usage
52
+
47
53
  Download the [latest package](https://github.com/thednp/color-picker/archive/master.zip). unpack and inspect the contents. You need to copy the `color-picker.js` and `color-picker.css` or their minified variations to your app `assets` folders as follows.
48
54
  Link the required CSS in your document `<head>` tag
55
+
49
56
  ```html
50
- <link href="../assets/css/color-picker.css" rel="stylesheet">
57
+ <link href="../assets/css/color-picker.css" rel="stylesheet" />
51
58
  ```
52
59
 
53
- Link the required JS in your document `<body>` tag, though it should work in the `<head>` as well
60
+ Link the required JS in your document `<body>` tag, though it should work in the `<head>` as well
61
+
54
62
  ```html
55
63
  <script src="../assets/js/color-picker.js"></script>
56
64
  ```
57
- OR use the `ColorPickerElement` custom element:
58
- ```html
59
- <script src="../assets/js/color-picker-element.js"></script>
60
- ```
61
- OR use the `ColorPickerElement` custom element ESM module:
62
- ```html
63
- <script type="module" src="../assets/js/color-picker-element-esm.js"></script>
64
- ```
65
65
 
66
- If you don't want to use the custom element, you can initialize the function for your elements at the end of your `<body>` tag
66
+ Now you can initialize the function for your elements at the end of your `<body>` tag
67
+
67
68
  ```html
68
69
  <script>
69
- var myPicker = new ColorPicker('input.SELECTOR');
70
+ var myPicker = new ColorPicker('input.SELECTOR');
70
71
  </script>
71
72
  ```
72
73
 
73
74
  To use the DATA-API, you can provide for instance the `data-format="hex"`, and other specific attributes like so:
75
+
74
76
  ```html
75
77
  <label for="myPicker">Color Label</label>
76
78
  <div class="color-picker">
77
- <input id="myPicker" name="myPicker" data-function="color-picker" data-format="hex" data-color-presets="red,green,blue" class="color-preview" value="#069">
79
+ <input
80
+ id="myPicker"
81
+ name="myPicker"
82
+ data-function="color-picker"
83
+ data-format="hex"
84
+ data-color-presets="red,green,blue"
85
+ class="color-preview"
86
+ value="#069"
87
+ />
78
88
  </div>
79
89
  ```
80
- The `data-function="color-picker"` attribute is useful for mass initialization, [check this usage section of the wiki](https://github.com/thednp/color-picker/wiki/Usage#initialize-multiple-targets).
81
-
82
- Alternatively you can use the `ColorPickerElement` custom element, the `data-function="color-picker"` attribute is no longer required:
83
- ```html
84
- <label for="myPicker">Colour Field Label</label>
85
- <color-picker data-format="rgb" data-color-keywords="#069:default,#111:revert">
86
- <input id="myPicker" name="myPicker" class="color-preview" value="#069">
87
- </color-picker>
88
-
89
- <script type="module" src="../path-to/color-picker-element-esm.js"></script>
90
- ```
91
- As shown in the above example, all DATA API attributes for instance configuration are to be used on your **custom element**.
92
90
 
91
+ The `data-function="color-picker"` attribute is useful for mass initialization, [check this usage section of the wiki](https://github.com/thednp/color-picker/wiki/Usage#initialize-multiple-targets).
93
92
 
94
93
  ## Initialize INPUT
94
+
95
95
  ```javascript
96
96
  import ColorPicker from '@thednp/color-picker';
97
97
 
98
98
  const myPicker = new ColorPicker('#myPicker');
99
99
  ```
100
100
 
101
- ## Initialize Custom Element
102
- ```javascript
103
- import ColorPickerElement from '@thednp/color-picker/src/color-picker-element';
104
-
105
- // initialize the CustomElement
106
- const myPicker = new ColorPickerElement();
107
- // set DATA API
108
- myPicker.setAttribute('data-format', 'hsl');
109
- myPicker.setAttribute('data-id', 'ADD_YOUR_UNIQUE_ID');
110
- myPicker.setAttribute('data-value', 'rgb(150 0 150 / 0.8)');
111
- myPicker.setAttribute('data-label', 'Color Picker Element Label');
112
- myPicker.setAttribute('data-color-keywords', 'false');
113
-
114
- // append, connectedCallback() is triggered
115
- document.body.append(myPicker);
116
- ```
117
- Other configuration options apply, see [the API Guide](https://github.com/thednp/color-picker/wiki/API).
118
-
119
-
120
101
  ## Thanks
121
- * Dimitris Grammatikogiannis for his [initial project](https://codepen.io/dgrammatiko/pen/zLvXwR) as well as testing and contributions
122
- * Serhii Kulykov for his [Vanilla Colorful](https://github.com/web-padawan/vanilla-colorful)
123
- * Brian Grinstead for his [TinyColor](https://github.com/bgrins/TinyColor)
124
- * Jonathan Neal for his [convert-colors](https://github.com/jonathantneal/convert-colors)
125
- * Peter Dematté for his [colorPicker](http://www.dematte.at/colorPicker/)
126
- * Ștefan Petre at eyecon for his [colorPicker](https://www.eyecon.ro/colorpicker/)
127
- * Brian Teeman for his [patience](https://github.com/joomla/joomla-cms/pull/35639)
102
+
103
+ - Dimitris Grammatikogiannis for his [initial project](https://codepen.io/dgrammatiko/pen/zLvXwR) as well as testing and contributions
104
+ - Serhii Kulykov for his [Vanilla Colorful](https://github.com/web-padawan/vanilla-colorful)
105
+ - Brian Grinstead for his [TinyColor](https://github.com/bgrins/TinyColor)
106
+ - Jonathan Neal for his [convert-colors](https://github.com/jonathantneal/convert-colors)
107
+ - Peter Dematté for his [colorPicker](http://www.dematte.at/colorPicker/)
108
+ - Ștefan Petre at eyecon for his [colorPicker](https://www.eyecon.ro/colorpicker/)
109
+ - Brian Teeman for his [patience](https://github.com/joomla/joomla-cms/pull/35639)
128
110
 
129
111
  ## License
112
+
130
113
  **ColorPicker** is released under the [MIT License](https://github.com/thednp/color-picker/blob/master/LICENSE).