rescript-polished 1.15.0 → 2.1.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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "rescript-polished",
3
- "version": "1.15.0",
3
+ "version": "2.1.0",
4
+ "type": "module",
4
5
  "description": "ReScript bindings for polished.",
5
6
  "main": "dist/index.js",
6
7
  "repository": "https://github.com/brnrdog/rescript-polished",
@@ -16,29 +17,32 @@
16
17
  "colour",
17
18
  "styled-components"
18
19
  ],
20
+ "release": {
21
+ "branches": [
22
+ "main"
23
+ ]
24
+ },
19
25
  "scripts": {
20
- "res:start": "bsb -make-world -w",
21
- "res:build": "bsb -make-world",
22
- "res:clean": "bsb -clean-world",
23
- "test": "jest",
24
- "test:ci": "jest --collect-coverage"
26
+ "res:start": "rescript build -w",
27
+ "res:build": "rescript build",
28
+ "res:clean": "rescript clean",
29
+ "test": "rescript build && node lib/bs/__tests__/RunTests.res.js",
30
+ "test:ci": "rescript build && node lib/bs/__tests__/RunTests.res.js"
25
31
  },
26
32
  "dependencies": {
27
- "bs-css": "^13.4.0",
28
- "bs-platform": "^9.0.1",
29
- "polished": "^4.0.3"
33
+ "bs-css": "^18.1.1",
34
+ "polished": "^4.0.3",
35
+ "rescript": "^12.0.2"
30
36
  },
31
37
  "devDependencies": {
32
- "@glennsl/bs-jest": "^0.7.0",
33
- "jest": "^26.6.3",
34
- "semantic-release": "^17.2.2"
35
- },
36
- "jest": {
37
- "collectCoverageFrom": [
38
- "<rootDir>/lib/js/src/**/*.js",
39
- "!<rootDir>/lib/js/src/Polished.js",
40
- "!<rootDir>/lib/js/src/PolishedCss.js"
41
- ],
42
- "verbose": true
38
+ "@commitlint/cli": "^20.1.0",
39
+ "@commitlint/config-conventional": "^20.0.0",
40
+ "@rescript/core": "^1.6.1",
41
+ "@semantic-release/changelog": "^6.0.3",
42
+ "@semantic-release/git": "^10.0.1",
43
+ "@semantic-release/github": "^12.0.2",
44
+ "@semantic-release/npm": "^13.1.2",
45
+ "husky": "^9.1.7",
46
+ "semantic-release": "^25.0.2"
43
47
  }
44
48
  }
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "rescript-polished",
3
- "version": "0.0.0-semantic-released",
4
3
  "sources": [
5
4
  {
6
5
  "dir": "src",
@@ -11,8 +10,13 @@
11
10
  "type": "dev"
12
11
  }
13
12
  ],
14
- "bs-dev-dependencies": ["@glennsl/bs-jest"],
15
- "bs-dependencies": ["bs-css"],
13
+ "package-specs": [
14
+ {
15
+ "module": "es6"
16
+ }
17
+ ],
18
+ "suffix": ".res.js",
19
+ "dependencies": ["bs-css"],
16
20
  "warnings": {
17
21
  "error": "+101"
18
22
  }
