Skip to content

Commit ea08a50

Browse files
committed
Merge remote-tracking branch 'origin/feat/2.6.0'
2 parents 0e736e5 + 01d3dcc commit ea08a50

File tree

11 files changed

+93
-4719
lines changed

11 files changed

+93
-4719
lines changed

dist/vue-color.js

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ function _colorChange(data, oldHue) {
516516
return {
517517
hsl: hsl,
518518
hex: color.toHexString().toUpperCase(),
519+
hex8: color.toHex8String().toUpperCase(),
519520
rgba: color.toRgb(),
520521
hsv: hsv,
521522
oldHue: data.h || oldHue || hsl.h,
@@ -927,7 +928,7 @@ var _color2 = _interopRequireDefault(_color);
927928
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
928929

929930
var VueColor = {
930-
version: '2.5.0',
931+
version: '2.6.0',
931932
Compact: _Compact2.default,
932933
Grayscale: _Grayscale2.default,
933934
Material: _Material2.default,
@@ -3071,7 +3072,7 @@ exports = module.exports = __webpack_require__(0)(false);
30713072

30723073

30733074
// module
3074-
exports.push([module.i, "\n.vc-slider {\n position: relative;\n width: 410px;\n}\n.vc-slider-hue-warp {\n height: 12px;\n position: relative;\n}\n.vc-slider-hue-warp .vc-hue-picker {\n width: 14px;\n height: 14px;\n border-radius: 6px;\n transform: translate(-7px, -2px);\n background-color: rgb(248, 248, 248);\n box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);\n}\n.vc-slider-swatches {\n display: flex;\n margin-top: 20px;\n}\n.vc-slider-swatch {\n margin-right: 1px;\n flex: 1;\n width: 20%;\n}\n.vc-slider-swatch:first-child {\n margin-right: 1px;\n}\n.vc-slider-swatch:first-child .vc-slider-swatch-picker {\n border-radius: 2px 0px 0px 2px;\n}\n.vc-slider-swatch:last-child {\n margin-right: 0;\n}\n.vc-slider-swatch:last-child .vc-slider-swatch-picker {\n border-radius: 0px 2px 2px 0px;\n}\n.vc-slider-swatch-picker {\n cursor: pointer;\n height: 12px;\n}\n.vc-slider-swatch-picker--active {\n transform: scaleY(1.8);\n border-radius: 3.6px/2px;\n}\n", ""]);
3075+
exports.push([module.i, "\n.vc-slider {\n position: relative;\n width: 410px;\n}\n.vc-slider-hue-warp {\n height: 12px;\n position: relative;\n}\n.vc-slider-hue-warp .vc-hue-picker {\n width: 14px;\n height: 14px;\n border-radius: 6px;\n transform: translate(-7px, -2px);\n background-color: rgb(248, 248, 248);\n box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);\n}\n.vc-slider-swatches {\n display: flex;\n margin-top: 20px;\n}\n.vc-slider-swatch {\n margin-right: 1px;\n flex: 1;\n width: 20%;\n}\n.vc-slider-swatch:first-child {\n margin-right: 1px;\n}\n.vc-slider-swatch:first-child .vc-slider-swatch-picker {\n border-radius: 2px 0px 0px 2px;\n}\n.vc-slider-swatch:last-child {\n margin-right: 0;\n}\n.vc-slider-swatch:last-child .vc-slider-swatch-picker {\n border-radius: 0px 2px 2px 0px;\n}\n.vc-slider-swatch-picker {\n cursor: pointer;\n height: 12px;\n}\n.vc-slider-swatch-picker--active {\n transform: scaleY(1.8);\n border-radius: 3.6px/2px;\n}\n.vc-slider-swatch-picker--white {\n box-shadow: inset 0 0 0 1px #ddd;\n}\n.vc-slider-swatch-picker--active.vc-slider-swatch-picker--white {\n box-shadow: inset 0 0 0 0.6px #ddd;\n}\n", ""]);
30753076

30763077
// exports
30773078

@@ -3101,25 +3102,32 @@ exports.default = {
31013102
name: 'Slider',
31023103
mixins: [_color2.default],
31033104
props: {
3104-
direction: String
3105+
swatches: {
3106+
type: Array,
3107+
default: function _default() {
3108+
return ['.80', '.65', '.50', '.35', '.20'];
3109+
}
3110+
}
31053111
},
31063112
components: {
31073113
hue: _Hue2.default
31083114
},
31093115
computed: {
31103116
activeOffset: function activeOffset() {
3111-
if (Math.round(this.colors.hsl.s * 100) / 100 === 0.50) {
3112-
return Math.round(this.colors.hsl.l * 100) / 100;
3117+
var hasBlack = this.swatches.includes('0');
3118+
var hasWhite = this.swatches.includes('1');
3119+
var hsl = this.colors.hsl;
3120+
3121+
if (Math.round(hsl.s * 100) / 100 === 0.50) {
3122+
return Math.round(hsl.l * 100) / 100;
3123+
} else if (hasBlack && hsl.l === 0) {
3124+
return 0;
3125+
} else if (hasWhite && hsl.l === 1) {
3126+
return 1;
31133127
}
3114-
return 0;
3128+
return -1;
31153129
}
31163130
},
3117-
data: function data() {
3118-
return {
3119-
swatches: ['.80', '.65', '.50', '.35', '.20']
3120-
};
3121-
},
3122-
31233131
methods: {
31243132
hueChange: function hueChange(data) {
31253133
this.colorChange(data);
@@ -3394,7 +3402,7 @@ var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._sel
33943402
}, [_c('div', {
33953403
staticClass: "vc-slider-swatch-picker",
33963404
class: {
3397-
'vc-slider-swatch-picker--active': offset == _vm.activeOffset
3405+
'vc-slider-swatch-picker--active': offset == _vm.activeOffset, 'vc-slider-swatch-picker--white': offset === '1'
33983406
},
33993407
style: ({
34003408
background: 'hsl(' + _vm.colors.hsl.h + ', 50%, ' + (offset * 100) + '%)'
@@ -5218,7 +5226,7 @@ exports = module.exports = __webpack_require__(0)(false);
52185226

52195227

52205228
// module
5221-
exports.push([module.i, "\n.vc-sketch {\n position: relative;\n width: 200px;\n padding: 10px 10px 0;\n box-sizing: initial;\n background: #fff;\n border-radius: 4px;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, .15), 0 8px 16px rgba(0, 0, 0, .15);\n}\n.vc-sketch-saturation-wrap {\n width: 100%;\n padding-bottom: 75%;\n position: relative;\n overflow: hidden;\n}\n.vc-sketch-controls {\n display: flex;\n}\n.vc-sketch-sliders {\n padding: 4px 0;\n flex: 1;\n}\n.vc-sketch-sliders .vc-hue,\n.vc-sketch-sliders .vc-alpha-gradient {\n border-radius: 2px;\n}\n.vc-sketch-hue-wrap {\n position: relative;\n height: 10px;\n}\n.vc-sketch-alpha-wrap {\n position: relative;\n height: 10px;\n margin-top: 4px;\n overflow: hidden;\n}\n.vc-sketch-color-wrap {\n width: 24px;\n height: 24px;\n position: relative;\n margin-top: 4px;\n margin-left: 4px;\n border-radius: 3px;\n}\n.vc-sketch-active-color {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 2px;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15), inset 0 0 4px rgba(0, 0, 0, .25);\n z-index: 2;\n}\n.vc-sketch-color-wrap .vc-checkerboard {\n background-size: auto;\n}\n.vc-sketch-field {\n display: flex;\n padding-top: 4px;\n}\n.vc-sketch-field .vc-input__input {\n width: 80%;\n padding: 4px 10% 3px;\n border: none;\n box-shadow: inset 0 0 0 1px #ccc;\n font-size: 11px;\n}\n.vc-sketch-field .vc-input__label {\n display: block;\n text-align: center;\n font-size: 11px;\n color: #222;\n padding-top: 3px;\n padding-bottom: 4px;\n text-transform: capitalize;\n}\n.vc-sketch-field--single {\n flex: 1;\n padding-left: 6px;\n}\n.vc-sketch-field--double {\n flex: 2;\n}\n.vc-sketch-presets {\n margin-right: -10px;\n margin-left: -10px;\n padding-left: 10px;\n padding-top: 10px;\n border-top: 1px solid #eee;\n}\n.vc-sketch-presets-color {\n border-radius: 3px;\n overflow: hidden;\n position: relative;\n display: inline-block;\n margin: 0 10px 10px 0;\n vertical-align: top;\n cursor: pointer;\n width: 16px;\n height: 16px;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);\n}\n.vc-sketch-presets-color .vc-checkerboard {\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);\n border-radius: 3px;\n}\n.vc-sketch__disable-alpha .vc-sketch-color-wrap {\n height: 10px;\n}\n", ""]);
5229+
exports.push([module.i, "\n.vc-sketch {\n position: relative;\n width: 200px;\n padding: 10px 10px 0;\n box-sizing: initial;\n background: #fff;\n border-radius: 4px;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, .15), 0 8px 16px rgba(0, 0, 0, .15);\n}\n.vc-sketch-saturation-wrap {\n width: 100%;\n padding-bottom: 75%;\n position: relative;\n overflow: hidden;\n}\n.vc-sketch-controls {\n display: flex;\n}\n.vc-sketch-sliders {\n padding: 4px 0;\n flex: 1;\n}\n.vc-sketch-sliders .vc-hue,\n.vc-sketch-sliders .vc-alpha-gradient {\n border-radius: 2px;\n}\n.vc-sketch-hue-wrap {\n position: relative;\n height: 10px;\n}\n.vc-sketch-alpha-wrap {\n position: relative;\n height: 10px;\n margin-top: 4px;\n overflow: hidden;\n}\n.vc-sketch-color-wrap {\n width: 24px;\n height: 24px;\n position: relative;\n margin-top: 4px;\n margin-left: 4px;\n border-radius: 3px;\n}\n.vc-sketch-active-color {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: 2px;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15), inset 0 0 4px rgba(0, 0, 0, .25);\n z-index: 2;\n}\n.vc-sketch-color-wrap .vc-checkerboard {\n background-size: auto;\n}\n.vc-sketch-field {\n display: flex;\n padding-top: 4px;\n}\n.vc-sketch-field .vc-input__input {\n width: 90%;\n padding: 4px 0 3px 10%;\n border: none;\n box-shadow: inset 0 0 0 1px #ccc;\n font-size: 10px;\n}\n.vc-sketch-field .vc-input__label {\n display: block;\n text-align: center;\n font-size: 11px;\n color: #222;\n padding-top: 3px;\n padding-bottom: 4px;\n text-transform: capitalize;\n}\n.vc-sketch-field--single {\n flex: 1;\n padding-left: 6px;\n}\n.vc-sketch-field--double {\n flex: 2;\n}\n.vc-sketch-presets {\n margin-right: -10px;\n margin-left: -10px;\n padding-left: 10px;\n padding-top: 10px;\n border-top: 1px solid #eee;\n}\n.vc-sketch-presets-color {\n border-radius: 3px;\n overflow: hidden;\n position: relative;\n display: inline-block;\n margin: 0 10px 10px 0;\n vertical-align: top;\n cursor: pointer;\n width: 16px;\n height: 16px;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);\n}\n.vc-sketch-presets-color .vc-checkerboard {\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);\n border-radius: 3px;\n}\n.vc-sketch__disable-alpha .vc-sketch-color-wrap {\n height: 10px;\n}\n", ""]);
52225230

52235231
// exports
52245232

@@ -5290,7 +5298,13 @@ exports.default = {
52905298
},
52915299
computed: {
52925300
hex: function hex() {
5293-
return this.colors.hex.replace('#', '');
5301+
var hex = void 0;
5302+
if (this.colors.a < 1) {
5303+
hex = this.colors.hex8;
5304+
} else {
5305+
hex = this.colors.hex;
5306+
}
5307+
return hex.replace('#', '');
52945308
},
52955309
activeColor: function activeColor() {
52965310
var rgba = this.colors.rgba;
@@ -5667,24 +5681,12 @@ exports.default = {
56675681
activeColor: function activeColor() {
56685682
var rgba = this.colors.rgba;
56695683
return 'rgba(' + [rgba.r, rgba.g, rgba.b, rgba.a].join(',') + ')';
5670-
}
5671-
},
5672-
watch: {
5673-
colors: function colors(newVal) {
5674-
var a = newVal.a;
5675-
5676-
if (a < 1 && this.fieldsIndex === 0) {
5677-
this.fieldsIndex = 1;
5678-
}
5684+
},
5685+
hasAlpha: function hasAlpha() {
5686+
return this.colors.a < 1;
56795687
}
56805688
},
56815689
methods: {
5682-
handlePreset: function handlePreset(c) {
5683-
this.colorChange({
5684-
hex: c,
5685-
source: 'hex'
5686-
});
5687-
},
56885690
childChange: function childChange(data) {
56895691
this.colorChange(data);
56905692
},
@@ -5719,7 +5721,7 @@ exports.default = {
57195721
},
57205722
toggleViews: function toggleViews() {
57215723
if (this.fieldsIndex >= 2) {
5722-
this.fieldsIndex = this.colors.a < 1 ? 1 : 0;
5724+
this.fieldsIndex = 0;
57235725
return;
57245726
}
57255727
this.fieldsIndex++;
@@ -5808,15 +5810,23 @@ var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._sel
58085810
staticClass: "vc-chrome-fields"
58095811
}, [_c('div', {
58105812
staticClass: "vc-chrome-field"
5811-
}, [_c('ed-in', {
5813+
}, [(!_vm.hasAlpha) ? _c('ed-in', {
58125814
attrs: {
58135815
"label": "hex",
58145816
"value": _vm.colors.hex
58155817
},
58165818
on: {
58175819
"change": _vm.inputChange
58185820
}
5819-
})], 1)]), _vm._v(" "), _c('div', {
5821+
}) : _vm._e(), _vm._v(" "), (_vm.hasAlpha) ? _c('ed-in', {
5822+
attrs: {
5823+
"label": "hex",
5824+
"value": _vm.colors.hex8
5825+
},
5826+
on: {
5827+
"change": _vm.inputChange
5828+
}
5829+
}) : _vm._e()], 1)]), _vm._v(" "), _c('div', {
58205830
directives: [{
58215831
name: "show",
58225832
rawName: "v-show",

dist/vue-color.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,26 @@ import chrome from '../src/components/Chrome.vue'
6969
import photoshop from '../src/components/Photoshop.vue'
7070
7171
let defaultProps = {
72-
hex: '#194d33',
72+
hex: '#194d33e6',
7373
hsl: {
7474
h: 150,
7575
s: 0.5,
7676
l: 0.2,
77-
a: 1
77+
a: 0.9
7878
},
7979
hsv: {
8080
h: 150,
8181
s: 0.66,
8282
v: 0.30,
83-
a: 1
83+
a: 0.9
8484
},
8585
rgba: {
8686
r: 25,
8787
g: 77,
8888
b: 51,
89-
a: 1
89+
a: 0.9
9090
},
91-
a: 1
91+
a: 0.9
9292
}
9393
9494
export default {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-color",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"description": "Color of Vue Components",
55
"keywords": [
66
"color",

src/components/Chrome.vue

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
<div class="vc-chrome-fields" v-show="fieldsIndex === 0">
2525
<!-- hex -->
2626
<div class="vc-chrome-field">
27-
<ed-in label="hex" :value="colors.hex" @change="inputChange"></ed-in>
27+
<ed-in v-if="!hasAlpha" label="hex" :value="colors.hex" @change="inputChange"></ed-in>
28+
<ed-in v-if="hasAlpha" label="hex" :value="colors.hex8" @change="inputChange"></ed-in>
2829
</div>
2930
</div>
3031
<div class="vc-chrome-fields" v-show="fieldsIndex === 1">
@@ -121,23 +122,12 @@ export default {
121122
activeColor () {
122123
const rgba = this.colors.rgba
123124
return 'rgba(' + [rgba.r, rgba.g, rgba.b, rgba.a].join(',') + ')'
124-
}
125-
},
126-
watch: {
127-
colors (newVal) {
128-
const { a } = newVal
129-
if (a < 1 && this.fieldsIndex === 0) {
130-
this.fieldsIndex = 1
131-
}
125+
},
126+
hasAlpha () {
127+
return this.colors.a < 1
132128
}
133129
},
134130
methods: {
135-
handlePreset (c) {
136-
this.colorChange({
137-
hex: c,
138-
source: 'hex'
139-
})
140-
},
141131
childChange (data) {
142132
this.colorChange(data)
143133
},
@@ -172,7 +162,7 @@ export default {
172162
},
173163
toggleViews () {
174164
if (this.fieldsIndex >= 2) {
175-
this.fieldsIndex = this.colors.a < 1 ? 1 : 0
165+
this.fieldsIndex = 0
176166
return
177167
}
178168
this.fieldsIndex ++

src/components/Sketch.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ export default {
101101
},
102102
computed: {
103103
hex () {
104-
return this.colors.hex.replace('#', '')
104+
let hex
105+
if (this.colors.a < 1) {
106+
hex = this.colors.hex8
107+
} else {
108+
hex = this.colors.hex
109+
}
110+
return hex.replace('#', '')
105111
},
106112
activeColor () {
107113
var rgba = this.colors.rgba
@@ -215,11 +221,11 @@ export default {
215221
}
216222
217223
.vc-sketch-field .vc-input__input {
218-
width: 80%;
219-
padding: 4px 10% 3px;
224+
width: 90%;
225+
padding: 4px 0 3px 10%;
220226
border: none;
221227
box-shadow: inset 0 0 0 1px #ccc;
222-
font-size: 11px;
228+
font-size: 10px;
223229
}
224230
225231
.vc-sketch-field .vc-input__label {

src/components/Slider.vue

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div
1010
class="vc-slider-swatch-picker"
1111
:aria-label="'color:' + 'hsl(' + colors.hsl.h + ', 50%, ' + (offset * 100) + '%)'"
12-
:class="{'vc-slider-swatch-picker--active': offset == activeOffset}"
12+
:class="{'vc-slider-swatch-picker--active': offset == activeOffset, 'vc-slider-swatch-picker--white': offset === '1'}"
1313
:style="{background: 'hsl(' + colors.hsl.h + ', 50%, ' + (offset * 100) + '%)'}"
1414
></div>
1515
</div>
@@ -25,22 +25,30 @@ export default {
2525
name: 'Slider',
2626
mixins: [colorMixin],
2727
props: {
28-
direction: String
28+
swatches: {
29+
type: Array,
30+
default () {
31+
return ['.80', '.65', '.50', '.35', '.20']
32+
}
33+
}
2934
},
3035
components: {
3136
hue
3237
},
3338
computed: {
3439
activeOffset () {
35-
if (Math.round(this.colors.hsl.s * 100) / 100 === 0.50) {
36-
return Math.round(this.colors.hsl.l * 100) / 100
40+
const hasBlack = this.swatches.includes('0')
41+
const hasWhite = this.swatches.includes('1')
42+
const hsl = this.colors.hsl
43+
44+
if (Math.round(hsl.s * 100) / 100 === 0.50) {
45+
return Math.round(hsl.l * 100) / 100
46+
} else if (hasBlack && hsl.l === 0) {
47+
return 0
48+
} else if (hasWhite && hsl.l === 1) {
49+
return 1
3750
}
38-
return 0
39-
}
40-
},
41-
data () {
42-
return {
43-
swatches: ['.80', '.65', '.50', '.35', '.20']
51+
return -1
4452
}
4553
},
4654
methods: {
@@ -105,4 +113,10 @@ export default {
105113
transform: scaleY(1.8);
106114
border-radius: 3.6px/2px;
107115
}
116+
.vc-slider-swatch-picker--white {
117+
box-shadow: inset 0 0 0 1px #ddd;
118+
}
119+
.vc-slider-swatch-picker--active.vc-slider-swatch-picker--white {
120+
box-shadow: inset 0 0 0 0.6px #ddd;
121+
}
108122
</style>

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Saturation from './components/common/Saturation.vue'
1414
import ColorMixin from './mixin/color.js'
1515

1616
const VueColor = {
17-
version: '2.5.0',
17+
version: '2.6.0',
1818
Compact,
1919
Grayscale,
2020
Material,

src/mixin/color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function _colorChange (data, oldHue) {
4242
return {
4343
hsl: hsl,
4444
hex: color.toHexString().toUpperCase(),
45+
hex8: color.toHex8String().toUpperCase(),
4546
rgba: color.toRgb(),
4647
hsv: hsv,
4748
oldHue: data.h || oldHue || hsl.h,

0 commit comments

Comments
 (0)