git.iko.soy/purestack-dev/purescript-plum
on master help sign in
pseudoclasses
7a49683iko
plum/index.js+481−61
@@ -23,6 +23,9 @@
23 }
23 }
24 };
24 };
25
25
26+ // output/Data.Boolean/index.js
27+ var otherwise = true;
28+
26 // output/Data.Function/index.js
29 // output/Data.Function/index.js
27 var flip = function(f) {
30 var flip = function(f) {
28 return function(b) {
31 return function(b) {
@@ -31,6 +34,11 @@
31 };
34 };
32 };
35 };
33 };
36 };
37+ var $$const = function(a) {
38+ return function(v) {
39+ return a;
40+ };
41+ };
34 var applyFlipped = function(x) {
42 var applyFlipped = function(x) {
35 return function(f) {
43 return function(f) {
36 return f(x);
44 return f(x);
@@ -161,6 +169,42 @@
161 };
169 };
162 };
170 };
163
171
172+ // output/Data.Eq/foreign.js
173+ var refEq = function(r1) {
174+ return function(r2) {
175+ return r1 === r2;
176+ };
177+ };
178+ var eqIntImpl = refEq;
179+
180+ // output/Data.Eq/index.js
181+ var eqInt = {
182+ eq: eqIntImpl
183+ };
184+
185+ // output/Data.Ordering/index.js
186+ var LT = /* @__PURE__ */ function() {
187+ function LT2() {
188+ }
189+ ;
190+ LT2.value = new LT2();
191+ return LT2;
192+ }();
193+ var GT = /* @__PURE__ */ function() {
194+ function GT2() {
195+ }
196+ ;
197+ GT2.value = new GT2();
198+ return GT2;
199+ }();
200+ var EQ = /* @__PURE__ */ function() {
201+ function EQ2() {
202+ }
203+ ;
204+ EQ2.value = new EQ2();
205+ return EQ2;
206+ }();
207+
164 // output/Data.Semigroup/foreign.js
208 // output/Data.Semigroup/foreign.js
165 var concatString = function(s1) {
209 var concatString = function(s1) {
166 return function(s2) {
210 return function(s2) {
@@ -224,9 +268,9 @@
224 return function(rb) {
268 return function(rb) {
225 var tail = appendRecord1($$Proxy.value)(ra)(rb);
269 var tail = appendRecord1($$Proxy.value)(ra)(rb);
226 var key = reflectSymbol2($$Proxy.value);
270 var key = reflectSymbol2($$Proxy.value);
227− var insert = unsafeSet(key);
271+ var insert2 = unsafeSet(key);
228 var get = unsafeGet(key);
272 var get = unsafeGet(key);
229− return insert(append1(get(ra))(get(rb)))(tail);
273+ return insert2(append1(get(ra))(get(rb)))(tail);
230 };
274 };
231 };
275 };
232 }
276 }
@@ -295,8 +339,8 @@
295 memptyRecord: function(v) {
339 memptyRecord: function(v) {
296 var tail = memptyRecord1($$Proxy.value);
340 var tail = memptyRecord1($$Proxy.value);
297 var key = reflectSymbol2($$Proxy.value);
341 var key = reflectSymbol2($$Proxy.value);
298− var insert = unsafeSet(key);
342+ var insert2 = unsafeSet(key);
299− return insert(mempty12)(tail);
343+ return insert2(mempty12)(tail);
300 },
344 },
301 SemigroupRecord0: function() {
345 SemigroupRecord0: function() {
302 return semigroupRecordCons1;
346 return semigroupRecordCons1;
@@ -411,7 +455,7 @@
411 var result = [];
455 var result = [];
412 for (var i = 0, l = xss.length; i < l; i++) {
456 for (var i = 0, l = xss.length; i < l; i++) {
413 var xs = xss[i];
457 var xs = xss[i];
414− for (var j = 0, m = xs.length; j < m; j++) {
458+ for (var j = 0, m2 = xs.length; j < m2; j++) {
415 result.push(xs[j]);
459 result.push(xs[j]);
416 }
460 }
417 }
461 }
@@ -419,11 +463,52 @@
419 };
463 };
420
464
421 // output/Data.Bounded/foreign.js
465 // output/Data.Bounded/foreign.js
466+ var topInt = 2147483647;
467+ var bottomInt = -2147483648;
422 var topChar = String.fromCharCode(65535);
468 var topChar = String.fromCharCode(65535);
423 var bottomChar = String.fromCharCode(0);
469 var bottomChar = String.fromCharCode(0);
424 var topNumber = Number.POSITIVE_INFINITY;
470 var topNumber = Number.POSITIVE_INFINITY;
425 var bottomNumber = Number.NEGATIVE_INFINITY;
471 var bottomNumber = Number.NEGATIVE_INFINITY;
426
472
473+ // output/Data.Ord/foreign.js
474+ var unsafeCompareImpl = function(lt) {
475+ return function(eq2) {
476+ return function(gt) {
477+ return function(x) {
478+ return function(y) {
479+ return x < y ? lt : x === y ? eq2 : gt;
480+ };
481+ };
482+ };
483+ };
484+ };
485+ var ordIntImpl = unsafeCompareImpl;
486+
487+ // output/Data.Ord/index.js
488+ var ordInt = /* @__PURE__ */ function() {
489+ return {
490+ compare: ordIntImpl(LT.value)(EQ.value)(GT.value),
491+ Eq0: function() {
492+ return eqInt;
493+ }
494+ };
495+ }();
496+
497+ // output/Data.Bounded/index.js
498+ var top = function(dict) {
499+ return dict.top;
500+ };
501+ var boundedInt = {
502+ top: topInt,
503+ bottom: bottomInt,
504+ Ord0: function() {
505+ return ordInt;
506+ }
507+ };
508+ var bottom = function(dict) {
509+ return dict.bottom;
510+ };
511+
427 // output/Data.Show/foreign.js
512 // output/Data.Show/foreign.js
428 var showIntImpl = function(n) {
513 var showIntImpl = function(n) {
429 return n.toString();
514 return n.toString();
@@ -488,8 +573,8 @@
488 };
573 };
489 var functorIdentity = {
574 var functorIdentity = {
490 map: function(f) {
575 map: function(f) {
491− return function(m) {
576+ return function(m2) {
492− return f(m);
577+ return f(m2);
493 };
578 };
494 }
579 }
495 };
580 };
@@ -656,6 +741,11 @@
656 };
741 };
657 return Tuple2;
742 return Tuple2;
658 }();
743 }();
744+ var uncurry = function(f) {
745+ return function(v) {
746+ return f(v.value0)(v.value1);
747+ };
748+ };
659
749
660 // output/Unsafe.Coerce/foreign.js
750 // output/Unsafe.Coerce/foreign.js
661 var unsafeCoerce2 = function(x) {
751 var unsafeCoerce2 = function(x) {
@@ -711,12 +801,12 @@
711 };
801 };
712 };
802 };
713 var foldMapDefaultR = function(dictFoldable) {
803 var foldMapDefaultR = function(dictFoldable) {
714− var foldr2 = foldr(dictFoldable);
804+ var foldr22 = foldr(dictFoldable);
715 return function(dictMonoid) {
805 return function(dictMonoid) {
716 var append3 = append(dictMonoid.Semigroup0());
806 var append3 = append(dictMonoid.Semigroup0());
717 var mempty5 = mempty(dictMonoid);
807 var mempty5 = mempty(dictMonoid);
718 return function(f) {
808 return function(f) {
719− return foldr2(function(x) {
809+ return foldr22(function(x) {
720 return function(acc) {
810 return function(acc) {
721 return append3(f(x))(acc);
811 return append3(f(x))(acc);
722 };
812 };
@@ -779,8 +869,8 @@
779 return function(pure4) {
869 return function(pure4) {
780 return function(f) {
870 return function(f) {
781 return function(array) {
871 return function(array) {
782− function go2(bot, top2) {
872+ function go2(bot, top3) {
783− switch (top2 - bot) {
873+ switch (top3 - bot) {
784 case 0:
874 case 0:
785 return pure4([]);
875 return pure4([]);
786 case 1:
876 case 1:
@@ -790,8 +880,8 @@
790 case 3:
880 case 3:
791 return apply2(apply2(map4(array3)(f(array[bot])))(f(array[bot + 1])))(f(array[bot + 2]));
881 return apply2(apply2(map4(array3)(f(array[bot])))(f(array[bot + 1])))(f(array[bot + 2]));
792 default:
882 default:
793− var pivot = bot + Math.floor((top2 - bot) / 4) * 2;
883+ var pivot = bot + Math.floor((top3 - bot) / 4) * 2;
794− return apply2(map4(concat2)(go2(bot, pivot)))(go2(pivot, top2));
884+ return apply2(map4(concat2)(go2(bot, pivot)))(go2(pivot, top3));
795 }
885 }
796 }
886 }
797 return go2(0, array.length);
887 return go2(0, array.length);
@@ -1614,9 +1704,9 @@
1614 }
1704 }
1615 function replace(projector) {
1705 function replace(projector) {
1616 return function(el) {
1706 return function(el) {
1617− return function(render3) {
1707+ return function(render4) {
1618 return function() {
1708 return function() {
1619− projector.replace(el, render3);
1709+ projector.replace(el, render4);
1620 };
1710 };
1621 };
1711 };
1622 };
1712 };
@@ -1789,13 +1879,63 @@
1789 return unwrap2(runWriterT($5));
1879 return unwrap2(runWriterT($5));
1790 };
1880 };
1791
1881
1882+ // output/Data.Int/foreign.js
1883+ var fromNumberImpl = function(just) {
1884+ return function(nothing) {
1885+ return function(n) {
1886+ return (n | 0) === n ? just(n) : nothing;
1887+ };
1888+ };
1889+ };
1890+ var toNumber = function(n) {
1891+ return n;
1892+ };
1893+
1894+ // output/Data.Number/foreign.js
1895+ var isFiniteImpl = isFinite;
1896+ var round = Math.round;
1897+
1898+ // output/Data.Int/index.js
1899+ var top2 = /* @__PURE__ */ top(boundedInt);
1900+ var bottom2 = /* @__PURE__ */ bottom(boundedInt);
1901+ var fromNumber = /* @__PURE__ */ function() {
1902+ return fromNumberImpl(Just.create)(Nothing.value);
1903+ }();
1904+ var unsafeClamp = function(x) {
1905+ if (!isFiniteImpl(x)) {
1906+ return 0;
1907+ }
1908+ ;
1909+ if (x >= toNumber(top2)) {
1910+ return top2;
1911+ }
1912+ ;
1913+ if (x <= toNumber(bottom2)) {
1914+ return bottom2;
1915+ }
1916+ ;
1917+ if (otherwise) {
1918+ return fromMaybe(0)(fromNumber(x));
1919+ }
1920+ ;
1921+ throw new Error("Failed pattern match at Data.Int (line 72, column 1 - line 72, column 29): " + [x.constructor.name]);
1922+ };
1923+ var round2 = function($37) {
1924+ return unsafeClamp(round($37));
1925+ };
1926+
1927+ // output/Data.TraversableWithIndex/index.js
1928+ var traverseWithIndex = function(dict) {
1929+ return dict.traverseWithIndex;
1930+ };
1931+
1792 // output/Foreign.Object/foreign.js
1932 // output/Foreign.Object/foreign.js
1793− function _copyST(m) {
1933+ function _copyST(m2) {
1794 return function() {
1934 return function() {
1795 var r = {};
1935 var r = {};
1796− for (var k in m) {
1936+ for (var k in m2) {
1797− if (hasOwnProperty.call(m, k)) {
1937+ if (hasOwnProperty.call(m2, k)) {
1798− r[k] = m[k];
1938+ r[k] = m2[k];
1799 }
1939 }
1800 }
1940 }
1801 return r;
1941 return r;
@@ -1805,18 +1945,36 @@
1805 function runST(f) {
1945 function runST(f) {
1806 return f();
1946 return f();
1807 }
1947 }
1948+ function _fmapObject(m0, f) {
1949+ var m2 = {};
1950+ for (var k in m0) {
1951+ if (hasOwnProperty.call(m0, k)) {
1952+ m2[k] = f(m0[k]);
1953+ }
1954+ }
1955+ return m2;
1956+ }
1957+ function _mapWithKey(m0, f) {
1958+ var m2 = {};
1959+ for (var k in m0) {
1960+ if (hasOwnProperty.call(m0, k)) {
1961+ m2[k] = f(k)(m0[k]);
1962+ }
1963+ }
1964+ return m2;
1965+ }
1808 function _foldM(bind4) {
1966 function _foldM(bind4) {
1809 return function(f) {
1967 return function(f) {
1810 return function(mz) {
1968 return function(mz) {
1811− return function(m) {
1969+ return function(m2) {
1812 var acc = mz;
1970 var acc = mz;
1813 function g(k2) {
1971 function g(k2) {
1814 return function(z) {
1972 return function(z) {
1815− return f(z)(k2)(m[k2]);
1973+ return f(z)(k2)(m2[k2]);
1816 };
1974 };
1817 }
1975 }
1818− for (var k in m) {
1976+ for (var k in m2) {
1819− if (hasOwnProperty.call(m, k)) {
1977+ if (hasOwnProperty.call(m2, k)) {
1820 acc = bind4(acc)(g(k));
1978 acc = bind4(acc)(g(k));
1821 }
1979 }
1822 }
1980 }
@@ -1826,11 +1984,11 @@
1826 };
1984 };
1827 }
1985 }
1828 function toArrayWithKey(f) {
1986 function toArrayWithKey(f) {
1829− return function(m) {
1987+ return function(m2) {
1830 var r = [];
1988 var r = [];
1831− for (var k in m) {
1989+ for (var k in m2) {
1832− if (hasOwnProperty.call(m, k)) {
1990+ if (hasOwnProperty.call(m2, k)) {
1833− r.push(f(k)(m[k]));
1991+ r.push(f(k)(m2[k]));
1834 }
1992 }
1835 }
1993 }
1836 return r;
1994 return r;
@@ -1848,10 +2006,10 @@
1848 };
2006 };
1849 function poke2(k) {
2007 function poke2(k) {
1850 return function(v) {
2008 return function(v) {
1851− return function(m) {
2009+ return function(m2) {
1852 return function() {
2010 return function() {
1853− m[k] = v;
2011+ m2[k] = v;
1854− return m;
2012+ return m2;
1855 };
2013 };
1856 };
2014 };
1857 };
2015 };
@@ -1859,6 +2017,13 @@
1859
2017
1860 // output/Foreign.Object/index.js
2018 // output/Foreign.Object/index.js
1861 var bindFlipped2 = /* @__PURE__ */ bindFlipped(bindST);
2019 var bindFlipped2 = /* @__PURE__ */ bindFlipped(bindST);
2020+ var foldr2 = /* @__PURE__ */ foldr(foldableArray);
2021+ var identity4 = /* @__PURE__ */ identity(categoryFn);
2022+ var values = /* @__PURE__ */ toArrayWithKey(function(v) {
2023+ return function(v1) {
2024+ return v1;
2025+ };
2026+ });
1862 var thawST = _copyST;
2027 var thawST = _copyST;
1863 var singleton2 = function(k) {
2028 var singleton2 = function(k) {
1864 return function(v) {
2029 return function(v) {
@@ -1866,14 +2031,37 @@
1866 };
2031 };
1867 };
2032 };
1868 var mutate = function(f) {
2033 var mutate = function(f) {
1869− return function(m) {
2034+ return function(m2) {
1870 return runST(function __do() {
2035 return runST(function __do() {
1871− var s = thawST(m)();
2036+ var s = thawST(m2)();
1872 f(s)();
2037 f(s)();
1873 return s;
2038 return s;
1874 });
2039 });
1875 };
2040 };
1876 };
2041 };
2042+ var mapWithKey = function(f) {
2043+ return function(m2) {
2044+ return _mapWithKey(m2, f);
2045+ };
2046+ };
2047+ var insert = function(k) {
2048+ return function(v) {
2049+ return mutate(poke2(k)(v));
2050+ };
2051+ };
2052+ var functorObject = {
2053+ map: function(f) {
2054+ return function(m2) {
2055+ return _fmapObject(m2, f);
2056+ };
2057+ }
2058+ };
2059+ var functorWithIndexObject = {
2060+ mapWithIndex: mapWithKey,
2061+ Functor0: function() {
2062+ return functorObject;
2063+ }
2064+ };
1877 var foldM = function(dictMonad) {
2065 var foldM = function(dictMonad) {
1878 var bind1 = bind(dictMonad.Bind1());
2066 var bind1 = bind(dictMonad.Bind1());
1879 var pure1 = pure(dictMonad.Applicative0());
2067 var pure1 = pure(dictMonad.Applicative0());
@@ -1884,7 +2072,7 @@
1884 };
2072 };
1885 };
2073 };
1886 var foldM1 = /* @__PURE__ */ foldM(monadST);
2074 var foldM1 = /* @__PURE__ */ foldM(monadST);
1887− var union = function(m) {
2075+ var union = function(m2) {
1888 return mutate(function(s) {
2076 return mutate(function(s) {
1889 return foldM1(function(s$prime) {
2077 return foldM1(function(s$prime) {
1890 return function(k) {
2078 return function(k) {
@@ -1892,7 +2080,7 @@
1892 return poke2(k)(v)(s$prime);
2080 return poke2(k)(v)(s$prime);
1893 };
2081 };
1894 };
2082 };
1895− })(s)(m);
2083+ })(s)(m2);
1896 });
2084 });
1897 };
2085 };
1898 var fold2 = /* @__PURE__ */ _foldM(applyFlipped);
2086 var fold2 = /* @__PURE__ */ _foldM(applyFlipped);
@@ -1909,6 +2097,91 @@
1909 })(mempty5);
2097 })(mempty5);
1910 };
2098 };
1911 };
2099 };
2100+ var foldableObject = {
2101+ foldl: function(f) {
2102+ return fold2(function(z) {
2103+ return function(v) {
2104+ return f(z);
2105+ };
2106+ });
2107+ },
2108+ foldr: function(f) {
2109+ return function(z) {
2110+ return function(m2) {
2111+ return foldr2(f)(z)(values(m2));
2112+ };
2113+ };
2114+ },
2115+ foldMap: function(dictMonoid) {
2116+ var foldMap1 = foldMap2(dictMonoid);
2117+ return function(f) {
2118+ return foldMap1($$const(f));
2119+ };
2120+ }
2121+ };
2122+ var foldableWithIndexObject = {
2123+ foldlWithIndex: function(f) {
2124+ return fold2(flip(f));
2125+ },
2126+ foldrWithIndex: function(f) {
2127+ return function(z) {
2128+ return function(m2) {
2129+ return foldr2(uncurry(f))(z)(toArrayWithKey(Tuple.create)(m2));
2130+ };
2131+ };
2132+ },
2133+ foldMapWithIndex: function(dictMonoid) {
2134+ return foldMap2(dictMonoid);
2135+ },
2136+ Foldable0: function() {
2137+ return foldableObject;
2138+ }
2139+ };
2140+ var traversableWithIndexObject = {
2141+ traverseWithIndex: function(dictApplicative) {
2142+ var Apply0 = dictApplicative.Apply0();
2143+ var apply2 = apply(Apply0);
2144+ var map4 = map(Apply0.Functor0());
2145+ var pure1 = pure(dictApplicative);
2146+ return function(f) {
2147+ return function(ms) {
2148+ return fold2(function(acc) {
2149+ return function(k) {
2150+ return function(v) {
2151+ return apply2(map4(flip(insert(k)))(acc))(f(k)(v));
2152+ };
2153+ };
2154+ })(pure1(empty2))(ms);
2155+ };
2156+ };
2157+ },
2158+ FunctorWithIndex0: function() {
2159+ return functorWithIndexObject;
2160+ },
2161+ FoldableWithIndex1: function() {
2162+ return foldableWithIndexObject;
2163+ },
2164+ Traversable2: function() {
2165+ return traversableObject;
2166+ }
2167+ };
2168+ var traversableObject = {
2169+ traverse: function(dictApplicative) {
2170+ var $96 = traverseWithIndex(traversableWithIndexObject)(dictApplicative);
2171+ return function($97) {
2172+ return $96($$const($97));
2173+ };
2174+ },
2175+ sequence: function(dictApplicative) {
2176+ return traverse(traversableObject)(dictApplicative)(identity4);
2177+ },
2178+ Functor0: function() {
2179+ return functorObject;
2180+ },
2181+ Foldable1: function() {
2182+ return foldableObject;
2183+ }
2184+ };
1912
2185
1913 // output/Record.Unsafe.Union/foreign.js
2186 // output/Record.Unsafe.Union/foreign.js
1914 function unsafeUnionFn(r1, r2) {
2187 function unsafeUnionFn(r1, r2) {
@@ -1959,15 +2232,44 @@
1959 };
2232 };
1960 var semigroupRecordCons2 = /* @__PURE__ */ semigroupRecordCons(childrenIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(downIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(hoverIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(meatIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(nervesIsSymbol)()(semigroupRecordNil)(semigroupArray))(semigroupArray))(semigroupArray))(semigroupArray));
2233 var semigroupRecordCons2 = /* @__PURE__ */ semigroupRecordCons(childrenIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(downIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(hoverIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(meatIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(nervesIsSymbol)()(semigroupRecordNil)(semigroupArray))(semigroupArray))(semigroupArray))(semigroupArray));
1961 var show2 = /* @__PURE__ */ show(showInt);
2234 var show2 = /* @__PURE__ */ show(showInt);
1962− var show1 = /* @__PURE__ */ show(showNumber);
1963 var mempty2 = /* @__PURE__ */ mempty(monoidArray);
2235 var mempty2 = /* @__PURE__ */ mempty(monoidArray);
1964 var monoidRecord2 = /* @__PURE__ */ monoidRecord();
2236 var monoidRecord2 = /* @__PURE__ */ monoidRecord();
1965 var monoidRecordCons2 = /* @__PURE__ */ monoidRecordCons(childrenIsSymbol);
2237 var monoidRecordCons2 = /* @__PURE__ */ monoidRecordCons(childrenIsSymbol);
1966 var monoidRecordCons1 = /* @__PURE__ */ monoidRecordCons(downIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(hoverIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(meatIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(nervesIsSymbol)(monoidArray)()(monoidRecordNil))));
2238 var monoidRecordCons1 = /* @__PURE__ */ monoidRecordCons(downIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(hoverIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(meatIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(nervesIsSymbol)(monoidArray)()(monoidRecordNil))));
1967 var mempty1 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidRecord2(/* @__PURE__ */ monoidRecordCons2(monoidArray)()(monoidRecordCons1)));
2239 var mempty1 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidRecord2(/* @__PURE__ */ monoidRecordCons2(monoidArray)()(monoidRecordCons1)));
1968 var foldMap3 = /* @__PURE__ */ foldMap2(monoidString);
2240 var foldMap3 = /* @__PURE__ */ foldMap2(monoidString);
2241+ var show1 = /* @__PURE__ */ show(showNumber);
1969 var intercalate3 = /* @__PURE__ */ intercalate2(monoidString);
2242 var intercalate3 = /* @__PURE__ */ intercalate2(monoidString);
1970 var map2 = /* @__PURE__ */ map(/* @__PURE__ */ functorWriterT(functorIdentity));
2243 var map2 = /* @__PURE__ */ map(/* @__PURE__ */ functorWriterT(functorIdentity));
2244+ var map1 = /* @__PURE__ */ map(functorArray);
2245+ var Top = /* @__PURE__ */ function() {
2246+ function Top2() {
2247+ }
2248+ ;
2249+ Top2.value = new Top2();
2250+ return Top2;
2251+ }();
2252+ var Right2 = /* @__PURE__ */ function() {
2253+ function Right3() {
2254+ }
2255+ ;
2256+ Right3.value = new Right3();
2257+ return Right3;
2258+ }();
2259+ var Bottom = /* @__PURE__ */ function() {
2260+ function Bottom2() {
2261+ }
2262+ ;
2263+ Bottom2.value = new Bottom2();
2264+ return Bottom2;
2265+ }();
2266+ var Left2 = /* @__PURE__ */ function() {
2267+ function Left3() {
2268+ }
2269+ ;
2270+ Left3.value = new Left3();
2271+ return Left3;
2272+ }();
1971 var Px = /* @__PURE__ */ function() {
2273 var Px = /* @__PURE__ */ function() {
1972 function Px2(value0) {
2274 function Px2(value0) {
1973 this.value0 = value0;
2275 this.value0 = value0;
@@ -2155,12 +2457,15 @@
2155 return BackgroundColor2;
2457 return BackgroundColor2;
2156 }();
2458 }();
2157 var Padding = /* @__PURE__ */ function() {
2459 var Padding = /* @__PURE__ */ function() {
2158− function Padding2(value0) {
2460+ function Padding2(value0, value1) {
2159 this.value0 = value0;
2461 this.value0 = value0;
2462+ this.value1 = value1;
2160 }
2463 }
2161 ;
2464 ;
2162 Padding2.create = function(value0) {
2465 Padding2.create = function(value0) {
2466+ return function(value1) {
2163− return new Padding2(value0);
2467+ return new Padding2(value0, value1);
2468+ };
2164 };
2469 };
2165 return Padding2;
2470 return Padding2;
2166 }();
2471 }();
@@ -2356,12 +2661,52 @@
2356 };
2661 };
2357 };
2662 };
2358 };
2663 };
2664+ var renderableSide = {
2665+ render: function(v) {
2666+ if (v instanceof Top) {
2667+ return "top";
2668+ }
2669+ ;
2670+ if (v instanceof Right2) {
2671+ return "right";
2672+ }
2673+ ;
2674+ if (v instanceof Bottom) {
2675+ return "bottom";
2676+ }
2677+ ;
2678+ if (v instanceof Left2) {
2679+ return "left";
2680+ }
2681+ ;
2682+ throw new Error("Failed pattern match at Plum.View (line 263, column 12 - line 267, column 19): " + [v.constructor.name]);
2683+ },
2684+ renderKey: function(v) {
2685+ if (v instanceof Top) {
2686+ return "top";
2687+ }
2688+ ;
2689+ if (v instanceof Right2) {
2690+ return "right";
2691+ }
2692+ ;
2693+ if (v instanceof Bottom) {
2694+ return "bottom";
2695+ }
2696+ ;
2697+ if (v instanceof Left2) {
2698+ return "left";
2699+ }
2700+ ;
2701+ throw new Error("Failed pattern match at Plum.View (line 268, column 15 - line 272, column 19): " + [v.constructor.name]);
2702+ }
2703+ };
2359 var renderableColor = {
2704 var renderableColor = {
2360 render: function(v) {
2705 render: function(v) {
2361− return "rgba(" + (show2(v.r) + ("," + (show2(v.g) + ("," + (show2(v.b) + ("," + (show1(v.a) + ")")))))));
2706+ return "rgb(" + (show2(v.r) + ("," + (show2(v.g) + ("," + (show2(v.b) + ("," + (show2(v.a) + "%)")))))));
2362 },
2707 },
2363 renderKey: function(v) {
2708 renderKey: function(v) {
2364− return show2(v.r) + ("-" + (show2(v.g) + ("-" + (show2(v.b) + ("-" + show1(v.a))))));
2709+ return show2(v.r) + ("-" + (show2(v.g) + ("-" + (show2(v.b) + ("-" + show2(v.a))))));
2365 }
2710 }
2366 };
2711 };
2367 var monoidSkinGrowth = {
2712 var monoidSkinGrowth = {
@@ -2375,6 +2720,7 @@
2375 var pure2 = /* @__PURE__ */ pure(applicativeWriterT2);
2720 var pure2 = /* @__PURE__ */ pure(applicativeWriterT2);
2376 var mempty22 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidWriterT(applicativeIdentity)(monoidSkinGrowth)(monoidArray));
2721 var mempty22 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidWriterT(applicativeIdentity)(monoidSkinGrowth)(monoidArray));
2377 var traverse2 = /* @__PURE__ */ traverse(traversableArray)(applicativeWriterT2);
2722 var traverse2 = /* @__PURE__ */ traverse(traversableArray)(applicativeWriterT2);
2723+ var traverseWithIndex2 = /* @__PURE__ */ traverseWithIndex(traversableWithIndexObject)(applicativeWriterT2);
2378 var monoidMutation = {
2724 var monoidMutation = {
2379 mempty: {
2725 mempty: {
2380 extraSkin: mempty2
2726 extraSkin: mempty2
@@ -2467,14 +2813,28 @@
2467 };
2813 };
2468 };
2814 };
2469 };
2815 };
2816+ var rgb = function(r) {
2817+ return function(g) {
2818+ return function(b) {
2819+ return {
2820+ r: round2(r * 255),
2821+ g: round2(g * 255),
2822+ b: round2(b * 255),
2823+ a: 100
2824+ };
2825+ };
2826+ };
2827+ };
2470 var renderKey = function(dict) {
2828 var renderKey = function(dict) {
2471 return dict.renderKey;
2829 return dict.renderKey;
2472 };
2830 };
2473 var renderKey1 = /* @__PURE__ */ renderKey(renderableColor);
2831 var renderKey1 = /* @__PURE__ */ renderKey(renderableColor);
2832+ var renderKey2 = /* @__PURE__ */ renderKey(renderableSide);
2474 var render = function(dict) {
2833 var render = function(dict) {
2475 return dict.render;
2834 return dict.render;
2476 };
2835 };
2477 var render1 = /* @__PURE__ */ render(renderableColor);
2836 var render1 = /* @__PURE__ */ render(renderableColor);
2837+ var render2 = /* @__PURE__ */ render(renderableSide);
2478 var renderableLength = {
2838 var renderableLength = {
2479 render: function(v) {
2839 render: function(v) {
2480 if (v instanceof Px) {
2840 if (v instanceof Px) {
@@ -2497,7 +2857,7 @@
2497 return "min(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
2857 return "min(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
2498 }
2858 }
2499 ;
2859 ;
2500− throw new Error("Failed pattern match at Plum.View (line 295, column 12 - line 300, column 62): " + [v.constructor.name]);
2860+ throw new Error("Failed pattern match at Plum.View (line 362, column 12 - line 367, column 62): " + [v.constructor.name]);
2501 },
2861 },
2502 renderKey: function(v) {
2862 renderKey: function(v) {
2503 if (v instanceof Px) {
2863 if (v instanceof Px) {
@@ -2520,11 +2880,11 @@
2520 return "min-" + (show2(v.value0) + ("-" + renderKey(renderableLength)(v.value1)));
2880 return "min-" + (show2(v.value0) + ("-" + renderKey(renderableLength)(v.value1)));
2521 }
2881 }
2522 ;
2882 ;
2523− throw new Error("Failed pattern match at Plum.View (line 301, column 15 - line 306, column 56): " + [v.constructor.name]);
2883+ throw new Error("Failed pattern match at Plum.View (line 368, column 15 - line 373, column 56): " + [v.constructor.name]);
2524 }
2884 }
2525 };
2885 };
2526− var renderKey2 = /* @__PURE__ */ renderKey(renderableLength);
2886+ var renderKey3 = /* @__PURE__ */ renderKey(renderableLength);
2527− var render2 = /* @__PURE__ */ render(renderableLength);
2887+ var render3 = /* @__PURE__ */ render(renderableLength);
2528 var skin = function(ctx) {
2888 var skin = function(ctx) {
2529 return function(v) {
2889 return function(v) {
2530 if (v instanceof Spacing) {
2890 if (v instanceof Spacing) {
@@ -2558,7 +2918,7 @@
2558 return "end";
2918 return "end";
2559 }
2919 }
2560 ;
2920 ;
2561− throw new Error("Failed pattern match at Plum.View (line 244, column 13 - line 247, column 27): " + [v.value1.constructor.name]);
2921+ throw new Error("Failed pattern match at Plum.View (line 311, column 13 - line 314, column 27): " + [v.value1.constructor.name]);
2562 }();
2922 }();
2563 var k = function() {
2923 var k = function() {
2564 if (v.value0 instanceof X) {
2924 if (v.value0 instanceof X) {
@@ -2569,7 +2929,7 @@
2569 return "align-items";
2929 return "align-items";
2570 }
2930 }
2571 ;
2931 ;
2572− throw new Error("Failed pattern match at Plum.View (line 239, column 13 - line 241, column 33): " + [v.value0.constructor.name]);
2932+ throw new Error("Failed pattern match at Plum.View (line 306, column 13 - line 308, column 33): " + [v.value0.constructor.name]);
2573 }();
2933 }();
2574 return sk("align-grid-" + (k + ("-" + v1)))(k)(v1);
2934 return sk("align-grid-" + (k + ("-" + v1)))(k)(v1);
2575 }
2935 }
@@ -2588,7 +2948,7 @@
2588 return "flex-end";
2948 return "flex-end";
2589 }
2949 }
2590 ;
2950 ;
2591− throw new Error("Failed pattern match at Plum.View (line 263, column 13 - line 266, column 32): " + [v.value1.constructor.name]);
2951+ throw new Error("Failed pattern match at Plum.View (line 330, column 13 - line 333, column 32): " + [v.value1.constructor.name]);
2592 }();
2952 }();
2593 var k = function() {
2953 var k = function() {
2594 var v2 = new Tuple(ctx.value0, v.value0);
2954 var v2 = new Tuple(ctx.value0, v.value0);
@@ -2608,20 +2968,20 @@
2608 return "justify-content";
2968 return "justify-content";
2609 }
2969 }
2610 ;
2970 ;
2611− throw new Error("Failed pattern match at Plum.View (line 255, column 13 - line 259, column 42): " + [v2.constructor.name]);
2971+ throw new Error("Failed pattern match at Plum.View (line 322, column 13 - line 326, column 42): " + [v2.constructor.name]);
2612 }();
2972 }();
2613 return sk("align-flexbox-" + (k + ("-" + v1)))(k)(v1);
2973 return sk("align-flexbox-" + (k + ("-" + v1)))(k)(v1);
2614 }
2974 }
2615 ;
2975 ;
2616− throw new Error("Failed pattern match at Plum.View (line 233, column 26 - line 269, column 51): " + [ctx.constructor.name]);
2976+ throw new Error("Failed pattern match at Plum.View (line 300, column 26 - line 336, column 51): " + [ctx.constructor.name]);
2617 }
2977 }
2618 ;
2978 ;
2619 if (v instanceof Width) {
2979 if (v instanceof Width) {
2620− return sk("width-" + renderKey2(v.value0))("width")(render2(v.value0));
2980+ return sk("width-" + renderKey3(v.value0))("width")(render3(v.value0));
2621 }
2981 }
2622 ;
2982 ;
2623 if (v instanceof Height) {
2983 if (v instanceof Height) {
2624− return sk("width-" + renderKey2(v.value0))("height")(render2(v.value0));
2984+ return sk("height-" + renderKey3(v.value0))("height")(render3(v.value0));
2625 }
2985 }
2626 ;
2986 ;
2627 if (v instanceof Wrapped) {
2987 if (v instanceof Wrapped) {
@@ -2637,7 +2997,7 @@
2637 }
2997 }
2638 ;
2998 ;
2639 if (v instanceof Padding) {
2999 if (v instanceof Padding) {
2640− return sk("padding-" + (show2(v.value0.top) + ("-" + (show2(v.value0.right) + ("-" + (show2(v.value0.bottom) + ("-" + show2(v.value0.left))))))))("padding")(show2(v.value0.top) + ("px " + (show2(v.value0.right) + ("px " + (show2(v.value0.bottom) + ("px " + (show2(v.value0.left) + "px")))))));
3000+ return sk("padding-" + (renderKey2(v.value0) + ("-" + show2(v.value1))))("padding-" + render2(v.value0))(show2(v.value1) + "px");
2641 }
3001 }
2642 ;
3002 ;
2643 if (v instanceof Spread) {
3003 if (v instanceof Spread) {
@@ -2668,7 +3028,36 @@
2668 return sk("clip-y")("overflow-y")("hidden");
3028 return sk("clip-y")("overflow-y")("hidden");
2669 }
3029 }
2670 ;
3030 ;
2671− throw new Error("Failed pattern match at Plum.View (line 230, column 12 - line 288, column 46): " + [v.constructor.name]);
3031+ throw new Error("Failed pattern match at Plum.View (line 297, column 12 - line 355, column 46): " + [v.constructor.name]);
3032+ };
3033+ };
3034+ var onHover = function(dictMonoid) {
3035+ var mempty42 = mempty(monoidRecord2(monoidRecordCons2(dictMonoid)()(monoidRecordCons1)));
3036+ return function(dictMonoid1) {
3037+ return function(v) {
3038+ return new UI({
3039+ nerves: mempty42.nerves,
3040+ meat: mempty42.meat,
3041+ down: mempty42.down,
3042+ children: mempty42.children,
3043+ hover: v.value0.meat
3044+ }, v.value1);
3045+ };
3046+ };
3047+ };
3048+ var m = function(dictMonoid) {
3049+ var mempty42 = mempty(monoidRecord2(monoidRecordCons2(dictMonoid)()(monoidRecordCons1)));
3050+ return function(dictMonoid1) {
3051+ var mempty5 = mempty(dictMonoid1);
3052+ return function(meat) {
3053+ return new UI({
3054+ nerves: mempty42.nerves,
3055+ hover: mempty42.hover,
3056+ down: mempty42.down,
3057+ children: mempty42.children,
3058+ meat: [meat]
3059+ }, mempty5);
3060+ };
2672 };
3061 };
2673 };
3062 };
2674 var hWith = function(elem2) {
3063 var hWith = function(elem2) {
@@ -2697,10 +3086,10 @@
2697 var widthFill = [new Width(Fill.value), new Height(Fill.value)];
3086 var widthFill = [new Width(Fill.value), new Height(Fill.value)];
2698 var alignCenter = [new Align(X.value, Center.value), new Align(Y.value, Center.value)];
3087 var alignCenter = [new Align(X.value, Center.value), new Align(Y.value, Center.value)];
2699 var skn = function(ctx) {
3088 var skn = function(ctx) {
2700− return map2(function($424) {
3089+ return bind2(map2(function($511) {
2701 return function(v2) {
3090 return function(v2) {
2702 return append2(v2)(v.extraSkin);
3091 return append2(v2)(v.extraSkin);
2703− }(concat($424));
3092+ }(concat($511));
2704 })(traverse2(skin(ctx))(append2(v1.value0.meat)(append2(function() {
3093 })(traverse2(skin(ctx))(append2(v1.value0.meat)(append2(function() {
2705 if (ctx instanceof Span) {
3094 if (ctx instanceof Span) {
2706 return mempty2;
3095 return mempty2;
@@ -2718,7 +3107,7 @@
2718 return widthFill;
3107 return widthFill;
2719 }
3108 }
2720 ;
3109 ;
2721− throw new Error("Failed pattern match at Plum.View (line 368, column 16 - line 372, column 35): " + [ctx.constructor.name]);
3110+ throw new Error("Failed pattern match at Plum.View (line 435, column 16 - line 439, column 35): " + [ctx.constructor.name]);
2722 }())(function() {
3111 }())(function() {
2723 if (ctx instanceof Grid) {
3112 if (ctx instanceof Grid) {
2724 return alignCenter;
3113 return alignCenter;
@@ -2736,8 +3125,28 @@
2736 return alignCenter;
3125 return alignCenter;
2737 }
3126 }
2738 ;
3127 ;
2739− throw new Error("Failed pattern match at Plum.View (line 373, column 16 - line 377, column 37): " + [ctx.constructor.name]);
3128+ throw new Error("Failed pattern match at Plum.View (line 440, column 16 - line 444, column 37): " + [ctx.constructor.name]);
2740− }()))));
3129+ }())))))(function(meatClasses) {
3130+ var v2 = runWriter(traverse2(skin(ctx))(v1.value0.hover));
3131+ return bind2(traverseWithIndex2(function(key) {
3132+ return function(val) {
3133+ return tell2(singleton2(key + "-hover:hover")(val));
3134+ };
3135+ })(v2.value1))(function() {
3136+ var v3 = runWriter(traverse2(skin(ctx))(v1.value0.down));
3137+ return bind2(traverseWithIndex2(function(key) {
3138+ return function(val) {
3139+ return tell2(singleton2(key + "-down:active")(val));
3140+ };
3141+ })(v3.value1))(function() {
3142+ return pure2(append2(meatClasses)(append2(map1(function(v4) {
3143+ return v4 + "-hover";
3144+ })(concat(v2.value0)))(map1(function(v4) {
3145+ return v4 + "-down";
3146+ })(concat(v3.value0)))));
3147+ });
3148+ });
3149+ });
2741 };
3150 };
2742 if (v1.value1 instanceof Text) {
3151 if (v1.value1 instanceof Text) {
2743 return map2(function(c) {
3152 return map2(function(c) {
@@ -2823,7 +3232,7 @@
2823 return pure2(h3("div")(mempty2)([]));
3232 return pure2(h3("div")(mempty2)([]));
2824 }
3233 }
2825 ;
3234 ;
2826− throw new Error("Failed pattern match at Plum.View (line 380, column 3 - line 421, column 37): " + [v1.value1.constructor.name]);
3235+ throw new Error("Failed pattern match at Plum.View (line 453, column 3 - line 494, column 37): " + [v1.value1.constructor.name]);
2827 };
3236 };
2828 };
3237 };
2829 };
3238 };
@@ -2850,6 +3259,15 @@
2850 }, new Column(v.value0.children))]
3259 }, new Column(v.value0.children))]
2851 }, v.value1);
3260 }, v.value1);
2852 };
3261 };
3262+ var bgColor = function(dictMonoid) {
3263+ var m1 = m(dictMonoid);
3264+ return function(dictMonoid1) {
3265+ var m2 = m1(dictMonoid1);
3266+ return function(c) {
3267+ return m2(new BackgroundColor(c));
3268+ };
3269+ };
3270+ };
2853
3271
2854 // output/Web.DOM.NonElementParentNode/foreign.js
3272 // output/Web.DOM.NonElementParentNode/foreign.js
2855 function _getElementById(id) {
3273 function _getElementById(id) {
@@ -2921,8 +3339,8 @@
2921 if (v2 instanceof Just) {
3339 if (v2 instanceof Just) {
2922 var v3 = grow(function(msg) {
3340 var v3 = grow(function(msg) {
2923 return function __do3() {
3341 return function __do3() {
2924− var m = read(modelRef)();
3342+ var m2 = read(modelRef)();
2925− var m_ = plum2.update(msg)(m)();
3343+ var m_ = plum2.update(msg)(m2)();
2926 write(m_)(modelRef)();
3344 write(m_)(modelRef)();
2927 return scheduleRender(projector)();
3345 return scheduleRender(projector)();
2928 };
3346 };
@@ -2951,13 +3369,15 @@
2951 // output/Main/index.js
3369 // output/Main/index.js
2952 var pure3 = /* @__PURE__ */ pure(applicativeEffect);
3370 var pure3 = /* @__PURE__ */ pure(applicativeEffect);
2953 var discard3 = /* @__PURE__ */ discard(discardUnit)(/* @__PURE__ */ bindGenericUI(monoidArray));
3371 var discard3 = /* @__PURE__ */ discard(discardUnit)(/* @__PURE__ */ bindGenericUI(monoidArray));
3372+ var onHover2 = /* @__PURE__ */ onHover(monoidUnit)(monoidUnit);
3373+ var bgColor2 = /* @__PURE__ */ bgColor(monoidUnit)(monoidUnit);
2954 var mempty4 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidGenericUI(monoidUnit)(monoidUnit));
3374 var mempty4 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidGenericUI(monoidUnit)(monoidUnit));
2955 var plum = {
3375 var plum = {
2956 init: /* @__PURE__ */ pure3({
3376 init: /* @__PURE__ */ pure3({
2957 text: "Test"
3377 text: "Test"
2958 }),
3378 }),
2959 view: function(model) {
3379 view: function(model) {
2960− return column(discard3(text("hi")(mempty4))(function() {
3380+ return column(discard3(text("hi")(onHover2(bgColor2(rgb(1)(0)(0)))))(function() {
2961 return text("hello")(mempty4);
3381 return text("hello")(mempty4);
2962 }));
3382 }));
2963 },
3383 },
plum/src/Main.purs+3−1
@@ -18,7 +18,9 @@ plum =
18 { init: pure { text: "Test" }
18 { init: pure { text: "Test" }
19 , view: \model -> do
19 , view: \model -> do
20 column $ do
20 column $ do
21− text "hi" mempty
21+ text "hi" $ do
22+ onHover $ do
23+ bgColor $ rgb 1.0 0.0 0.0
22 text "hello" mempty
24 text "hello" mempty
23 , update: \msg model -> case msg of
25 , update: \msg model -> case msg of
24 _ -> pure { text: "Button pressed" }
26 _ -> pure { text: "Button pressed" }
plum/src/Plum/View.purs+88−15
@@ -2,6 +2,7 @@ module Plum.View
2 ( View
2 ( View
3 , Nerve(..)
3 , Nerve(..)
4 , Meat(..)
4 , Meat(..)
5+ , Side(..)
5 , Bones(..)
6 , Bones(..)
6 , grow
7 , grow
7 , Direction(..)
8 , Direction(..)
@@ -27,6 +28,19 @@ module Plum.View
27 , image
28 , image
28 , spacing
29 , spacing
29 , explain
30 , explain
31+ , align
32+ , width
33+ , height
34+ , wrapped
35+ , bgColor
36+ , padding
37+ , spread
38+ , opacity
39+ , pointer
40+ , move
41+ , clip
42+ , onHover
43+ , onMouseDown
30 ) where
44 ) where
31
45
32import Prelude
46import Prelude
@@ -37,6 +51,7 @@ import Data.Int as Int
37import Data.Maybe (Maybe(..))
51import Data.Maybe (Maybe(..))
38import Data.Maybe as Maybe
52import Data.Maybe as Maybe
39import Data.Traversable (traverse)
53import Data.Traversable (traverse)
54+import Data.TraversableWithIndex (traverseWithIndex)
40import Data.Tuple.Nested (type (/\), (/\))
55import Data.Tuple.Nested (type (/\), (/\))
41import Effect (Effect)
56import Effect (Effect)
42import Foreign.Object (Object)
57import Foreign.Object (Object)
@@ -44,7 +59,6 @@ import Foreign.Object as Object
44import Maquette (VNode, string)
59import Maquette (VNode, string)
45import Maquette as Maquette
60import Maquette as Maquette
46import Record.Unsafe.Union as Record
61import Record.Unsafe.Union as Record
47−import Web.HTML (ClassName)
48
62
49type GenericUIView children msg =
63type GenericUIView children msg =
50 { nerves :: Array (Nerve msg)
64 { nerves :: Array (Nerve msg)
@@ -189,6 +203,45 @@ spacing { x, y } = m $ Spacing x y
189explain :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
203explain :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
190explain = m Explain
204explain = m Explain
191
205
206+align :: forall ch msg a. Monoid ch => Monoid a => Direction -> Alignment -> GenericUI ch msg a
207+align dir al = m $ Align dir al
208+
209+width :: forall ch msg a. Monoid ch => Monoid a => Length -> GenericUI ch msg a
210+width l = m $ Width l
211+
212+height :: forall ch msg a. Monoid ch => Monoid a => Length -> GenericUI ch msg a
213+height l = m $ Height l
214+
215+wrapped :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
216+wrapped = m Wrapped
217+
218+bgColor :: forall ch msg a. Monoid ch => Monoid a => Color -> GenericUI ch msg a
219+bgColor c = m $ BackgroundColor c
220+
221+padding :: forall ch msg a. Monoid ch => Monoid a => Side -> Int -> GenericUI ch msg a
222+padding s l = m $ Padding s l
223+
224+spread :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
225+spread = m Spread
226+
227+opacity :: forall ch msg a. Monoid ch => Monoid a => Number -> GenericUI ch msg a
228+opacity o = m $ Opacity o
229+
230+pointer :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
231+pointer = m Pointer
232+
233+move :: forall ch msg a. Monoid ch => Monoid a => { x :: Int, y :: Int } -> GenericUI ch msg a
234+move a = m $ Move a
235+
236+clip :: forall ch msg a. Monoid ch => Monoid a => Direction -> GenericUI ch msg a
237+clip dir = m $ Clip dir
238+
239+onHover :: forall ch msg a. Monoid ch => Monoid a => GenericUI Unit msg a -> GenericUI ch msg a
240+onHover (UI { meat } a) = UI (mempty :: GenericUIView ch msg) { hover = meat } a
241+
242+onMouseDown :: forall ch msg a. Monoid ch => Monoid a => GenericUI Unit msg a -> GenericUI ch msg a
243+onMouseDown (UI { meat } a) = UI (mempty :: GenericUIView ch msg) { down = meat } a
244+
192data Meat
245data Meat
193 = Spacing Int Int
246 = Spacing Int Int
194 | Explain
247 | Explain
@@ -197,13 +250,27 @@ data Meat
197 | Height Length
250 | Height Length
198 | Wrapped
251 | Wrapped
199 | BackgroundColor Color
252 | BackgroundColor Color
200− | Padding { top :: Int, right :: Int, bottom :: Int, left :: Int }
253+ | Padding Side Int
201 | Spread
254 | Spread
202 | Opacity Number
255 | Opacity Number
203 | Pointer
256 | Pointer
204 | Move { x :: Int, y :: Int }
257 | Move { x :: Int, y :: Int }
205 | Clip Direction
258 | Clip Direction
206
259
260+data Side = Top | Right | Bottom | Left
261+
262+instance Renderable Side where
263+ render = case _ of
264+ Top -> "top"
265+ Right -> "right"
266+ Bottom -> "bottom"
267+ Left -> "left"
268+ renderKey = case _ of
269+ Top -> "top"
270+ Right -> "right"
271+ Bottom -> "bottom"
272+ Left -> "left"
273+
207data Nerve msg = OnClick msg
274data Nerve msg = OnClick msg
208
275
209type View msg = { nerves :: Array (Nerve msg), meat :: Array Meat, hover :: Array Meat, down :: Array Meat } /\ Bones msg
276type View msg = { nerves :: Array (Nerve msg), meat :: Array Meat, hover :: Array Meat, down :: Array Meat } /\ Bones msg
@@ -268,16 +335,16 @@ skin ctx = case _ of
268 in
335 in
269 sk ("align-flexbox-" <> k <> "-" <> v) k v
336 sk ("align-flexbox-" <> k <> "-" <> v) k v
270 Width l -> sk ("width-" <> renderKey l) "width" (render l)
337 Width l -> sk ("width-" <> renderKey l) "width" (render l)
271− Height l -> sk ("width-" <> renderKey l) "height" (render l)
338+ Height l -> sk ("height-" <> renderKey l) "height" (render l)
272 Wrapped -> case ctx of
339 Wrapped -> case ctx of
273 Flexbox _ -> sk "wrapped" "flex-wrap" "wrap"
340 Flexbox _ -> sk "wrapped" "flex-wrap" "wrap"
274 _ -> pure []
341 _ -> pure []
275 BackgroundColor color -> sk ("bg-color-" <> renderKey color) "background-color" (render color)
342 BackgroundColor color -> sk ("bg-color-" <> renderKey color) "background-color" (render color)
276− Padding { top, right, bottom, left } ->
343+ Padding side l ->
277 sk
344 sk
278− ("padding-" <> show top <> "-" <> show right <> "-" <> show bottom <> "-" <> show left)
345+ ("padding-" <> renderKey side <> "-" <> show l)
279− "padding"
346+ ("padding-" <> render side)
280− (show top <> "px " <> show right <> "px " <> show bottom <> "px " <> show left <> "px")
347+ (show l <> "px")
281 Spread -> case ctx of
348 Spread -> case ctx of
282 Flexbox _ -> sk "spread" "justify-content" "space-between"
349 Flexbox _ -> sk "spread" "justify-content" "space-between"
283 _ -> pure []
350 _ -> pure []
@@ -305,22 +372,22 @@ instance Renderable Length where
305 Max px l -> "max-" <> show px <> "-" <> renderKey l
372 Max px l -> "max-" <> show px <> "-" <> renderKey l
306 Min px l -> "min-" <> show px <> "-" <> renderKey l
373 Min px l -> "min-" <> show px <> "-" <> renderKey l
307
374
308−newtype Color = Color { r :: Int, g :: Int, b :: Int, a :: Number }
375+newtype Color = Color { r :: Int, g :: Int, b :: Int, a :: Int }
309
376
310rgb255 :: Int -> Int -> Int -> Color
377rgb255 :: Int -> Int -> Int -> Color
311−rgb255 r g b = Color { r, g, b, a: 1.0 }
378+rgb255 r g b = Color { r, g, b, a: 100 }
312
379
313−rgba255 :: Int -> Int -> Int -> Number -> Color
380+rgba255 :: Int -> Int -> Int -> Int -> Color
314rgba255 r g b a = Color { r, g, b, a }
381rgba255 r g b a = Color { r, g, b, a }
315
382
316rgb :: Number -> Number -> Number -> Color
383rgb :: Number -> Number -> Number -> Color
317−rgb r g b = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: 1.0 }
384+rgb r g b = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: 100 }
318
385
319rgba :: Number -> Number -> Number -> Number -> Color
386rgba :: Number -> Number -> Number -> Number -> Color
320−rgba r g b a = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a }
387+rgba r g b a = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: Int.round (a * 100.0) }
321
388
322instance Renderable Color where
389instance Renderable Color where
323− render (Color { r, g, b, a }) = "rgba(" <> show r <> "," <> show g <> "," <> show b <> "," <> show a <> ")"
390+ render (Color { r, g, b, a }) = "rgb(" <> show r <> "," <> show g <> "," <> show b <> "," <> show a <> "%)"
324 renderKey (Color { r, g, b, a }) = show r <> "-" <> show g <> "-" <> show b <> "-" <> show a
391 renderKey (Color { r, g, b, a }) = show r <> "-" <> show g <> "-" <> show b <> "-" <> show a
325
392
326data Bones :: Type -> Type
393data Bones :: Type -> Type
@@ -362,8 +429,8 @@ growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
362 let
429 let
363 alignCenter = [ Align X Center, Align Y Center ]
430 alignCenter = [ Align X Center, Align Y Center ]
364 widthFill = [ Width Fill, Height Fill ]
431 widthFill = [ Width Fill, Height Fill ]
365− skn ctx =
432+ skn ctx = do
366− ((_ <> mutation.extraSkin) <<< Array.concat) <$> traverse (skin ctx)
433+ meatClasses <- ((_ <> mutation.extraSkin) <<< Array.concat) <$> traverse (skin ctx)
367 ( meat
434 ( meat
368 <> case ctx of
435 <> case ctx of
369 Span -> mempty
436 Span -> mempty
@@ -376,6 +443,12 @@ growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
376 Span -> mempty
443 Span -> mempty
377 Generic -> alignCenter
444 Generic -> alignCenter
378 )
445 )
446+ let hoverClasses /\ (SkinGrowth hover') = runWriter $ traverse (skin ctx) hover
447+ _ <- traverseWithIndex (\key val -> tell $ SkinGrowth $ Object.singleton (key <> "-hover:hover") val) hover'
448+ let downClasses /\ (SkinGrowth down') = runWriter $ traverse (skin ctx) down
449+ _ <- traverseWithIndex (\key val -> tell $ SkinGrowth $ Object.singleton (key <> "-down:active") val) down'
450+
451+ pure $ meatClasses <> map (_ <> "-hover") (Array.concat hoverClasses) <> map (_ <> "-down") (Array.concat downClasses)
379
452
380 case bones of
453 case bones of
381 Text t -> (\c -> h "span" c [ string t ]) <$> (skn Span)
454 Text t -> (\c -> h "span" c [ string t ]) <$> (skn Span)