@appscode/ui-builder
Version:
## Motivation
1 lines • 2.31 kB
JavaScript
;var t=/^(attrs|props|on|nativeOn|class|style|hook)$/;function e(t,e){return function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}}var r=function(){return Math.random().toString(36).substring(2)},a={name:"ContentLoader",functional:!0,props:{width:{type:[Number,String],default:400},height:{type:[Number,String],default:130},speed:{type:Number,default:2},preserveAspectRatio:{type:String,default:"xMidYMid meet"},baseUrl:{type:String,default:""},primaryColor:{type:String,default:"#f9f9f9"},secondaryColor:{type:String,default:"#ecebeb"},primaryOpacity:{type:Number,default:1},secondaryOpacity:{type:Number,default:1},uniqueKey:{type:String},animate:{type:Boolean,default:!0}},render:function(a,i){var s=i.props,n=i.data,o=i.children,p=s.uniqueKey?s.uniqueKey+"-idClip":r(),u=s.uniqueKey?s.uniqueKey+"-idGradient":r();return a("svg",[n,{attrs:{viewBox:"0 0 "+s.width+" "+s.height,version:"1.1",preserveAspectRatio:s.preserveAspectRatio}}].reduce((function(r,a){var i,s,n,o,p;for(n in a)if(i=r[n],s=a[n],i&&t.test(n))if("class"===n&&("string"==typeof i&&(p=i,r[n]=i={},i[p]=!0),"string"==typeof s&&(p=s,a[n]=s={},s[p]=!0)),"on"===n||"nativeOn"===n||"hook"===n)for(o in s)i[o]=e(i[o],s[o]);else if(Array.isArray(i))r[n]=i.concat(s);else if(Array.isArray(s))r[n]=[i].concat(s);else for(o in s)i[o]=s[o];else r[n]=a[n];return r}),{}),[a("rect",{style:{fill:"url("+s.baseUrl+"#"+u+")"},attrs:{"clip-path":"url("+s.baseUrl+"#"+p+")",x:"0",y:"0",width:s.width,height:s.height}}),a("defs",[a("clipPath",{attrs:{id:p}},[o||a("rect",{attrs:{x:"0",y:"0",rx:"5",ry:"5",width:s.width,height:s.height}})]),a("linearGradient",{attrs:{id:u}},[a("stop",{attrs:{offset:"0%","stop-color":s.primaryColor,"stop-opacity":s.primaryOpacity}},[s.animate?a("animate",{attrs:{attributeName:"offset",values:"-2; 1",dur:s.speed+"s",repeatCount:"indefinite"}}):null]),a("stop",{attrs:{offset:"50%","stop-color":s.secondaryColor,"stop-opacity":s.secondaryOpacity}},[s.animate?a("animate",{attrs:{attributeName:"offset",values:"-1.5; 1.5",dur:s.speed+"s",repeatCount:"indefinite"}}):null]),a("stop",{attrs:{offset:"100%","stop-color":s.primaryColor,"stop-opacity":s.primaryOpacity}},[s.animate?a("animate",{attrs:{attributeName:"offset",values:"-1; 2",dur:s.speed+"s",repeatCount:"indefinite"}}):null])])])])}};exports.C=a;