@flourish/ui-styles 4.0.0 → 5.0.0
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/RELEASE_NOTES.md +4 -0
- package/package.json +7 -7
- package/src/button-style/index.js +2 -2
- package/src/dropdown-style/index.js +1 -1
- package/ui-styles.js +18 -216
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# 5.0.0
|
|
2
|
+
* Change default background button color to black [BREAKING]
|
|
3
|
+
* Ignore layout background color if not enabled
|
|
4
|
+
|
|
1
5
|
# 4.0.0
|
|
2
6
|
* Move slider width setting from @flourish/ui-styles to @flourish/controls [BREAKING] For use with version 8.0.0+ of @flourish/controls
|
|
3
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flourish/ui-styles",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Flourish module for styling UI elements",
|
|
5
5
|
"main": "ui-styles.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@flourish/eslint-plugin-flourish": "^0.7.2",
|
|
22
|
-
"eslint": "^
|
|
23
|
-
"husky": "^
|
|
24
|
-
"lint-staged": "^
|
|
25
|
-
"rollup": "^
|
|
26
|
-
"rollup-plugin-node-resolve": "^
|
|
27
|
-
"uglify-js": "^3.4
|
|
22
|
+
"eslint": "^8.34.0",
|
|
23
|
+
"husky": "^8.0.3",
|
|
24
|
+
"lint-staged": "^13.1.2",
|
|
25
|
+
"rollup": "^2.79.1",
|
|
26
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
27
|
+
"uglify-js": "^3.17.4"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
@@ -5,7 +5,7 @@ var DEFAULTS = Object.freeze({
|
|
|
5
5
|
background: null,
|
|
6
6
|
font_color: null,
|
|
7
7
|
|
|
8
|
-
background_selected: "#
|
|
8
|
+
background_selected: "#333333",
|
|
9
9
|
font_color_selected: "#ffffff",
|
|
10
10
|
|
|
11
11
|
background_hover: null,
|
|
@@ -39,7 +39,7 @@ ButtonStyle.prototype._createStylesheet = function() {
|
|
|
39
39
|
ButtonStyle.prototype.update = function() {
|
|
40
40
|
this._styles.clear();
|
|
41
41
|
|
|
42
|
-
var background_color = this._state.background || this._layout.background_color || "#ffffff";
|
|
42
|
+
var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
|
|
43
43
|
var text_color = this._state.font_color || this._layout.font_color || "#333333";
|
|
44
44
|
var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
|
|
45
45
|
var read_direction = getTextDirection();
|
|
@@ -34,7 +34,7 @@ DropdownStyle.prototype._createStylesheet = function() {
|
|
|
34
34
|
DropdownStyle.prototype.update = function() {
|
|
35
35
|
this._styles.clear();
|
|
36
36
|
|
|
37
|
-
var background_color = this._state.background || this._layout.background_color || "#ffffff";
|
|
37
|
+
var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
|
|
38
38
|
var text_color = this._state.font_color || this._layout.font_color || "#333333";
|
|
39
39
|
var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
|
|
40
40
|
|
package/ui-styles.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = global || self, factory(global[
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["ui-styles"] = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function Stylesheet() {
|
|
8
8
|
this.declarations = [];
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
Stylesheet.prototype.select = function(selector) {
|
|
13
13
|
if (!selector) return this;
|
|
14
|
-
var declaration = new Declaration(selector
|
|
14
|
+
var declaration = new Declaration(selector);
|
|
15
15
|
declaration.parent = this;
|
|
16
16
|
this.addDeclaration(declaration);
|
|
17
17
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
return this.parent.select(this.selector + " " + selector);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
var DEFAULTS = Object.freeze({
|
|
59
|
+
var DEFAULTS$3 = Object.freeze({
|
|
60
60
|
font_size: 1,
|
|
61
61
|
font_weight: "bold",
|
|
62
62
|
height: 2
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
|
|
65
65
|
function GeneralControlsStyle(state_, selector_, layout_) {
|
|
66
66
|
this._state = state_;
|
|
67
|
-
for (var key in DEFAULTS) { if (this._state[key] === undefined) this._state[key] = DEFAULTS[key]; }
|
|
67
|
+
for (var key in DEFAULTS$3) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key]; }
|
|
68
68
|
|
|
69
69
|
this._layout = layout_ || {};
|
|
70
70
|
|
|
@@ -502,179 +502,6 @@
|
|
|
502
502
|
: m1) * 255;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
var deg2rad = Math.PI / 180;
|
|
506
|
-
var rad2deg = 180 / Math.PI;
|
|
507
|
-
|
|
508
|
-
// https://observablehq.com/@mbostock/lab-and-rgb
|
|
509
|
-
var K = 18,
|
|
510
|
-
Xn = 0.96422,
|
|
511
|
-
Yn = 1,
|
|
512
|
-
Zn = 0.82521,
|
|
513
|
-
t0 = 4 / 29,
|
|
514
|
-
t1 = 6 / 29,
|
|
515
|
-
t2 = 3 * t1 * t1,
|
|
516
|
-
t3 = t1 * t1 * t1;
|
|
517
|
-
|
|
518
|
-
function labConvert(o) {
|
|
519
|
-
if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
|
|
520
|
-
if (o instanceof Hcl) return hcl2lab(o);
|
|
521
|
-
if (!(o instanceof Rgb)) o = rgbConvert(o);
|
|
522
|
-
var r = rgb2lrgb(o.r),
|
|
523
|
-
g = rgb2lrgb(o.g),
|
|
524
|
-
b = rgb2lrgb(o.b),
|
|
525
|
-
y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
|
|
526
|
-
if (r === g && g === b) x = z = y; else {
|
|
527
|
-
x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
|
|
528
|
-
z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
|
|
529
|
-
}
|
|
530
|
-
return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function lab(l, a, b, opacity) {
|
|
534
|
-
return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function Lab(l, a, b, opacity) {
|
|
538
|
-
this.l = +l;
|
|
539
|
-
this.a = +a;
|
|
540
|
-
this.b = +b;
|
|
541
|
-
this.opacity = +opacity;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
define(Lab, lab, extend(Color, {
|
|
545
|
-
brighter: function(k) {
|
|
546
|
-
return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
|
|
547
|
-
},
|
|
548
|
-
darker: function(k) {
|
|
549
|
-
return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
|
|
550
|
-
},
|
|
551
|
-
rgb: function() {
|
|
552
|
-
var y = (this.l + 16) / 116,
|
|
553
|
-
x = isNaN(this.a) ? y : y + this.a / 500,
|
|
554
|
-
z = isNaN(this.b) ? y : y - this.b / 200;
|
|
555
|
-
x = Xn * lab2xyz(x);
|
|
556
|
-
y = Yn * lab2xyz(y);
|
|
557
|
-
z = Zn * lab2xyz(z);
|
|
558
|
-
return new Rgb(
|
|
559
|
-
lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
|
|
560
|
-
lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
|
|
561
|
-
lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
|
|
562
|
-
this.opacity
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
}));
|
|
566
|
-
|
|
567
|
-
function xyz2lab(t) {
|
|
568
|
-
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function lab2xyz(t) {
|
|
572
|
-
return t > t1 ? t * t * t : t2 * (t - t0);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
function lrgb2rgb(x) {
|
|
576
|
-
return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function rgb2lrgb(x) {
|
|
580
|
-
return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function hclConvert(o) {
|
|
584
|
-
if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
|
|
585
|
-
if (!(o instanceof Lab)) o = labConvert(o);
|
|
586
|
-
if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
|
|
587
|
-
var h = Math.atan2(o.b, o.a) * rad2deg;
|
|
588
|
-
return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function hcl(h, c, l, opacity) {
|
|
592
|
-
return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
function Hcl(h, c, l, opacity) {
|
|
596
|
-
this.h = +h;
|
|
597
|
-
this.c = +c;
|
|
598
|
-
this.l = +l;
|
|
599
|
-
this.opacity = +opacity;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
function hcl2lab(o) {
|
|
603
|
-
if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
|
|
604
|
-
var h = o.h * deg2rad;
|
|
605
|
-
return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
define(Hcl, hcl, extend(Color, {
|
|
609
|
-
brighter: function(k) {
|
|
610
|
-
return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
|
|
611
|
-
},
|
|
612
|
-
darker: function(k) {
|
|
613
|
-
return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
|
|
614
|
-
},
|
|
615
|
-
rgb: function() {
|
|
616
|
-
return hcl2lab(this).rgb();
|
|
617
|
-
}
|
|
618
|
-
}));
|
|
619
|
-
|
|
620
|
-
var A = -0.14861,
|
|
621
|
-
B = +1.78277,
|
|
622
|
-
C = -0.29227,
|
|
623
|
-
D = -0.90649,
|
|
624
|
-
E = +1.97294,
|
|
625
|
-
ED = E * D,
|
|
626
|
-
EB = E * B,
|
|
627
|
-
BC_DA = B * C - D * A;
|
|
628
|
-
|
|
629
|
-
function cubehelixConvert(o) {
|
|
630
|
-
if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
|
|
631
|
-
if (!(o instanceof Rgb)) o = rgbConvert(o);
|
|
632
|
-
var r = o.r / 255,
|
|
633
|
-
g = o.g / 255,
|
|
634
|
-
b = o.b / 255,
|
|
635
|
-
l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
|
|
636
|
-
bl = b - l,
|
|
637
|
-
k = (E * (g - l) - C * bl) / D,
|
|
638
|
-
s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
|
|
639
|
-
h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
|
|
640
|
-
return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
function cubehelix(h, s, l, opacity) {
|
|
644
|
-
return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
function Cubehelix(h, s, l, opacity) {
|
|
648
|
-
this.h = +h;
|
|
649
|
-
this.s = +s;
|
|
650
|
-
this.l = +l;
|
|
651
|
-
this.opacity = +opacity;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
define(Cubehelix, cubehelix, extend(Color, {
|
|
655
|
-
brighter: function(k) {
|
|
656
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
657
|
-
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
|
|
658
|
-
},
|
|
659
|
-
darker: function(k) {
|
|
660
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
661
|
-
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
|
|
662
|
-
},
|
|
663
|
-
rgb: function() {
|
|
664
|
-
var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
|
|
665
|
-
l = +this.l,
|
|
666
|
-
a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
|
|
667
|
-
cosh = Math.cos(h),
|
|
668
|
-
sinh = Math.sin(h);
|
|
669
|
-
return new Rgb(
|
|
670
|
-
255 * (l + a * (A * cosh + B * sinh)),
|
|
671
|
-
255 * (l + a * (C * cosh + D * sinh)),
|
|
672
|
-
255 * (l + a * (E * cosh)),
|
|
673
|
-
this.opacity
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
}));
|
|
677
|
-
|
|
678
505
|
var prefix = "$";
|
|
679
506
|
|
|
680
507
|
function Map() {}
|
|
@@ -753,7 +580,7 @@
|
|
|
753
580
|
|
|
754
581
|
var proto = map.prototype;
|
|
755
582
|
|
|
756
|
-
Set.prototype =
|
|
583
|
+
Set.prototype = {
|
|
757
584
|
constructor: Set,
|
|
758
585
|
has: proto.has,
|
|
759
586
|
add: function(value) {
|
|
@@ -769,33 +596,8 @@
|
|
|
769
596
|
each: proto.each
|
|
770
597
|
};
|
|
771
598
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
// Copy constructor.
|
|
776
|
-
if (object instanceof Set) object.each(function(value) { set.add(value); });
|
|
777
|
-
|
|
778
|
-
// Otherwise, assume it’s an array.
|
|
779
|
-
else if (object) {
|
|
780
|
-
var i = -1, n = object.length;
|
|
781
|
-
if (f == null) while (++i < n) set.add(object[i]);
|
|
782
|
-
else while (++i < n) set.add(f(object[i], i, object));
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
return set;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
var getTextDimensions = (function() {
|
|
789
|
-
var context = document.createElement("canvas").getContext("2d");
|
|
790
|
-
return function(text, font) {
|
|
791
|
-
context.font = font || "10px sans-serif";
|
|
792
|
-
var metrics = context.measureText(text);
|
|
793
|
-
return {
|
|
794
|
-
width: metrics.width,
|
|
795
|
-
height: metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
})();
|
|
599
|
+
var canvas = document.createElement("canvas");
|
|
600
|
+
canvas.getContext("2d");
|
|
799
601
|
|
|
800
602
|
function getTextDirection() {
|
|
801
603
|
return window.getComputedStyle(document.body).direction || "ltr";
|
|
@@ -814,11 +616,11 @@
|
|
|
814
616
|
return c ? c.toString() : false;
|
|
815
617
|
}
|
|
816
618
|
|
|
817
|
-
var DEFAULTS$
|
|
619
|
+
var DEFAULTS$2 = Object.freeze({
|
|
818
620
|
background: null,
|
|
819
621
|
font_color: null,
|
|
820
622
|
|
|
821
|
-
background_selected: "#
|
|
623
|
+
background_selected: "#333333",
|
|
822
624
|
font_color_selected: "#ffffff",
|
|
823
625
|
|
|
824
626
|
background_hover: null,
|
|
@@ -832,7 +634,7 @@
|
|
|
832
634
|
|
|
833
635
|
function ButtonStyle(state_, selector_, layout_) {
|
|
834
636
|
this._state = state_;
|
|
835
|
-
for (var key in DEFAULTS$
|
|
637
|
+
for (var key in DEFAULTS$2) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key]; }
|
|
836
638
|
|
|
837
639
|
this._layout = layout_ || {};
|
|
838
640
|
|
|
@@ -852,7 +654,7 @@
|
|
|
852
654
|
ButtonStyle.prototype.update = function() {
|
|
853
655
|
this._styles.clear();
|
|
854
656
|
|
|
855
|
-
var background_color = this._state.background || this._layout.background_color || "#ffffff";
|
|
657
|
+
var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
|
|
856
658
|
var text_color = this._state.font_color || this._layout.font_color || "#333333";
|
|
857
659
|
var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
|
|
858
660
|
var read_direction = getTextDirection();
|
|
@@ -899,7 +701,7 @@
|
|
|
899
701
|
this._stylesheet.innerHTML = this._styles.print();
|
|
900
702
|
};
|
|
901
703
|
|
|
902
|
-
var DEFAULTS$
|
|
704
|
+
var DEFAULTS$1 = Object.freeze({
|
|
903
705
|
background: null,
|
|
904
706
|
font_color: null,
|
|
905
707
|
|
|
@@ -912,7 +714,7 @@
|
|
|
912
714
|
|
|
913
715
|
function DropdownStyle(state_, selector_, layout_) {
|
|
914
716
|
this._state = state_;
|
|
915
|
-
for (var key in DEFAULTS$
|
|
717
|
+
for (var key in DEFAULTS$1) { if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key]; }
|
|
916
718
|
|
|
917
719
|
this._layout = layout_ || {};
|
|
918
720
|
|
|
@@ -932,7 +734,7 @@
|
|
|
932
734
|
DropdownStyle.prototype.update = function() {
|
|
933
735
|
this._styles.clear();
|
|
934
736
|
|
|
935
|
-
var background_color = this._state.background || this._layout.background_color || "#ffffff";
|
|
737
|
+
var background_color = this._state.background || (this._layout.background_color_enabled ? this._layout.background_color || "#ffffff" : "#ffffff");
|
|
936
738
|
var text_color = this._state.font_color || this._layout.font_color || "#333333";
|
|
937
739
|
var border_color = hexToRgba(this._state.border_color || text_color, this._state.border_transparency);
|
|
938
740
|
|
|
@@ -1009,7 +811,7 @@
|
|
|
1009
811
|
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
1010
812
|
}
|
|
1011
813
|
|
|
1012
|
-
var DEFAULTS
|
|
814
|
+
var DEFAULTS = Object.freeze({
|
|
1013
815
|
play_color: null,
|
|
1014
816
|
handle_color: null,
|
|
1015
817
|
font_color: null,
|
|
@@ -1024,7 +826,7 @@
|
|
|
1024
826
|
|
|
1025
827
|
function SliderStyle(state_, selector_, layout_) {
|
|
1026
828
|
this._state = state_;
|
|
1027
|
-
for (var key in DEFAULTS
|
|
829
|
+
for (var key in DEFAULTS) { if (this._state[key] === undefined) this._state[key] = DEFAULTS[key]; }
|
|
1028
830
|
|
|
1029
831
|
this._layout = layout_ || {};
|
|
1030
832
|
|
|
@@ -1127,4 +929,4 @@
|
|
|
1127
929
|
|
|
1128
930
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1129
931
|
|
|
1130
|
-
}))
|
|
932
|
+
}));
|