ngx-color 7.3.1 → 7.3.2
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.
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/circle/package.json +1 -1
- package/package.json +7 -7
- package/swatches/package.json +1 -1
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) Scott Cooper
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<img src="https://raw.githubusercontent.com/scttcper/ngx-color/master/misc/sketch-example.png" width="225" alt="Angular color sketch preview">
|
3
|
+
<br>
|
4
|
+
<h1>Angular Color</h1>
|
5
|
+
<br>
|
6
|
+
<a href="https://www.npmjs.org/package/ngx-color">
|
7
|
+
<img src="https://badge.fury.io/js/ngx-color.svg" alt="npm">
|
8
|
+
</a>
|
9
|
+
<a href="https://circleci.com/gh/scttcper/ngx-color">
|
10
|
+
<img src="https://circleci.com/gh/scttcper/ngx-color.svg?style=svg" alt="circleci"></a>
|
11
|
+
<a href="https://codecov.io/github/scttcper/ngx-color">
|
12
|
+
<img src="https://img.shields.io/codecov/c/github/scttcper/ngx-color.svg" alt="codecov">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<br>
|
17
|
+
<br>
|
18
|
+
|
19
|
+
DEMO: https://ngx-color.vercel.app
|
20
|
+
|
21
|
+
- [Component API](#component-api)
|
22
|
+
- [Color](#color)
|
23
|
+
- [onChange](#onchange)
|
24
|
+
- [onChangeComplete](#onchangecomplete)
|
25
|
+
- [Individual APIs](#individual-apis)
|
26
|
+
- [Alpha](#alpha)
|
27
|
+
- [Block](#block)
|
28
|
+
- [Chrome](#chrome)
|
29
|
+
- [Circle](#circle)
|
30
|
+
- [Compact](#compact)
|
31
|
+
- [Github](#github)
|
32
|
+
- [Hue](#hue)
|
33
|
+
- [Material](#material)
|
34
|
+
- [Photoshop](#photoshop)
|
35
|
+
- [Sketch](#sketch)
|
36
|
+
- [Slider](#slider)
|
37
|
+
- [Swatches](#swatches)
|
38
|
+
- [Twitter](#twitter)
|
39
|
+
- [Shade](#shade)
|
40
|
+
|
41
|
+
## About
|
42
|
+
|
43
|
+
- **13 Different Pickers** - Sketch, Photoshop, Chrome, Twitter and many more
|
44
|
+
|
45
|
+
- **Make Your Own** - Use the building block components to make your own
|
46
|
+
|
47
|
+
- This is a port of [react-color](https://github.com/casesandberg/react-color)
|
48
|
+
by casesandberg
|
49
|
+
|
50
|
+
## Getting Started
|
51
|
+
|
52
|
+
## Dependencies
|
53
|
+
|
54
|
+
Latest version available for each version of Angular
|
55
|
+
|
56
|
+
| ngx-color | Angular |
|
57
|
+
| --------- | --------- |
|
58
|
+
| 3.0.3 | 6.x 7.x |
|
59
|
+
| 4.1.1 | 8.x |
|
60
|
+
| 5.1.4 | 9.x |
|
61
|
+
| 6.2.0 | 10.x 11.x |
|
62
|
+
| current | >= 12.x |
|
63
|
+
|
64
|
+
### Install
|
65
|
+
|
66
|
+
```sh
|
67
|
+
npm install ngx-color --save
|
68
|
+
```
|
69
|
+
|
70
|
+
### Include Component
|
71
|
+
|
72
|
+
##### import
|
73
|
+
|
74
|
+
```ts
|
75
|
+
import { ColorSketchModule } from 'ngx-color/sketch';
|
76
|
+
|
77
|
+
@NgModule({
|
78
|
+
imports: [
|
79
|
+
ColorSketchModule, // added to imports
|
80
|
+
],
|
81
|
+
})
|
82
|
+
class YourModule {}
|
83
|
+
```
|
84
|
+
|
85
|
+
##### use
|
86
|
+
|
87
|
+
```html
|
88
|
+
<color-sketch [color]="state" (onChangeComplete)="changeComplete($event)"></color-sketch>
|
89
|
+
```
|
90
|
+
|
91
|
+
### Others available
|
92
|
+
|
93
|
+
```ts
|
94
|
+
import { ColorAlphaModule } from 'ngx-color/alpha'; // <color-alpha-picker></color-alpha-picker>
|
95
|
+
import { ColorBlockModule } from 'ngx-color/block'; // <color-block></color-block>
|
96
|
+
import { ColorChromeModule } from 'ngx-color/chrome'; // <color-chrome></color-chrome>
|
97
|
+
import { ColorCircleModule } from 'ngx-color/circle'; // <color-circle></color-circle>
|
98
|
+
import { ColorCompactModule } from 'ngx-color/compact'; // <color-compact></color-compact>
|
99
|
+
import { ColorGithubModule } from 'ngx-color/github'; // <color-github></color-github>
|
100
|
+
import { ColorHueModule } from 'ngx-color/hue'; // <color-hue-picker></color-hue-picker>
|
101
|
+
import { ColorMaterialModule } from 'ngx-color/material'; // <color-material></color-material>
|
102
|
+
import { ColorPhotoshopModule } from 'ngx-color/photoshop'; // <color-photoshop></color-photoshop>
|
103
|
+
import { ColorSketchModule } from 'ngx-color/sketch'; // <color-sketch></color-sketch>
|
104
|
+
import { ColorSliderModule } from 'ngx-color/slider'; // <color-slider></color-slider>
|
105
|
+
import { ColorSwatchesModule } from 'ngx-color/swatches'; // <color-swatches></color-swatches>
|
106
|
+
import { ColorTwitterModule } from 'ngx-color/twitter'; // <color-twitter></color-twitter>
|
107
|
+
import { ColorShadeModule } from 'ngx-color/shade'; // <color-shade-picker></color-shade-picker>
|
108
|
+
```
|
109
|
+
|
110
|
+
# Component API
|
111
|
+
|
112
|
+
## Color
|
113
|
+
|
114
|
+
Color controls what color is active on the color picker. You can use this to
|
115
|
+
initialize the color picker with a particular color, or to keep it in sync with
|
116
|
+
the state of a parent component.
|
117
|
+
|
118
|
+
Color accepts either a string of a hex color `'#333'` or a object of rgb or hsl
|
119
|
+
values `{ r: 51, g: 51, b: 51 }` or `{ h: 0, s: 0, l: .10 }`. Both rgb and hsl
|
120
|
+
will also take a `a: 1` value for alpha. You can also use `transparent`.
|
121
|
+
|
122
|
+
```html
|
123
|
+
<color-sketch color="#fff" (onChangeComplete)="handleChangeComplete($event)"></color-sketch>
|
124
|
+
```
|
125
|
+
|
126
|
+
In this case, the color picker will initialize with the color `#fff`. When the
|
127
|
+
color is changed, `handleChangeComplete` will fire and set the new color to
|
128
|
+
state.
|
129
|
+
|
130
|
+
## onChange
|
131
|
+
|
132
|
+
Pass a function to call every time the color is changed. Use this to store the
|
133
|
+
color in the state of a parent component or to make other transformations.
|
134
|
+
|
135
|
+
Keep in mind this is called on drag events that can happen quite frequently. If
|
136
|
+
you just need to get the color once use `onChangeComplete`.
|
137
|
+
|
138
|
+
```ts
|
139
|
+
import { Component } from '@angular/core';
|
140
|
+
import { ColorEvent } from 'ngx-color';
|
141
|
+
|
142
|
+
@Component({
|
143
|
+
selector: 'selector-name',
|
144
|
+
template: ` <color-sketch (onChange)="handleChange($event)"></color-sketch> `,
|
145
|
+
})
|
146
|
+
export class NameComponent {
|
147
|
+
constructor() {}
|
148
|
+
|
149
|
+
handleChange($event: ColorEvent) {
|
150
|
+
console.log($event.color);
|
151
|
+
// color = {
|
152
|
+
// hex: '#333',
|
153
|
+
// rgb: {
|
154
|
+
// r: 51,
|
155
|
+
// g: 51,
|
156
|
+
// b: 51,
|
157
|
+
// a: 1,
|
158
|
+
// },
|
159
|
+
// hsl: {
|
160
|
+
// h: 0,
|
161
|
+
// s: 0,
|
162
|
+
// l: .20,
|
163
|
+
// a: 1,
|
164
|
+
// },
|
165
|
+
// }
|
166
|
+
}
|
167
|
+
}
|
168
|
+
```
|
169
|
+
|
170
|
+
## onChangeComplete
|
171
|
+
|
172
|
+
Pass a function to call once a color change is complete.
|
173
|
+
|
174
|
+
## Individual APIs
|
175
|
+
|
176
|
+
Some pickers have specific APIs that are unique to themselves:
|
177
|
+
|
178
|
+
### Alpha
|
179
|
+
|
180
|
+
- **width** - String | Number, Pixel value for picker width. Default `316px`
|
181
|
+
- **height** - String | Number, Pixel value for picker height. Default `16px`
|
182
|
+
- **direction** - String, `horizontal` or `vertical`. Default `horizontal`
|
183
|
+
|
184
|
+
### Block
|
185
|
+
|
186
|
+
- **width** - string | number, Pixel value for picker width. Default `170px`
|
187
|
+
- **colors** - Array of Strings, Color squares to display. Default `['#D9E3F0', '#F47373', '#697689', '#37D67A', '#2CCCE4', '#555555', '#dce775', '#ff8a65', '#ba68c8']`
|
188
|
+
- **triangle** - String, Either `hide` or `top`. Default `top`
|
189
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
190
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
191
|
+
|
192
|
+
### Chrome
|
193
|
+
|
194
|
+
- **disableAlpha** - Bool, Remove alpha slider and options from picker. Default
|
195
|
+
`false`
|
196
|
+
|
197
|
+
### Circle
|
198
|
+
|
199
|
+
- **width** - String | number, Pixel value for picker width. Default `252px`
|
200
|
+
- **colors** - Array of Strings, Color squares to display. Default `["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#cddc39", "#ffeb3b", "#ffc107", "#ff9800", "#ff5722", "#795548", "#607d8b"]`
|
201
|
+
- **circleSize** - Number, Value for circle size. Default `28`
|
202
|
+
- **circleSpacing** - Number, Value for spacing between circles. Default `14`
|
203
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
204
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
205
|
+
|
206
|
+
### Compact
|
207
|
+
|
208
|
+
- **colors** - Array of Strings, Color squares to display. Default `['#4D4D4D', '#999999', '#FFFFFF', '#F44E3B', '#FE9200', '#FCDC00', '#DBDF00', '#A4DD00', '#68CCCA', '#73D8FF', '#AEA1FF', '#FDA1FF', '#333333', '#808080', '#cccccc', '#D33115', '#E27300', '#FCC400', '#B0BC00', '#68BC00', '#16A5A5', '#009CE0', '#7B64FF', '#FA28FF', '#000000', '#666666', '#B3B3B3', '#9F0500', '#C45100', '#FB9E00', '#808900', '#194D33', '#0C797D', '#0062B1', '#653294', '#AB149E']`
|
209
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
210
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
211
|
+
|
212
|
+
### Github
|
213
|
+
|
214
|
+
- **width** - string | number, Pixel value for picker width. Default `212px`
|
215
|
+
- **colors** - Array of Strings, Color squares to display. Default `['#B80000', '#DB3E00', '#FCCB00', '#008B02', '#006B76', '#1273DE', '#004DCF', '#5300EB', '#EB9694', '#FAD0C3', '#FEF3BD', '#C1E1C5', '#BEDADC', '#C4DEF6', '#BED3F3', '#D4C4FB']`
|
216
|
+
- **triangle** - String, Either `hide`, `top-left` or `top-right`. Default
|
217
|
+
`top-left`
|
218
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
219
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
220
|
+
|
221
|
+
### Hue
|
222
|
+
|
223
|
+
- **width** - string | number, Pixel value for picker width. Default `316px`
|
224
|
+
- **height** - string | number, Pixel value for picker height. Default `16px`
|
225
|
+
- **direction** - String Enum, `horizontal` or `vertical`. Default `horizontal`
|
226
|
+
|
227
|
+
### Material
|
228
|
+
|
229
|
+
None
|
230
|
+
|
231
|
+
### Photoshop
|
232
|
+
|
233
|
+
- **header** - String, Title text. Default `Color Picker`
|
234
|
+
- **onAccept** - (Output), Callback for when accept is clicked.
|
235
|
+
- **onCancel** - (Output), Callback for when cancel is clicked.
|
236
|
+
|
237
|
+
### Sketch
|
238
|
+
|
239
|
+
- **disableAlpha** - Bool, Remove alpha slider and options from picker. Default
|
240
|
+
`false`
|
241
|
+
- **presetColors** - Array of Strings or Objects, Hex strings for default colors
|
242
|
+
at bottom of picker. Default `['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF']`
|
243
|
+
> **presetColors** may also be described as an array of objects with `color`
|
244
|
+
> and `title` properties: `[{ color: '#f00', title: 'red' }]` or a combination
|
245
|
+
> of both
|
246
|
+
- **width** - Number, Width of picker. Default `200`
|
247
|
+
- **onSwatchHover** - An event handler for `onMouseOver` on the `<Swatch>`s
|
248
|
+
within this component. Gives the args `(color, event)`
|
249
|
+
|
250
|
+
### Slider
|
251
|
+
|
252
|
+
- **pointer** - React Component, Custom pointer component
|
253
|
+
|
254
|
+
### Swatches
|
255
|
+
|
256
|
+
- **width** - string | number, Pixel value for picker width. Default `320`
|
257
|
+
- **height** - string | number, Pixel value for picker height. Default `240`
|
258
|
+
- **colors** - Array of Arrays of Strings, An array of color groups, each with
|
259
|
+
an array of colors
|
260
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
261
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
262
|
+
|
263
|
+
### Twitter
|
264
|
+
|
265
|
+
- **width** - string | number, Pixel value for picker width. Default `276px`
|
266
|
+
- **colors** - Array of Strings, Color squares to display. Default `['#FF6900', '#FCB900', '#7BDCB5', '#00D084', '#8ED1FC', '#0693E3', '#ABB8C3', '#EB144C', '#F78DA7', '#9900EF']`
|
267
|
+
- **triangle** - String, Either `hide`, `top-left` or `top-right`. Default
|
268
|
+
`top-left`
|
269
|
+
- **onSwatchHover** - (Output) An event handler for `onMouseOver` on the
|
270
|
+
`<Swatch>`s within this component. Gives the args `(color, event)`
|
271
|
+
|
272
|
+
### Shade
|
273
|
+
|
274
|
+
- **width** - String | Number, Pixel value for picker width. Default `316px`
|
275
|
+
- **height** - String | Number, Pixel value for picker height. Default `16px`
|
276
|
+
|
277
|
+
---
|
278
|
+
|
279
|
+
> GitHub [@scttcper](https://github.com/scttcper) ·
|
280
|
+
> Twitter [@scttcper](https://twitter.com/scttcper)
|
package/circle/package.json
CHANGED
package/package.json
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "../../../node_modules/ng-packagr/package.schema.json",
|
3
3
|
"name": "ngx-color",
|
4
|
-
"version": "7.3.
|
4
|
+
"version": "7.3.2",
|
5
5
|
"description": "A Collection of Color Pickers from Sketch, Photoshop, Chrome & more",
|
6
|
+
"dependencies": {
|
7
|
+
"@ctrl/tinycolor": "^3.4.0",
|
8
|
+
"tslib": "^2.3.0"
|
9
|
+
},
|
6
10
|
"peerDependencies": {
|
7
11
|
"@angular/core": ">=12.0.0-0",
|
8
|
-
"@angular/common": ">=12.0.0-0"
|
9
|
-
"@ctrl/tinycolor": "^3.4.0"
|
12
|
+
"@angular/common": ">=12.0.0-0"
|
10
13
|
},
|
11
14
|
"homepage": "https://github.com/scttcper/ngx-color",
|
12
15
|
"repository": "scttcper/ngx-color",
|
@@ -154,8 +157,5 @@
|
|
154
157
|
"default": "./fesm2020/ngx-color-twitter.mjs"
|
155
158
|
}
|
156
159
|
},
|
157
|
-
"sideEffects": false
|
158
|
-
"dependencies": {
|
159
|
-
"tslib": "^2.3.0"
|
160
|
-
}
|
160
|
+
"sideEffects": false
|
161
161
|
}
|