Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 00c3cc6

Browse files
Merge pull request #349 from deckgo/color-picker
feat: new "Color Picker" web component
2 parents e91f24b + 979738e commit 00c3cc6

File tree

43 files changed

+2022
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2022
-192
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<a name="1.0.0-rc.14"></a>
2+
# [1.0.0-rc.14](https://github.com/deckgo/deckdeckgo/compare/v1.0.0-rc.13...v1.0.0-14) (2019-09-XX)
3+
4+
5+
### Others
6+
7+
* utils: v1.0.0-rc.1-2 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/utils/CHANGELOG.md))
8+
19
<a name="1.0.0-rc.13"></a>
210
# [1.0.0-rc.13](https://github.com/deckgo/deckdeckgo/compare/v1.0.0-rc.12-3...v1.0.0-13) (2019-09-20)
311

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# Color Picker
2+
3+
The "Color Picker" component is a simple component to, guess what, allow your users to "pick colors" 😉
4+
5+
It is fully configurable in terms of colors, you could define the set of colors you rather like to offer and it also implements a "more" action which, if clicked, will open the platform standard color picker.
6+
7+
## Table of contents
8+
9+
- [Showcase](#app-components-color-showcase)
10+
- [Installation](#app-components-color-installation)
11+
- [Using from a CDN](#app-components-color-from-a-cdn)
12+
- [Install from NPM](#app-components-color-from-npm)
13+
- [Framework integration](#app-components-color-framework-integration)
14+
- [Usage](#app-components-color-usage)
15+
- [Slots](#app-components-color-slots)
16+
- [Attributes](#app-components-color-attributes)
17+
- [Theming](#app-components-color-theming)
18+
- [Methods](#app-components-color-methods)
19+
- [Trying it out](#app-components-color-trying-it-out)
20+
21+
## Showcase
22+
23+
<div>
24+
<deckgo-color>
25+
<span slot="more">...</span>
26+
</deckgo-color>
27+
</div>
28+
29+
## Installation
30+
31+
This component could be added to your web application using the following methods.
32+
33+
### Using from a CDN
34+
35+
It's recommended to use [unpkg](https://unpkg.com/) to use the [DeckDeckGo] lazy image component from a CDN. To do so, add the following include script in the main HTML file of your project:
36+
37+
```
38+
<script type="module" src="https://unpkg.com/@deckdeckgo/color@latest/dist/deckdeckgo-color/deckdeckgo-color.esm.js"></script>
39+
<script nomodule="" src="https://unpkg.com/@deckdeckgo/color@latest/dist/deckdeckgo-color/deckdeckgo-color.js"></script>
40+
```
41+
### Install from NPM
42+
43+
Install it in your project from [npm](https://www.npmjs.com/package/@deckdeckgo/qrcode) using the following command:
44+
45+
```bash
46+
npm install @deckdeckgo/color
47+
```
48+
49+
### Framework integration
50+
51+
The [Stencil documentation](https://stenciljs.com/docs/overview) provide examples of framework integration for [Angular](https://stenciljs.com/docs/angular), [React](https://stenciljs.com/docs/react), [Vue](https://stenciljs.com/docs/vue) and [Ember](https://stenciljs.com/docs/ember).
52+
53+
That being said, commonly, you might either `import` or `load` it:
54+
55+
#### Import
56+
57+
```
58+
import '@deckdeckgo/color';
59+
```
60+
61+
#### Loader
62+
63+
```
64+
import { defineCustomElements as deckDeckGoElement } from '@deckdeckgo/color/dist/loader';
65+
deckDeckGoElement(window);
66+
```
67+
68+
## Usage
69+
70+
The "Color Picker" Web Component could be integrated using the tag `<deckgo-color/>`.
71+
72+
```
73+
<deckgo-color>
74+
<span slot="more">...</span>
75+
</deckgo-color>
76+
```
77+
78+
### Slots
79+
80+
The slot `more` is optional, moreover, the "more" action itself could be turned off.
81+
82+
### Attributes
83+
84+
This component offers the following options which could be set using attributes:
85+
86+
| Property | Attribute | Description | Type | Default |
87+
| ---------- | ----------- | ----------- | --------------------- | ----------------- |
88+
| `colorHex` | `color-hex` | The current selected color provided as hexadecimal value. | `string` | `undefined` |
89+
| `more` | `more` | In case you would not like to offer the "more" options. | `boolean` | `true` |
90+
| `moreAlt` | `more-alt` | An accessibility label for the "more action. | `string` | `'More'` |
91+
| `palette` | | The palette of color (see here under). | `DeckdeckgoPalette[]` | `DEFAULT_PALETTE` |
92+
93+
#### Palette
94+
95+
The `palette` attribute is a complex object and therefore could only be set using Javascript.
96+
97+
It is defined as the following:
98+
99+
```
100+
export interface DeckdeckgoPaletteColor {
101+
hex: string;
102+
rgb?: string;
103+
}
104+
105+
export interface DeckdeckgoPalette {
106+
color: DeckdeckgoPaletteColor;
107+
alt?: string;
108+
}
109+
```
110+
111+
The key value is the color provided as `hex` value. The `rgb` value is use for presentation purpose, for the hover action and the highlight of the selected color.
112+
113+
The default palette is the following:
114+
115+
```
116+
export const DEFAULT_PALETTE: DeckdeckgoPalette[] = [
117+
{
118+
color: {
119+
hex: '#FF6900',
120+
rgb: '255,105,0'
121+
},
122+
alt: 'Orange'
123+
},
124+
{
125+
color: {
126+
hex: '#FCB900',
127+
rgb: '252,185,0'
128+
},
129+
alt: 'Yellow'
130+
},
131+
{
132+
color: {
133+
hex: '#7BDCB5',
134+
rgb: '123,220,181'
135+
},
136+
alt: 'Light green'
137+
},
138+
{
139+
color: {
140+
hex: '#00D084',
141+
rgb: '0,208,132'
142+
},
143+
alt: 'Green'
144+
},
145+
{
146+
color: {
147+
hex: '#8ED1FC',
148+
rgb: '142,209,252'
149+
},
150+
alt: 'Light blue'
151+
},
152+
{
153+
color: {
154+
hex: '#0693E3',
155+
rgb: '6,147,227'
156+
},
157+
alt: 'Blue'
158+
},
159+
{
160+
color: {
161+
hex: '#ABB8C3',
162+
rgb: '171,184,195'
163+
},
164+
alt: 'Grey'
165+
},
166+
{
167+
color: {
168+
hex: '#EB144C',
169+
rgb: '235,20,76'
170+
},
171+
alt: 'Red'
172+
},
173+
{
174+
color: {
175+
hex: '#F78DA7',
176+
rgb: '247,141,167'
177+
},
178+
alt: 'Pink'
179+
},
180+
{
181+
color: {
182+
hex: '#9900EF',
183+
rgb: '153,0,239'
184+
},
185+
alt: 'Violet'
186+
},
187+
{
188+
color: {
189+
hex: '#000000',
190+
rgb: '0,0,0'
191+
},
192+
alt: 'Black'
193+
}
194+
];
195+
```
196+
197+
### Theming
198+
199+
The following theming options will affect this component if set on its host or parent.
200+
201+
| CSS4 variable | Default | Note |
202+
| -------------------------- |-----------------|-----------------|
203+
| --deckgo-button-width | 28px | The width of a button to select a color and the more button |
204+
| --deckgo-button-height | 28px | The height of a button to select a color and the more button |
205+
| --deckgo-button-margin | 4px | The margin of a button to select a color and the more button |
206+
| --deckgo-button-outline | none | The outline of a button to select a color and the more button |
207+
| --deckgo-button-border | none | The border of a button to select a color and the more button |
208+
| --deckgo-button-border-radius | 50% | The border radius of a button to select a color |
209+
| --deckgo-button-more-border-radius | | The border radius of the more button |
210+
| --deckgo-button-more-border | | The border of the more button |
211+
212+
### Events
213+
214+
To listen to the selected color you have to subscribe to the following event:
215+
216+
| Event | Description | Type |
217+
| ------------- | ----------- | ------------------------------------- |
218+
| `colorChange` | Emit the selected color. | `CustomEvent<DeckdeckgoPaletteColor>` |
219+
220+
In case the platform color picker would be use by the user, the change will be triggered multiple times, as long as the user change its value in the platform picker.
221+
222+
For the definition of the type of the event, see above description of `DeckdeckgoPaletteColor`.
223+
224+
[DeckDeckGo]: https://deckdeckgo.com

docs/docs/components/app-components-lazy-img/app-components-lazy-img.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ An `<img/>` tag is per default use to display the image but optionally it could
99
## Table of contents
1010

1111
- [Installation](#app-components-lazy-img-installation)
12-
- [Using from a CDN](#app-components-from-a-cdn)
13-
- [Install from NPM](#app-components-from-npm)
12+
- [Using from a CDN](#app-components-lazy-img-from-a-cdn)
13+
- [Install from NPM](#app-components-lazy-img-from-npm)
1414
- [Framework integration](#app-components-lazy-img-framework-integration)
1515
- [Usage](#app-components-lazy-img-usage)
1616
- [Slots](#app-components-lazy-img-slots)

0 commit comments

Comments
 (0)