From 944180d572ac6aab03f12e8c444f92f6c3bd0f33 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 11 Dec 2022 17:43:09 +0100 Subject: [PATCH] Refactored theme-color implementation to support palette switches --- docs/customization.md | 1 - ...ce0331ff.min.js => bundle.c0285e69.min.js} | 8 +-- ....min.js.map => bundle.c0285e69.min.js.map} | 6 +- .../assets/stylesheets/extra.27126f53.min.css | 1 - .../stylesheets/extra.27126f53.min.css.map | 1 - .../assets/stylesheets/extra.73715943.min.css | 1 + .../stylesheets/extra.73715943.min.css.map | 1 + material/base.html | 17 ++--- material/partials/palette.html | 44 ------------- .../javascripts/components/palette/index.ts | 27 +++++++- src/base.html | 17 ++--- src/partials/palette.html | 66 ------------------- 12 files changed, 46 insertions(+), 144 deletions(-) rename material/assets/javascripts/{bundle.ce0331ff.min.js => bundle.c0285e69.min.js} (78%) rename material/assets/javascripts/{bundle.ce0331ff.min.js.map => bundle.c0285e69.min.js.map} (85%) delete mode 100644 material/assets/stylesheets/extra.27126f53.min.css delete mode 100644 material/assets/stylesheets/extra.27126f53.min.css.map create mode 100644 material/assets/stylesheets/extra.73715943.min.css create mode 100644 material/assets/stylesheets/extra.73715943.min.css.map delete mode 100644 material/partials/palette.html delete mode 100644 src/partials/palette.html diff --git a/docs/customization.md b/docs/customization.md index e7e4baa05..31c4aef49 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -113,7 +113,6 @@ assets may also be put in the `overrides` directory: │ ├─ nav.html # Main navigation │ ├─ nav-item.html # Main navigation item │ ├─ pagination.html # Pagination (used for blog) -│ ├─ palette.html # Color palette │ ├─ post.html # Blog post excerpt │ ├─ search.html # Search interface │ ├─ social.html # Social links diff --git a/material/assets/javascripts/bundle.ce0331ff.min.js b/material/assets/javascripts/bundle.c0285e69.min.js similarity index 78% rename from material/assets/javascripts/bundle.ce0331ff.min.js rename to material/assets/javascripts/bundle.c0285e69.min.js index 121fe1a89..48ed38ab3 100644 --- a/material/assets/javascripts/bundle.ce0331ff.min.js +++ b/material/assets/javascripts/bundle.c0285e69.min.js @@ -16,14 +16,14 @@ PERFORMANCE OF THIS SOFTWARE. * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha - */(function(t,r){typeof Lt=="object"&&typeof Br=="object"?Br.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Lt=="object"?Lt.ClipboardJS=r():t.ClipboardJS=r()})(Lt,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return oa}});var a=i(279),s=i.n(a),c=i(370),f=i.n(c),u=i(817),p=i.n(u);function m(j){try{return document.execCommand(j)}catch(T){return!1}}var d=function(T){var w=p()(T);return m("cut"),w},h=d;function b(j){var T=document.documentElement.getAttribute("dir")==="rtl",w=document.createElement("textarea");w.style.fontSize="12pt",w.style.border="0",w.style.padding="0",w.style.margin="0",w.style.position="absolute",w.style[T?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return w.style.top="".concat(k,"px"),w.setAttribute("readonly",""),w.value=j,w}var z=function(T,w){var k=b(T);w.container.appendChild(k);var I=p()(k);return m("copy"),k.remove(),I},Z=function(T){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof T=="string"?k=z(T,w):T instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(T==null?void 0:T.type)?k=z(T.value,w):(k=p()(T),m("copy")),k},W=Z;function O(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(w){return typeof w}:O=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},O(j)}var Ne=function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=T.action,k=w===void 0?"copy":w,I=T.container,q=T.target,_e=T.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(q!==void 0)if(q&&O(q)==="object"&&q.nodeType===1){if(k==="copy"&&q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(q.hasAttribute("readonly")||q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(_e)return W(_e,{container:I});if(q)return k==="cut"?h(q):W(q,{container:I})},Ue=Ne;function $e(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$e=function(w){return typeof w}:$e=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},$e(j)}function Bi(j,T){if(!(j instanceof T))throw new TypeError("Cannot call a class as a function")}function cn(j,T){for(var w=0;w0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=$e(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var q=this;this.listener=f()(I,"click",function(_e){return q.onClick(_e)})}},{key:"onClick",value:function(I){var q=I.delegateTarget||I.currentTarget,_e=this.action(q)||"copy",Rt=Ue({action:_e,container:this.container,target:this.target(q),text:this.text(q)});this.emit(Rt?"success":"error",{action:_e,text:Rt,trigger:q,clearSelection:function(){q&&q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return Sr("action",I)}},{key:"defaultTarget",value:function(I){var q=Sr("target",I);if(q)return document.querySelector(q)}},{key:"defaultText",value:function(I){return Sr("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return W(I,q)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],q=typeof I=="string"?[I]:I,_e=!!document.queryCommandSupported;return q.forEach(function(Rt){_e=_e&&!!document.queryCommandSupported(Rt)}),_e}}]),w}(s()),oa=na},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function a(s,c){for(;s&&s.nodeType!==o;){if(typeof s.matches=="function"&&s.matches(c))return s;s=s.parentNode}}n.exports=a},438:function(n,o,i){var a=i(828);function s(u,p,m,d,h){var b=f.apply(this,arguments);return u.addEventListener(m,b,h),{destroy:function(){u.removeEventListener(m,b,h)}}}function c(u,p,m,d,h){return typeof u.addEventListener=="function"?s.apply(null,arguments):typeof m=="function"?s.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(b){return s(b,p,m,d,h)}))}function f(u,p,m,d){return function(h){h.delegateTarget=a(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=c},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var a=Object.prototype.toString.call(i);return i!==void 0&&(a==="[object NodeList]"||a==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var a=Object.prototype.toString.call(i);return a==="[object Function]"}},370:function(n,o,i){var a=i(879),s=i(438);function c(m,d,h){if(!m&&!d&&!h)throw new Error("Missing required arguments");if(!a.string(d))throw new TypeError("Second argument must be a String");if(!a.fn(h))throw new TypeError("Third argument must be a Function");if(a.node(m))return f(m,d,h);if(a.nodeList(m))return u(m,d,h);if(a.string(m))return p(m,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(m,d,h){return m.addEventListener(d,h),{destroy:function(){m.removeEventListener(d,h)}}}function u(m,d,h){return Array.prototype.forEach.call(m,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(m,function(b){b.removeEventListener(d,h)})}}}function p(m,d,h){return s(document.body,m,d,h)}n.exports=c},817:function(n){function o(i){var a;if(i.nodeName==="SELECT")i.focus(),a=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var s=i.hasAttribute("readonly");s||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),s||i.removeAttribute("readonly"),a=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),f=document.createRange();f.selectNodeContents(i),c.removeAllRanges(),c.addRange(f),a=c.toString()}return a}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,a,s){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:a,ctx:s}),this},once:function(i,a,s){var c=this;function f(){c.off(i,f),a.apply(s,arguments)}return f._=a,this.on(i,f,s)},emit:function(i){var a=[].slice.call(arguments,1),s=((this.e||(this.e={}))[i]||[]).slice(),c=0,f=s.length;for(c;c{"use strict";/*! + */(function(t,r){typeof Lt=="object"&&typeof Br=="object"?Br.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Lt=="object"?Lt.ClipboardJS=r():t.ClipboardJS=r()})(Lt,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return oa}});var a=i(279),s=i.n(a),c=i(370),f=i.n(c),u=i(817),p=i.n(u);function m(j){try{return document.execCommand(j)}catch(T){return!1}}var d=function(T){var w=p()(T);return m("cut"),w},h=d;function b(j){var T=document.documentElement.getAttribute("dir")==="rtl",w=document.createElement("textarea");w.style.fontSize="12pt",w.style.border="0",w.style.padding="0",w.style.margin="0",w.style.position="absolute",w.style[T?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return w.style.top="".concat(k,"px"),w.setAttribute("readonly",""),w.value=j,w}var z=function(T,w){var k=b(T);w.container.appendChild(k);var I=p()(k);return m("copy"),k.remove(),I},Z=function(T){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof T=="string"?k=z(T,w):T instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(T==null?void 0:T.type)?k=z(T.value,w):(k=p()(T),m("copy")),k},W=Z;function O(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(w){return typeof w}:O=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},O(j)}var Ne=function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=T.action,k=w===void 0?"copy":w,I=T.container,q=T.target,_e=T.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(q!==void 0)if(q&&O(q)==="object"&&q.nodeType===1){if(k==="copy"&&q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(q.hasAttribute("readonly")||q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(_e)return W(_e,{container:I});if(q)return k==="cut"?h(q):W(q,{container:I})},Ue=Ne;function $e(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$e=function(w){return typeof w}:$e=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},$e(j)}function Bi(j,T){if(!(j instanceof T))throw new TypeError("Cannot call a class as a function")}function cn(j,T){for(var w=0;w0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=$e(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var q=this;this.listener=f()(I,"click",function(_e){return q.onClick(_e)})}},{key:"onClick",value:function(I){var q=I.delegateTarget||I.currentTarget,_e=this.action(q)||"copy",Rt=Ue({action:_e,container:this.container,target:this.target(q),text:this.text(q)});this.emit(Rt?"success":"error",{action:_e,text:Rt,trigger:q,clearSelection:function(){q&&q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return Sr("action",I)}},{key:"defaultTarget",value:function(I){var q=Sr("target",I);if(q)return document.querySelector(q)}},{key:"defaultText",value:function(I){return Sr("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return W(I,q)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],q=typeof I=="string"?[I]:I,_e=!!document.queryCommandSupported;return q.forEach(function(Rt){_e=_e&&!!document.queryCommandSupported(Rt)}),_e}}]),w}(s()),oa=na},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function a(s,c){for(;s&&s.nodeType!==o;){if(typeof s.matches=="function"&&s.matches(c))return s;s=s.parentNode}}n.exports=a},438:function(n,o,i){var a=i(828);function s(u,p,m,d,h){var b=f.apply(this,arguments);return u.addEventListener(m,b,h),{destroy:function(){u.removeEventListener(m,b,h)}}}function c(u,p,m,d,h){return typeof u.addEventListener=="function"?s.apply(null,arguments):typeof m=="function"?s.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(b){return s(b,p,m,d,h)}))}function f(u,p,m,d){return function(h){h.delegateTarget=a(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=c},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var a=Object.prototype.toString.call(i);return i!==void 0&&(a==="[object NodeList]"||a==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var a=Object.prototype.toString.call(i);return a==="[object Function]"}},370:function(n,o,i){var a=i(879),s=i(438);function c(m,d,h){if(!m&&!d&&!h)throw new Error("Missing required arguments");if(!a.string(d))throw new TypeError("Second argument must be a String");if(!a.fn(h))throw new TypeError("Third argument must be a Function");if(a.node(m))return f(m,d,h);if(a.nodeList(m))return u(m,d,h);if(a.string(m))return p(m,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(m,d,h){return m.addEventListener(d,h),{destroy:function(){m.removeEventListener(d,h)}}}function u(m,d,h){return Array.prototype.forEach.call(m,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(m,function(b){b.removeEventListener(d,h)})}}}function p(m,d,h){return s(document.body,m,d,h)}n.exports=c},817:function(n){function o(i){var a;if(i.nodeName==="SELECT")i.focus(),a=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var s=i.hasAttribute("readonly");s||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),s||i.removeAttribute("readonly"),a=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),f=document.createRange();f.selectNodeContents(i),c.removeAllRanges(),c.addRange(f),a=c.toString()}return a}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,a,s){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:a,ctx:s}),this},once:function(i,a,s){var c=this;function f(){c.off(i,f),a.apply(s,arguments)}return f._=a,this.on(i,f,s)},emit:function(i){var a=[].slice.call(arguments,1),s=((this.e||(this.e={}))[i]||[]).slice(),c=0,f=s.length;for(c;c{"use strict";/*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed - */var Rs=/["'&<>]/;Si.exports=ks;function ks(e){var t=""+e,r=Rs.exec(t);if(!r)return t;var n,o="",i=0,a=0;for(i=r.index;i]/;Si.exports=ks;function ks(e){var t=""+e,r=Rs.exec(t);if(!r)return t;var n,o="",i=0,a=0;for(i=r.index;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,a=o.isStopped,s=o.observers;return i||a?Ar:(this.currentObservers=null,s.push(r),new Ie(function(){n.currentObservers=null,We(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?r.error(i):a&&r.complete()},t.prototype.asObservable=function(){var r=new F;return r.source=this,r},t.create=function(r,n){return new Yn(r,n)},t}(F);var Yn=function(e){ne(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Ar},t}(E);var Et={now:function(){return(Et.delegate||Date).now()},delegate:void 0};var wt=function(e){ne(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Et);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,s=n._timestampProvider,c=n._windowTime;o||(i.push(r),!a&&i.push(s.now()+c)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,a=o._buffer,s=a.slice(),c=0;c0?e.prototype.requestAsyncId.call(this,r,n,o):(r.actions.push(this),r._scheduled||(r._scheduled=ut.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,n,o){var i;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,o);var a=r.actions;n!=null&&((i=a[a.length-1])===null||i===void 0?void 0:i.id)!==n&&(ut.cancelAnimationFrame(n),r._scheduled=void 0)},t}(Vt);var Jn=function(e){ne(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=!0;var n=this._scheduled;this._scheduled=void 0;var o=this.actions,i;r=r||o.shift();do if(i=r.execute(r.state,r.delay))break;while((r=o[0])&&r.id===n&&o.shift());if(this._active=!1,i){for(;(r=o[0])&&r.id===n&&o.shift();)r.unsubscribe();throw i}},t}(zt);var xe=new Jn(Bn);var R=new F(function(e){return e.complete()});function Nt(e){return e&&A(e.schedule)}function Ir(e){return e[e.length-1]}function qe(e){return A(Ir(e))?e.pop():void 0}function we(e){return Nt(Ir(e))?e.pop():void 0}function qt(e,t){return typeof Ir(e)=="number"?e.pop():t}var pt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Kt(e){return A(e==null?void 0:e.then)}function Qt(e){return A(e[ft])}function Yt(e){return Symbol.asyncIterator&&A(e==null?void 0:e[Symbol.asyncIterator])}function Gt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ga(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Bt=ga();function Jt(e){return A(e==null?void 0:e[Bt])}function Xt(e){return Fn(this,arguments,function(){var r,n,o,i;return It(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,jt(r.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,jt(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,jt(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Zt(e){return A(e==null?void 0:e.getReader)}function V(e){if(e instanceof F)return e;if(e!=null){if(Qt(e))return ya(e);if(pt(e))return xa(e);if(Kt(e))return Ea(e);if(Yt(e))return Xn(e);if(Jt(e))return wa(e);if(Zt(e))return Sa(e)}throw Gt(e)}function ya(e){return new F(function(t){var r=e[ft]();if(A(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function xa(e){return new F(function(t){for(var r=0;r=2;return function(n){return n.pipe(e?_(function(o,i){return e(o,i,n)}):me,ge(1),r?He(t):bo(function(){return new tr}))}}function vo(){for(var e=[],t=0;t=2,!0))}function fe(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new E}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,a=i===void 0?!0:i,s=e.resetOnRefCountZero,c=s===void 0?!0:s;return function(f){var u,p,m,d=0,h=!1,b=!1,z=function(){p==null||p.unsubscribe(),p=void 0},Z=function(){z(),u=m=void 0,h=b=!1},W=function(){var O=u;Z(),O==null||O.unsubscribe()};return g(function(O,Ne){d++,!b&&!h&&z();var Ue=m=m!=null?m:r();Ne.add(function(){d--,d===0&&!b&&!h&&(p=Vr(W,c))}),Ue.subscribe(Ne),!u&&d>0&&(u=new Ze({next:function($e){return Ue.next($e)},error:function($e){b=!0,z(),p=Vr(Z,o,$e),Ue.error($e)},complete:function(){h=!0,z(),p=Vr(Z,a),Ue.complete()}}),V(O).subscribe(u))})(f)}}function Vr(e,t){for(var r=[],n=2;ne.next(document)),e}function Q(e,t=document){return Array.from(t.querySelectorAll(e))}function K(e,t=document){let r=se(e,t);if(typeof r=="undefined")throw new ReferenceError(`Missing element: expected "${e}" to be present`);return r}function se(e,t=document){return t.querySelector(e)||void 0}function je(){return document.activeElement instanceof HTMLElement&&document.activeElement||void 0}function or(e){return M(v(document.body,"focusin"),v(document.body,"focusout")).pipe(ke(1),l(()=>{let t=je();return typeof t!="undefined"?e.contains(t):!1}),N(e===je()),G())}function Ye(e){return{x:e.offsetLeft,y:e.offsetTop}}function Eo(e){return M(v(window,"load"),v(window,"resize")).pipe(Ce(0,xe),l(()=>Ye(e)),N(Ye(e)))}function ir(e){return{x:e.scrollLeft,y:e.scrollTop}}function dt(e){return M(v(e,"scroll"),v(window,"resize")).pipe(Ce(0,xe),l(()=>ir(e)),N(ir(e)))}var So=function(){if(typeof Map!="undefined")return Map;function e(t,r){var n=-1;return t.some(function(o,i){return o[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,i=this.__entries__;o0},e.prototype.connect_=function(){!Qr||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Ka?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!Qr||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=qa.some(function(i){return!!~n.indexOf(i)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Oo=function(e,t){for(var r=0,n=Object.keys(t);r0},e}(),_o=typeof WeakMap!="undefined"?new WeakMap:new So,Mo=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=Qa.getInstance(),n=new ns(t,r,this);_o.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){Mo.prototype[e]=function(){var t;return(t=_o.get(this))[e].apply(t,arguments)}});var os=function(){return typeof ar.ResizeObserver!="undefined"?ar.ResizeObserver:Mo}(),Lo=os;var Ao=new E,is=$(()=>H(new Lo(e=>{for(let t of e)Ao.next(t)}))).pipe(x(e=>M(Se,H(e)).pipe(C(()=>e.disconnect()))),J(1));function de(e){return{width:e.offsetWidth,height:e.offsetHeight}}function ye(e){return is.pipe(S(t=>t.observe(e)),x(t=>Ao.pipe(_(({target:r})=>r===e),C(()=>t.unobserve(e)),l(()=>de(e)))),N(de(e)))}function bt(e){return{width:e.scrollWidth,height:e.scrollHeight}}function fr(e){let t=e.parentElement;for(;t&&(e.scrollWidth<=t.scrollWidth&&e.scrollHeight<=t.scrollHeight);)t=(e=t).parentElement;return t?e:void 0}var Co=new E,as=$(()=>H(new IntersectionObserver(e=>{for(let t of e)Co.next(t)},{threshold:0}))).pipe(x(e=>M(Se,H(e)).pipe(C(()=>e.disconnect()))),J(1));function ur(e){return as.pipe(S(t=>t.observe(e)),x(t=>Co.pipe(_(({target:r})=>r===e),C(()=>t.unobserve(e)),l(({isIntersecting:r})=>r))))}function Ro(e,t=16){return dt(e).pipe(l(({y:r})=>{let n=de(e),o=bt(e);return r>=o.height-n.height-t}),G())}var pr={drawer:K("[data-md-toggle=drawer]"),search:K("[data-md-toggle=search]")};function ko(e){return pr[e].checked}function Ge(e,t){pr[e].checked!==t&&pr[e].click()}function Be(e){let t=pr[e];return v(t,"change").pipe(l(()=>t.checked),N(t.checked))}function ss(e,t){switch(e.constructor){case HTMLInputElement:return e.type==="radio"?/^Arrow/.test(t):!0;case HTMLSelectElement:case HTMLTextAreaElement:return!0;default:return e.isContentEditable}}function cs(){return M(v(window,"compositionstart").pipe(l(()=>!0)),v(window,"compositionend").pipe(l(()=>!1))).pipe(N(!1))}function Ho(){let e=v(window,"keydown").pipe(_(t=>!(t.metaKey||t.ctrlKey)),l(t=>({mode:ko("search")?"search":"global",type:t.key,claim(){t.preventDefault(),t.stopPropagation()}})),_(({mode:t,type:r})=>{if(t==="global"){let n=je();if(typeof n!="undefined")return!ss(n,r)}return!0}),fe());return cs().pipe(x(t=>t?R:e))}function Oe(){return new URL(location.href)}function lr(e){location.href=e.href}function Po(){return new E}function $o(e,t){if(typeof t=="string"||typeof t=="number")e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(let r of t)$o(e,r)}function L(e,t,...r){let n=document.createElement(e);if(t)for(let o of Object.keys(t))typeof t[o]!="undefined"&&(typeof t[o]!="boolean"?n.setAttribute(o,t[o]):n.setAttribute(o,""));for(let o of r)$o(n,o);return n}function mr(e){if(e>999){let t=+((e-950)%1e3>99);return`${((e+1e-6)/1e3).toFixed(t)}k`}else return e.toString()}function Io(){return location.hash.substring(1)}function jo(e){let t=L("a",{href:e});t.addEventListener("click",r=>r.stopPropagation()),t.click()}function fs(){return v(window,"hashchange").pipe(l(Io),N(Io()),_(e=>e.length>0),J(1))}function Fo(){return fs().pipe(l(e=>se(`[id="${e}"]`)),_(e=>typeof e!="undefined"))}function Yr(e){let t=matchMedia(e);return rr(r=>t.addListener(()=>r(t.matches))).pipe(N(t.matches))}function Uo(){let e=matchMedia("print");return M(v(window,"beforeprint").pipe(l(()=>!0)),v(window,"afterprint").pipe(l(()=>!1))).pipe(N(e.matches))}function Gr(e,t){return e.pipe(x(r=>r?t():R))}function dr(e,t={credentials:"same-origin"}){return ve(fetch(`${e}`,t)).pipe(ce(()=>R),x(r=>r.status!==200?Ot(()=>new Error(r.statusText)):H(r)))}function Fe(e,t){return dr(e,t).pipe(x(r=>r.json()),J(1))}function Wo(e,t){let r=new DOMParser;return dr(e,t).pipe(x(n=>n.text()),l(n=>r.parseFromString(n,"text/xml")),J(1))}function hr(e){let t=L("script",{src:e});return $(()=>(document.head.appendChild(t),M(v(t,"load"),v(t,"error").pipe(x(()=>Ot(()=>new ReferenceError(`Invalid script: ${e}`))))).pipe(l(()=>{}),C(()=>document.head.removeChild(t)),ge(1))))}function Do(){return{x:Math.max(0,scrollX),y:Math.max(0,scrollY)}}function Vo(){return M(v(window,"scroll",{passive:!0}),v(window,"resize",{passive:!0})).pipe(l(Do),N(Do()))}function zo(){return{width:innerWidth,height:innerHeight}}function No(){return v(window,"resize",{passive:!0}).pipe(l(zo),N(zo()))}function qo(){return Y([Vo(),No()]).pipe(l(([e,t])=>({offset:e,size:t})),J(1))}function br(e,{viewport$:t,header$:r}){let n=t.pipe(X("size")),o=Y([n,r]).pipe(l(()=>Ye(e)));return Y([r,t,o]).pipe(l(([{height:i},{offset:a,size:s},{x:c,y:f}])=>({offset:{x:a.x-c,y:a.y-f+i},size:s})))}(()=>{function e(o,i){parent.postMessage(o,i||"*")}function t(...o){return o.reduce((i,a)=>i.then(()=>new Promise(s=>{let c=document.createElement("script");c.src=a,c.addEventListener("load",()=>s()),document.body.appendChild(c)})),Promise.resolve())}function r(){let o=document.createElement("iframe");return o.width=o.height=o.frameBorder="0",o}var n=class{constructor(o,i){if(this.url=o,this.onerror=null,this.onmessage=null,this.onmessageerror=null,this.handleMessage=s=>{s.source===this.worker&&(s.stopImmediatePropagation(),this.dispatchEvent(new MessageEvent("message",{data:s.data})),this.onmessage&&this.onmessage(s))},this.handleError=(s,c,f,u,p)=>{if(c===this.url.toString()){let m=new ErrorEvent("error",{message:s,filename:c,lineno:f,colno:u,error:p});this.dispatchEvent(m),this.onerror&&this.onerror(m)}},typeof i!="undefined")throw new TypeError("Options are not supported for iframe workers");let a=new EventTarget;this.addEventListener=a.addEventListener.bind(a),this.removeEventListener=a.removeEventListener.bind(a),this.dispatchEvent=a.dispatchEvent.bind(a),document.body.appendChild(this.iframe=r()),this.worker.document.open(),this.worker.document.write(` {% endblock %} {% block scripts %} - + {% for path in config.extra_javascript %} {% endfor %} {% endblock %} {% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %} - + {% endif %} diff --git a/material/partials/palette.html b/material/partials/palette.html deleted file mode 100644 index 05e366635..000000000 --- a/material/partials/palette.html +++ /dev/null @@ -1,44 +0,0 @@ -{#- - This file was automatically generated - do not edit --#} -{% macro primary(key) %}{{ { - "red": "#ef5552", - "pink": "#e92063", - "purple": "#ab47bd", - "deep-purple": "#7e56c2", - "indigo": "#4051b5", - "blue": "#2094f3", - "light-blue": "#02a6f2", - "cyan": "#00bdd6", - "teal": "#009485", - "green": "#4cae4f", - "light-green": "#8bc34b", - "lime": "#cbdc38", - "yellow": "#ffec3d", - "amber": "#ffc105", - "orange": "#ffa724", - "deep-orange": "#ff6e42", - "brown": "#795649", - "grey": "#757575", - "blue-grey": "#546d78", - "black": "#000000", - "white": "#ffffff" -}[key] }}{% endmacro %} -{% macro accent(key) %}{{ { - "red": "#ff1a47", - "pink": "#f50056", - "purple": "#df41fb", - "deep-purple": "#7c4dff", - "indigo": "#526cfe", - "blue": "#4287ff", - "light-blue": "#0091eb", - "cyan": "#00bad6", - "teal": "#00bda4", - "green": "#00c753", - "light-green": "#63de17", - "lime": "#b0eb00", - "yellow": "#ffd500", - "amber": "#ffaa00", - "orange": "#ff9100", - "deep-orange": "#ff6e42" -}[key] }}{% endmacro %} diff --git a/src/assets/javascripts/components/palette/index.ts b/src/assets/javascripts/components/palette/index.ts index cff45cb76..0c8e93700 100644 --- a/src/assets/javascripts/components/palette/index.ts +++ b/src/assets/javascripts/components/palette/index.ts @@ -37,8 +37,12 @@ import { } from "rxjs" import { getElements } from "~/browser" +import { h } from "~/utilities" -import { Component } from "../_" +import { + Component, + getComponentElement +} from "../_" /* ---------------------------------------------------------------------------- * Types @@ -112,6 +116,10 @@ export function watchPalette( export function mountPalette( el: HTMLElement ): Observable> { + const meta = h("meta", { name: "theme-color" }) + document.head.appendChild(meta) + + /* Mount component on subscription */ return defer(() => { const push$ = new Subject() push$.subscribe(palette => { @@ -132,6 +140,23 @@ export function mountPalette( __md_set("__palette", palette) }) + /* Update theme-color meta tag */ + push$ + .pipe( + map(() => { + const header = getComponentElement("header") + const { backgroundColor } = window.getComputedStyle(header) + + /* Return color in hexadecimal format */ + return `#${ + backgroundColor.match(/\d+/g)! + .map(value => (+value).toString(16).padStart(2, "0")) + .join("") + }` + }) + ) + .subscribe(color => meta.content = color) + /* Revert transition durations after color switch */ push$.pipe(observeOn(asyncScheduler)) .subscribe(() => { diff --git a/src/base.html b/src/base.html index 8eeb26215..eb9cddd2f 100644 --- a/src/base.html +++ b/src/base.html @@ -82,15 +82,6 @@ rel="stylesheet" href="{{ 'assets/stylesheets/palette.css' | url }}" /> - - - {% if palette.primary %} - {% import "partials/palette.html" as map %} - {% set primary = map.primary( - palette.primary | replace(" ", "-") | lower - ) %} - - {% endif %} {% endif %} @@ -159,12 +150,14 @@ {% if not palette is mapping %} {% set palette = palette | first %} {% endif %} - {% set scheme = palette.scheme | d("default", true) %} + {% set scheme = palette.scheme | d("default", true) %} + {% set primary = palette.primary | d("", true) %} + {% set accent = palette.accent | d("", true) %} {% else %} diff --git a/src/partials/palette.html b/src/partials/palette.html deleted file mode 100644 index 589e26b90..000000000 --- a/src/partials/palette.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -{% macro primary(key) %}{{ { - "red": "#ef5552", - "pink": "#e92063", - "purple": "#ab47bd", - "deep-purple": "#7e56c2", - "indigo": "#4051b5", - "blue": "#2094f3", - "light-blue": "#02a6f2", - "cyan": "#00bdd6", - "teal": "#009485", - "green": "#4cae4f", - "light-green": "#8bc34b", - "lime": "#cbdc38", - "yellow": "#ffec3d", - "amber": "#ffc105", - "orange": "#ffa724", - "deep-orange": "#ff6e42", - "brown": "#795649", - "grey": "#757575", - "blue-grey": "#546d78", - "black": "#000000", - "white": "#ffffff" -}[key] }}{% endmacro %} - - -{% macro accent(key) %}{{ { - "red": "#ff1a47", - "pink": "#f50056", - "purple": "#df41fb", - "deep-purple": "#7c4dff", - "indigo": "#526cfe", - "blue": "#4287ff", - "light-blue": "#0091eb", - "cyan": "#00bad6", - "teal": "#00bda4", - "green": "#00c753", - "light-green": "#63de17", - "lime": "#b0eb00", - "yellow": "#ffd500", - "amber": "#ffaa00", - "orange": "#ff9100", - "deep-orange": "#ff6e42" -}[key] }}{% endmacro %}