@@ -1,26 +1,26 @@
1
1
  module Utils = {
2
- open Css_AtomicTypes
2
+ module StdFloat = Float
3
+ module StdInt = Int
3
4
 
4
5
  module Rgba = {
5
- let regex = "rgba\(\s*(-?\d+|-?\d*\.\d+(?=%))\s*,\s*(-?\d+|-?\d*\.\d+(?=%))\s*,\s*(-?\d+|-?\d*\.\d+(?=%))\s*,\s*(-?\d+|-?\d*.\d+)\s*\)"
6
- let rgbaRegexGroups = (_, i) => [1, 2, 3, 4]->Js.Array2.includes(i)
7
- let rgbValue = v => v->Js.Nullable.toOption->Belt.Option.getExn->int_of_string
8
- let alphaValue = v => v->Js.Nullable.toOption->Belt.Option.getUnsafe->float_of_string
6
+ let regex = "rgba\\(\\s*(-?\\d+|-?\\d*\\.\\d+(?=%))\\s*,\\s*(-?\\d+|-?\\d*\\.\\d+(?=%))\\s*,\\s*(-?\\d+|-?\\d*\\.\\d+(?=%))\\s*,\\s*(-?\\d+|-?\\d*\\.\\d+)\\s*\\)"
7
+ let rgbValue = v => v->StdInt.fromString->Belt.Option.getExn
8
+ let alphaValue = v => v->StdFloat.fromString->Belt.Option.getExn
9
+
10
+ @get_index external unsafeGet: (RegExp.Result.t, int) => string = ""
9
11
 
10
12
  let fromString = string => {
11
- let result = regex->Js.Re.fromString->Js.Re.exec_(string)
13
+ let result = regex->RegExp.fromString->RegExp.exec(string)
12
14
 
13
15
  switch result {
14
16
  | None => None
15
17
  | Some(result) => {
16
- let values = result->Js.Re.captures->Js.Array2.filteri(rgbaRegexGroups)
17
-
18
- let red = values->Array.get(0)->rgbValue
19
- let green = values->Array.get(1)->rgbValue
20
- let blue = values->Array.get(2)->rgbValue
21
- let alpha = values->Array.get(3)->alphaValue
18
+ let red = result->unsafeGet(1)->rgbValue
19
+ let green = result->unsafeGet(2)->rgbValue
20
+ let blue = result->unsafeGet(3)->rgbValue
21
+ let alpha = result->unsafeGet(4)->alphaValue
22
22
 
23
- Some(Color.rgba(red, green, blue, #num(alpha)))
23
+ Some(Css_Js_Core.Types.Color.rgba(red, green, blue, #num(alpha)))
24
24
  }
25
25
  }
26
26
  }
@@ -28,13 +28,13 @@ module Utils = {
28
28
 
29
29
  module Hex = {
30
30
  let fromString = string =>
31
- #hex(string->Js.String2.slice(~from=1, ~to_=Js.String.length(string)))
31
+ #hex(string->String.slice(~start=1, ~end=String.length(string)))
32
32
  }
33
33
 
34
- let toString = Color.toString
34
+ let toString = Css_Js_Core.Types.Color.toString
35
35
 
36
36
  let fromString = string => {
37
- switch string->Js.String2.slice(~from=0, ~to_=4) {
37
+ switch string->String.slice(~start=0, ~end=4) {
38
38
  | "rgba" => string->Rgba.fromString->Belt.Option.getExn
39
39
  | _ => string->Hex.fromString
40
40
  }
@@ -10,19 +10,19 @@ type rgbaColor = {"red": int, "green": int, "blue": int, "alpha": float}
10
10
 
11
11
  @module("polished")
12
12
  external shade: (float, color) => color = "shade"
13
- let shade = (color, ~amount) => color |> shade(amount)
13
+ let shade = (color, ~amount) => shade(amount, color)
14
14
 
15
15
  @module("polished")
16
16
  external tint: (float, color) => color = "tint"
17
- let tint = (color, ~amount) => color |> tint(amount)
17
+ let tint = (color, ~amount) => tint(amount, color)
18
18
 
19
19
  @module("polished")
20
20
  external lighten: (float, color) => color = "lighten"
21
- let lighten = (color, ~amount) => color |> lighten(amount)
21
+ let lighten = (color, ~amount) => lighten(amount, color)
22
22
 
23
23
  @module("polished")
24
24
  external darken: (float, color) => color = "darken"
25
- let darken = (color, ~amount) => color |> darken(amount)
25
+ let darken = (color, ~amount) => darken(amount, color)
26
26
 
27
27
  @module("polished")
28
28
  external hsl: (float, float, float) => color = "hsl"
@@ -30,7 +30,7 @@ let hsl = (~hue, ~saturation, ~lightness) => hsl(hue, saturation, lightness)
30
30
 
31
31
  @module("polished")
32
32
  external extAdjustHue: (float, color) => color = "adjustHue"
33
- let adjustHue = (color, ~degree) => color |> extAdjustHue(degree)
33
+ let adjustHue = (color, ~degree) => extAdjustHue(degree, color)
34
34
 
35
35
  @module("polished")
36
36
  external complement: color => color = "complement"
@@ -38,7 +38,7 @@ let complement = complement
38
38
 
39
39
  @module("polished")
40
40
  external desaturate: (float, color) => color = "desaturate"
41
- let desaturate = (color, ~amount) => color |> desaturate(amount)
41
+ let desaturate = (color, ~amount) => desaturate(amount, color)
42
42
 
43
43
  @module("polished")
44
44
  external getContrast: (color, color) => float = "getContrast"
@@ -66,7 +66,7 @@ let meetsContrastGuidelines = meetsContrastGuidelines
66
66
 
67
67
  @module("polished")
68
68
  external extTransparentize: (float, color) => color = "transparentize"
69
- let transparentize = (color, ~amount) => color |> extTransparentize(amount)
69
+ let transparentize = (color, ~amount) => extTransparentize(amount, color)
70
70
 
71
71
  @module("polished")
72
72
  external hslToColorString: hslColor => color = "hslToColorString"
@@ -74,11 +74,11 @@ let hslToColorString = hslToColorString
74
74
 
75
75
  @module("polished")
76
76
  external mix: (float, color, color) => color = "mix"
77
- let mix = (color1, color2, ~weight) => color2 |> mix(weight, color1)
77
+ let mix = (color1, color2, ~weight) => mix(weight, color1, color2)
78
78
 
79
79
  @module("polished")
80
80
  external opacify: (float, color) => color = "opacify"
81
- let opacify = (color, ~amount) => color |> opacify(amount)
81
+ let opacify = (color, ~amount) => opacify(amount, color)
82
82
 
83
83
  @module("polished")
84
84
  external parseToHsl: color => hslColor = "parseToHsl"
@@ -90,7 +90,7 @@ let parseToRgb = parseToRgb
90
90
 
91
91
  @module("polished")
92
92
  external readableColor: (color, color, color, bool) => color = "readableColor"
93
- let readableColor = (color, ~lightReturnColor="#fff", ~darkReturnColor="#000", ~strict=true, ()) =>
93
+ let readableColor = (color, ~lightReturnColor="#000", ~darkReturnColor="#fff", ~strict=true, ()) =>
94
94
  readableColor(color, lightReturnColor, darkReturnColor, strict)
95
95
 
96
96
  @module("polished")
@@ -103,16 +103,16 @@ let rgba = rgba
103
103
 
104
104
  @module("polished")
105
105
  external saturate: (float, color) => color = "saturate"
106
- let saturate = (color, ~amount) => color |> saturate(amount)
106
+ let saturate = (color, ~amount) => saturate(amount, color)
107
107
 
108
108
  @module("polished")
109
109
  external setHue: (int, color) => color = "setHue"
110
- let setHue = (color, ~hue) => color |> setHue(hue)
110
+ let setHue = (color, ~hue) => setHue(hue, color)
111
111
 
112
112
  @module("polished")
113
113
  external setLightness: (float, color) => color = "setLightness"
114
- let setLightness = (color, ~lightness) => color |> setLightness(lightness)
114
+ let setLightness = (color, ~lightness) => setLightness(lightness, color)
115
115
 
116
116
  @module("polished")
117
117
  external setSaturation: (float, color) => color = "setSaturation"
118
- let setSaturation = (color, ~saturation) => color |> setSaturation(saturation)
118
+ let setSaturation = (color, ~saturation) => setSaturation(saturation, color)
@@ -26,37 +26,37 @@ external clearFix: option<string> => 'styles = "clearFix"
26
26
  let clearFix = (~parent=?) => parent->clearFix
27
27
 
28
28
  @module("polished")
29
- external cover: (~offset: Js.undefined<Size.t>) => 'styles = "cover"
30
- let cover = (~offset=?, ()) => cover(~offset=Js.Undefined.fromOption(offset))
29
+ external cover: (~offset: Nullable.t<Size.t>) => 'styles = "cover"
30
+ let cover = (~offset=?, ()) => cover(~offset=Nullable.fromOption(offset))
31
31
 
32
32
  @module("polished")
33
- external ellipsis: (~width: Js.undefined<Size.t>, ~lines: option<int>) => 'styles = "ellipsis"
33
+ external ellipsis: (~width: Nullable.t<Size.t>, ~lines: option<int>) => 'styles = "ellipsis"
34
34
  let ellipsis = (~width=?, ~lines=?, ()) => {
35
- ellipsis(~width=Js.Undefined.fromOption(width), ~lines)
35
+ ellipsis(~width=Nullable.fromOption(width), ~lines)
36
36
  }
37
37
 
38
38
  @module("polished")
39
39
  external fluidRange: (
40
40
  fluidRangeConfiguration,
41
- ~minScreen: Js.undefined<string>,
42
- ~maxScreen: Js.undefined<string>,
41
+ ~minScreen: Nullable.t<string>,
42
+ ~maxScreen: Nullable.t<string>,
43
43
  ) => 'styles = "fluidRange"
44
44
  let fluidRange = (~minScreen=?, ~maxScreen=?, cssProp) =>
45
45
  fluidRange(
46
46
  cssProp,
47
- ~minScreen=Js.Undefined.fromOption(minScreen),
48
- ~maxScreen=Js.Undefined.fromOption(maxScreen),
47
+ ~minScreen=Nullable.fromOption(minScreen),
48
+ ~maxScreen=Nullable.fromOption(maxScreen),
49
49
  )
50
50
 
51
51
  @module("polished")
52
52
  external fluidRangeWithArray: (
53
53
  array<fluidRangeConfiguration>,
54
- ~minScreen: Js.undefined<string>,
55
- ~maxScreen: Js.undefined<string>,
54
+ ~minScreen: Nullable.t<string>,
55
+ ~maxScreen: Nullable.t<string>,
56
56
  ) => 'styles = "fluidRange"
57
57
  let fluidRangeWithArray = (~minScreen=?, ~maxScreen=?, cssProps) =>
58
58
  fluidRangeWithArray(
59
59
  cssProps,
60
- ~minScreen=Js.Undefined.fromOption(minScreen),
61
- ~maxScreen=Js.Undefined.fromOption(maxScreen),
60
+ ~minScreen=Nullable.fromOption(minScreen),
61
+ ~maxScreen=Nullable.fromOption(maxScreen),
62
62
  )
@@ -1,171 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
-
4
- var Jest = require("@glennsl/bs-jest/lib/js/src/jest.js");
5
- var Curry = require("bs-platform/lib/js/curry.js");
6
- var Css_AtomicTypes = require("bs-css/lib/js/src/Css_AtomicTypes.js");
7
- var PolishedCss__Color = require("../src/PolishedCss__Color.js");
8
-
9
- function toEqual(x, y) {
10
- return Jest.Expect.toEqual(y, x);
11
- }
12
-
13
- Jest.describe("Color", (function (param) {
14
- Jest.test("shade with hex", (function (param) {
15
- var x = Jest.Expect.expect(PolishedCss__Color.shade({
16
- NAME: "hex",
17
- VAL: "ff0000"
18
- }, 0.25));
19
- return Jest.Expect.toEqual({
20
- NAME: "hex",
21
- VAL: "bf0000"
22
- }, x);
23
- }));
24
- Jest.test("shade with rgb", (function (param) {
25
- var x = Jest.Expect.expect(PolishedCss__Color.shade(Css_AtomicTypes.Color.rgb(255, 0, 0), 0.25));
26
- return Jest.Expect.toEqual({
27
- NAME: "hex",
28
- VAL: "bf0000"
29
- }, x);
30
- }));
31
- Jest.test("shade with rgba", (function (param) {
32
- var y = Css_AtomicTypes.Color.rgba(76, 0, 0, {
33
- NAME: "num",
34
- VAL: 0.4375
35
- });
36
- var x = Jest.Expect.expect(PolishedCss__Color.shade(Css_AtomicTypes.Color.rgba(255, 0, 0, {
37
- NAME: "num",
38
- VAL: 0.25
39
- }), 0.25));
40
- return Jest.Expect.toEqual(y, x);
41
- }));
42
- Jest.test("tint with hex", (function (param) {
43
- var x = Jest.Expect.expect(PolishedCss__Color.tint({
44
- NAME: "hex",
45
- VAL: "ff0000"
46
- }, 0.25));
47
- return Jest.Expect.toEqual({
48
- NAME: "hex",
49
- VAL: "ff3f3f"
50
- }, x);
51
- }));
52
- Jest.test("tint with rgb", (function (param) {
53
- var x = Jest.Expect.expect(PolishedCss__Color.tint(Css_AtomicTypes.Color.rgb(255, 0, 0), 0.25));
54
- return Jest.Expect.toEqual({
55
- NAME: "hex",
56
- VAL: "ff3f3f"
57
- }, x);
58
- }));
59
- Jest.test("darken with hex", (function (param) {
60
- var x = Jest.Expect.expect(PolishedCss__Color.darken({
61
- NAME: "hex",
62
- VAL: "ff0000"
63
- }, 0.25));
64
- return Jest.Expect.toEqual({
65
- NAME: "hex",
66
- VAL: "800000"
67
- }, x);
68
- }));
69
- Jest.test("lighten with hex", (function (param) {
70
- var x = Jest.Expect.expect(PolishedCss__Color.lighten({
71
- NAME: "hex",
72
- VAL: "ff0000"
73
- }, 0.25));
74
- return Jest.Expect.toEqual({
75
- NAME: "hex",
76
- VAL: "ff8080"
77
- }, x);
78
- }));
79
- Jest.test("transparentize with hex", (function (param) {
80
- var y = Curry._1(PolishedCss__Color.Utils.Rgba.fromString, "rgba(255, 0, 0, 0.5)");
81
- var x = Jest.Expect.expect(PolishedCss__Color.transparentize({
82
- NAME: "hex",
83
- VAL: "ff0000"
84
- }, 0.5));
85
- return Jest.Expect.toEqual(y, x);
86
- }));
87
- Jest.test("getContrast with hex", (function (param) {
88
- var x = Jest.Expect.expect(PolishedCss__Color.getContrast({
89
- NAME: "hex",
90
- VAL: "ff0000"
91
- }, {
92
- NAME: "hex",
93
- VAL: "0000ff"
94
- }));
95
- return Jest.Expect.toEqual(2.16, x);
96
- }));
97
- Jest.test("getLuminance with hex", (function (param) {
98
- var x = Jest.Expect.expect(PolishedCss__Color.getLuminance({
99
- NAME: "hex",
100
- VAL: "ff0000"
101
- }));
102
- return Jest.Expect.toEqual(0.213, x);
103
- }));
104
- Jest.test("grayscale with hex", (function (param) {
105
- var x = Jest.Expect.expect(PolishedCss__Color.grayscale({
106
- NAME: "hex",
107
- VAL: "ff0000"
108
- }));
109
- return Jest.Expect.toEqual({
110
- NAME: "hex",
111
- VAL: "808080"
112
- }, x);
113
- }));
114
- Jest.test("desaturate with hex", (function (param) {
115
- var x = Jest.Expect.expect(PolishedCss__Color.desaturate({
116
- NAME: "hex",
117
- VAL: "ff0000"
118
- }, 0.3));
119
- return Jest.Expect.toEqual({
120
- NAME: "hex",
121
- VAL: "d92626"
122
- }, x);
123
- }));
124
- Jest.test("complement with hex", (function (param) {
125
- var x = Jest.Expect.expect(PolishedCss__Color.complement({
126
- NAME: "hex",
127
- VAL: "ff0000"
128
- }));
129
- return Jest.Expect.toEqual({
130
- NAME: "hex",
131
- VAL: "0ff"
132
- }, x);
133
- }));
134
- Jest.test("adjustHue with hex", (function (param) {
135
- var x = Jest.Expect.expect(PolishedCss__Color.adjustHue({
136
- NAME: "hex",
137
- VAL: "ff0000"
138
- }, 0.3));
139
- return Jest.Expect.toEqual({
140
- NAME: "hex",
141
- VAL: "ff0100"
142
- }, x);
143
- }));
144
- return Jest.describe("Utils", (function (param) {
145
- Jest.test("fromString with hex", (function (param) {
146
- var x = Jest.Expect.expect(PolishedCss__Color.Utils.fromString("#ff0000"));
147
- return Jest.Expect.toEqual({
148
- NAME: "hex",
149
- VAL: "ff0000"
150
- }, x);
151
- }));
152
- return Jest.test("fromString with rgba", (function (param) {
153
- var x = Jest.Expect.expect(PolishedCss__Color.Utils.fromString("rgba(255, 0, 0, 0.5)"));
154
- return Jest.Expect.toEqual({
155
- NAME: "rgba",
156
- VAL: [
157
- 255,
158
- 0,
159
- 0,
160
- {
161
- NAME: "num",
162
- VAL: 0.5
163
- }
164
- ]
165
- }, x);
166
- }));
167
- }));
168
- }));
169
-
170
- exports.toEqual = toEqual;
171
- /* Not a pure module */
@@ -1,183 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
-
4
- var Jest = require("@glennsl/bs-jest/lib/js/src/jest.js");
5
- var Caml_option = require("bs-platform/lib/js/caml_option.js");
6
- var Polished__Math = require("../src/Polished__Math.js");
7
- var Polished__Color = require("../src/Polished__Color.js");
8
- var Polished__Mixins = require("../src/Polished__Mixins.js");
9
-
10
- function keepGoing(param) {
11
-
12
- }
13
-
14
- Jest.describe("Color", (function (param) {
15
- Jest.test("shade", (function (param) {
16
- return Jest.Expect.toBe("#b13c3c", Jest.Expect.expect(Polished__Color.shade("#ed5051", 0.25)));
17
- }));
18
- Jest.test("tint", (function (param) {
19
- return Jest.Expect.toBe("#f17b7c", Jest.Expect.expect(Polished__Color.tint("#ed5051", 0.25)));
20
- }));
21
- Jest.test("lighten", (function (param) {
22
- return Jest.Expect.toBe("#f9c4c4", Jest.Expect.expect(Polished__Color.lighten("#ed5051", 0.25)));
23
- }));
24
- Jest.test("darken", (function (param) {
25
- return Jest.Expect.toBe("#ac1213", Jest.Expect.expect(Polished__Color.darken("#ed5051", 0.25)));
26
- }));
27
- Jest.test("hsl", (function (param) {
28
- return Jest.Expect.toBe("#734d26", Jest.Expect.expect(Polished__Color.hsl(30, 0.5, 0.3)));
29
- }));
30
- Jest.test("adjustHue", (function (param) {
31
- return Jest.Expect.toBe("#ed9f50", Jest.Expect.expect(Polished__Color.adjustHue("#ed5051", 30.5)));
32
- }));
33
- Jest.test("complement", (function (param) {
34
- return Jest.Expect.toBe("#50edec", Jest.Expect.expect(Polished__Color.complement("#ed5051")));
35
- }));
36
- Jest.test("desaturate", (function (param) {
37
- return Jest.Expect.toBe("#9f9f9f", Jest.Expect.expect(Polished__Color.desaturate("#ed5051", 25.5)));
38
- }));
39
- Jest.test("getContrast", (function (param) {
40
- return Jest.Expect.toBe(3.58, Jest.Expect.expect(Polished__Color.getContrast("#ed5051", "#fff")));
41
- }));
42
- Jest.test("getLuminance", (function (param) {
43
- return Jest.Expect.toBe(0.243, Jest.Expect.expect(Polished__Color.getLuminance("#ed5051")));
44
- }));
45
- Jest.test("grayscale", (function (param) {
46
- return Jest.Expect.toBe("#9f9f9f", Jest.Expect.expect(Polished__Color.grayscale("#ed5051")));
47
- }));
48
- Jest.test("hsla", (function (param) {
49
- return Jest.Expect.toBe("rgba(96,159,106,0.5)", Jest.Expect.expect(Polished__Color.hsla(130, 0.25, 0.5, 0.5)));
50
- }));
51
- Jest.test("invert", (function (param) {
52
- return Jest.Expect.toBe("#12a6ae", Jest.Expect.expect(Polished__Color.invert("#ed5951")));
53
- }));
54
- Jest.test("meetsContrastGuidelines", (function (param) {
55
- var expected = {
56
- AA: true,
57
- AALarge: true,
58
- AAA: true,
59
- AAALarge: true
60
- };
61
- return Jest.Expect.toEqual(expected, Jest.Expect.expect(Polished__Color.meetsContrastGuidelines("#000000", "#ffffff")));
62
- }));
63
- Jest.test("transparentize", (function (param) {
64
- return Jest.Expect.toBe("rgba(237,80,81,0.5)", Jest.Expect.expect(Polished__Color.transparentize("#ed5051", 0.5)));
65
- }));
66
- Jest.test("hslToColorString", (function (param) {
67
- var hsl = {
68
- hue: 240,
69
- lightness: 1.0,
70
- saturation: 0.5
71
- };
72
- return Jest.Expect.toBe("#fff", Jest.Expect.expect(Polished__Color.hslToColorString(hsl)));
73
- }));
74
- Jest.test("mix", (function (param) {
75
- return Jest.Expect.toBe("#c58383", Jest.Expect.expect(Polished__Color.mix("#ed5051", "#bc9090", 0.2)));
76
- }));
77
- Jest.test("opacify", (function (param) {
78
- return Jest.Expect.toBe("rgba(237,80,81,0.5)", Jest.Expect.expect(Polished__Color.opacify("#ed505100", 0.5)));
79
- }));
80
- Jest.test("parseToHsl", (function (param) {
81
- var expected = {
82
- hue: 0.0,
83
- lightness: 0.5,
84
- saturation: 1.0
85
- };
86
- return Jest.Expect.toEqual(expected, Jest.Expect.expect(Polished__Color.parseToHsl("#FF0000")));
87
- }));
88
- Jest.test("parseToRgb", (function (param) {
89
- var expected = {
90
- red: 237,
91
- green: 80,
92
- blue: 81
93
- };
94
- return Jest.Expect.toEqual(expected, Jest.Expect.expect(Polished__Color.parseToRgb("#ed5051")));
95
- }));
96
- Jest.test("readableColor", (function (param) {
97
- Jest.Expect.toBe("#fff", Jest.Expect.expect(Polished__Color.readableColor("#ed5051", undefined, undefined, false, undefined)));
98
- Jest.Expect.toBe("#000", Jest.Expect.expect(Polished__Color.readableColor("#000", undefined, undefined, undefined, undefined)));
99
- Jest.Expect.toBe("#ff8", Jest.Expect.expect(Polished__Color.readableColor("black", undefined, "#ff8", undefined, undefined)));
100
- Jest.Expect.toBe("#001", Jest.Expect.expect(Polished__Color.readableColor("white", "#001", undefined, undefined, undefined)));
101
- Jest.Expect.toBe("#000", Jest.Expect.expect(Polished__Color.readableColor("red", "#333", "#ddd", true, undefined)));
102
- Jest.Expect.toBe("#333", Jest.Expect.expect(Polished__Color.readableColor("yellow", "#333", "#ddd", true, undefined)));
103
- return Jest.Expect.toBe("#ddd", Jest.Expect.expect(Polished__Color.readableColor("blue", "#333", "#ddd", true, undefined)));
104
- }));
105
- Jest.test("rgb", (function (param) {
106
- var subject = {
107
- red: 255,
108
- green: 255,
109
- blue: 255
110
- };
111
- return Jest.Expect.toBe("#fff", Jest.Expect.expect(Polished__Color.rgb(subject)));
112
- }));
113
- Jest.test("rgba", (function (param) {
114
- var subject = {
115
- red: 255,
116
- green: 205,
117
- blue: 100,
118
- alpha: 0.7
119
- };
120
- return Jest.Expect.toBe("rgba(255,205,100,0.7)", Jest.Expect.expect(Polished__Color.rgba(subject)));
121
- }));
122
- Jest.test("saturate", (function (param) {
123
- return Jest.Expect.toBe("#ff3e3f", Jest.Expect.expect(Polished__Color.saturate("#ed5051", 0.5)));
124
- }));
125
- Jest.test("setHue", (function (param) {
126
- return Jest.Expect.toBe("#cdae64", Jest.Expect.expect(Polished__Color.setHue("#CCCD64", 42)));
127
- }));
128
- Jest.test("setLightness", (function (param) {
129
- return Jest.Expect.toBe("#4d4d19", Jest.Expect.expect(Polished__Color.setLightness("#CCCD64", 0.2)));
130
- }));
131
- return Jest.test("setSaturation", (function (param) {
132
- return Jest.Expect.toBe("#adad84", Jest.Expect.expect(Polished__Color.setSaturation("#CCCD64", 0.2)));
133
- }));
134
- }));
135
-
136
- Jest.describe("Math", (function (param) {
137
- return Jest.test("math", (function (param) {
138
- Jest.Expect.toBe("20px", Jest.Expect.expect(Polished__Math.math("12px + 8px", undefined)));
139
- Jest.Expect.toBe("20rem", Jest.Expect.expect(Polished__Math.math("12rem + 8rem", undefined)));
140
- return Jest.Expect.toThrow(Jest.Expect.expect(function (param) {
141
- return Polished__Math.math("10px + 8rem", param);
142
- }));
143
- }));
144
- }));
145
-
146
- Jest.describe("Mixins", (function (param) {
147
- Jest.test("between", (function (param) {
148
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.between("400px", "1000px", Polished__Mixins.Size.makeString("16px"), Polished__Mixins.Size.makeString("100px"), undefined)));
149
- }));
150
- Jest.test("clearfix", (function (param) {
151
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.clearFix("div")));
152
- }));
153
- Jest.test("cover", (function (param) {
154
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.cover(Caml_option.some(Polished__Mixins.Size.makeString("16px")), undefined)));
155
- }));
156
- Jest.test("ellipsis", (function (param) {
157
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.ellipsis(Caml_option.some(Polished__Mixins.Size.makeString("16px")), 10, undefined)));
158
- }));
159
- Jest.test("fluidRange", (function (param) {
160
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.fluidRange("320px", "1024px", {
161
- prop: "padding",
162
- fromSize: Polished__Mixins.Size.makeString("20px"),
163
- toSize: Polished__Mixins.Size.makeString("20px")
164
- })));
165
- }));
166
- return Jest.test("fluidRangeWithArray", (function (param) {
167
- return Jest.Expect.toMatchSnapshot(Jest.Expect.expect(Polished__Mixins.fluidRangeWithArray("320px", "1024px", [
168
- {
169
- prop: "padding",
170
- fromSize: Polished__Mixins.Size.makeString("16px"),
171
- toSize: Polished__Mixins.Size.makeString("32px")
172
- },
173
- {
174
- prop: "margin",
175
- fromSize: Polished__Mixins.Size.makeString("16px"),
176
- toSize: Polished__Mixins.Size.makeString("32px")
177
- }
178
- ])));
179
- }));
180
- }));
181
-
182
- exports.keepGoing = keepGoing;
183
- /* Not a pure module */