@umbraco-ui/uui-color-swatch 1.2.0-rc.0 → 1.2.0-rc.1

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/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2
2
  import { property } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
- import { LitElement, html, css } from 'lit';
4
+ import { LitElement, html, nothing, css } from 'lit';
5
5
  import { iconCheck } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
6
6
  import { styleMap } from 'lit/directives/style-map.js';
7
7
  import { LabelMixin, SelectableMixin, ActiveMixin } from '@umbraco-ui/uui-base/lib/mixins';
@@ -84,23 +84,35 @@ let UUIColorSwatchElement = class extends LabelMixin(
84
84
  }
85
85
  render() {
86
86
  return html`
87
- <div
88
- class=${classMap({
89
- "color-swatch": true,
90
- "color-swatch--transparent-bg": true,
91
- "color-swatch--light": this.isLight
92
- })}
93
- role="button"
87
+ <button
88
+ id="swatch"
94
89
  aria-label=${this.label}
95
- aria-disabled="${this.disabled}">
90
+ aria-disabled="${this.disabled}"
91
+ title="${this.label}">
96
92
  <div
97
- class="color-swatch__color"
98
- style=${styleMap({ backgroundColor: this.value })}></div>
99
- <div class="color-swatch__check">${iconCheck}</div>
100
- </div>
101
- ${this.showLabel ? this.renderLabel() : ""}
93
+ class=${classMap({
94
+ "color-swatch": true,
95
+ "color-swatch--transparent-bg": true,
96
+ "color-swatch--light": this.isLight,
97
+ "color-swatch--big": this.showLabel
98
+ })}>
99
+ <div
100
+ class="color-swatch__color"
101
+ style=${styleMap({ backgroundColor: this.value })}></div>
102
+ <div class="color-swatch__check">${iconCheck}</div>
103
+ </div>
104
+ ${this._renderWithLabel()}
105
+ </button>
102
106
  `;
103
107
  }
108
+ _renderWithLabel() {
109
+ if (!this.showLabel)
110
+ return nothing;
111
+ return html`<div class="color-swatch__label">
112
+ <strong>${this.renderLabel()}</strong>
113
+ ${this.value}
114
+ </div>`;
115
+ }
104
116
  };
105
117
  UUIColorSwatchElement.styles = [
106
118
  css`
@@ -125,14 +137,14 @@ UUIColorSwatchElement.styles = [
125
137
  outline: none;
126
138
  }
127
139
 
128
- :host(:focus:not([disabled])) .color-swatch {
140
+ :host(:focus:not([disabled])) #swatch {
129
141
  outline-color: var(--uui-color-focus,#3879ff);
130
142
  outline-width: var(--uui-swatch-border-width, 1px);
131
143
  outline-style: solid;
132
144
  outline-offset: var(--uui-swatch-border-width, 1px);
133
145
  }
134
146
 
135
- :host([selectable]) {
147
+ :host([selectable]) #swatch {
136
148
  cursor: pointer;
137
149
  }
138
150
 
@@ -140,7 +152,21 @@ UUIColorSwatchElement.styles = [
140
152
  cursor: not-allowed;
141
153
  }
142
154
 
143
- :host([selectable]) .color-swatch::after {
155
+ #swatch {
156
+ outline: none;
157
+ background: none;
158
+ border: none;
159
+ padding: 0;
160
+ margin: 0;
161
+ text-align: left;
162
+ border-radius: 3px;
163
+ }
164
+
165
+ :host(:not([selectable])) #swatch:focus {
166
+ outline: none;
167
+ }
168
+
169
+ :host([selectable]) #swatch::after {
144
170
  content: '';
145
171
  position: absolute;
146
172
  pointer-events: none;
@@ -156,13 +182,13 @@ UUIColorSwatchElement.styles = [
156
182
  transition: opacity 100ms ease-out;
157
183
  opacity: 0;
158
184
  }
159
- :host([selectable]:not([disabled]):hover) .color-swatch::after {
185
+ :host([selectable]:not([disabled]):hover) #swatch::after {
160
186
  opacity: 0.33;
161
187
  }
162
- :host([selectable][selected]:not([disabled]):hover) .color-swatch::after {
188
+ :host([selectable][selected]:not([disabled]):hover) #swatch::after {
163
189
  opacity: 0.66;
164
190
  }
165
- :host([selectable][selected]:not([disabled])) .color-swatch::after {
191
+ :host([selectable][selected]:not([disabled])) #swatch::after {
166
192
  opacity: 1;
167
193
  }
168
194
 
@@ -172,6 +198,7 @@ UUIColorSwatchElement.styles = [
172
198
  height: var(--uui-swatch-size, 25px);
173
199
  border-radius: 3px;
174
200
  display: flex;
201
+ flex-direction: column;
175
202
  justify-content: center;
176
203
  align-items: center;
177
204
  }
@@ -195,6 +222,10 @@ UUIColorSwatchElement.styles = [
195
222
  box-sizing: border-box;
196
223
  }
197
224
 
225
+ .color-swatch--big .color-swatch__color {
226
+ border-radius: 3px 3px 0 0;
227
+ }
228
+
198
229
  .color-swatch__check {
199
230
  position: absolute;
200
231
  vertical-align: middle;
@@ -219,6 +250,31 @@ UUIColorSwatchElement.styles = [
219
250
  .label {
220
251
  font-size: var(--uui-size-4,12px);
221
252
  }
253
+
254
+ .color-swatch--big {
255
+ width: 120px;
256
+ height: 50px;
257
+ }
258
+
259
+ .color-swatch__label {
260
+ max-width: 120px;
261
+ box-sizing: border-box;
262
+ padding: var(--uui-size-space-1,3px) var(--uui-size-space-2,6px);
263
+ line-height: 1.5;
264
+ display: flex;
265
+ flex-direction: column;
266
+ background: white;
267
+ border: 1px solid var(--uui-color-border,#d8d7d9);
268
+ border-radius: 0 0 3px 3px;
269
+ font-size: var(--uui-size-4, 12px);
270
+ }
271
+
272
+ .color-swatch__label strong {
273
+ overflow: hidden;
274
+ text-overflow: ellipsis;
275
+ white-space: nowrap;
276
+ box-sizing: border-box;
277
+ }
222
278
  `
223
279
  ];
224
280
  __decorateClass([
@@ -55,6 +55,7 @@ export declare class UUIColorSwatchElement extends UUIColorSwatchElement_base {
55
55
  firstUpdated(): void;
56
56
  willUpdate(changedProperties: Map<string, any>): void;
57
57
  render(): import("lit-html").TemplateResult<1>;
58
+ private _renderWithLabel;
58
59
  }
59
60
  declare global {
60
61
  interface HTMLElementTagNameMap {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-color-swatch",
3
- "version": "1.2.0-rc.0",
3
+ "version": "1.2.0-rc.1",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -30,8 +30,8 @@
30
30
  "custom-elements.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@umbraco-ui/uui-base": "1.2.0-rc.0",
34
- "@umbraco-ui/uui-icon-registry-essential": "1.2.0-rc.0",
33
+ "@umbraco-ui/uui-base": "1.2.0-rc.1",
34
+ "@umbraco-ui/uui-icon-registry-essential": "1.2.0-rc.1",
35
35
  "colord": "^2.9.3"
36
36
  },
37
37
  "scripts": {
@@ -43,5 +43,5 @@
43
43
  "access": "public"
44
44
  },
45
45
  "homepage": "https://uui.umbraco.com/?path=/story/uui-color-swatch",
46
- "gitHead": "43f1b9a8bd1721af30ba7c145517ee665d874df3"
46
+ "gitHead": "c85fbce0370213590f8b60119ac39f0473ffa0fb"
47
47
  }