UNPKG

d2-ui

Version:
1 lines 2.41 kB
"use strict";(function(){var t,e,i,n=function(t,e){return function(){return t.apply(e,arguments)}},r=function(t,e){function i(){this.constructor=t}for(var n in e)o.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},o={}.hasOwnProperty,s=[].slice;t=require("react"),i=require("reactcss"),e=function(e){function o(){return this.handleControlsClick=n(this.handleControlsClick,this),this.handleClick=n(this.handleClick,this),o.__super__.constructor.apply(this,arguments)}return r(o,e),o.prototype.css=i.inline,o.prototype.classes=function(){return{"default":{tile:{fontSize:"16px",padding:"16px",display:"flex",justifyContent:"space-between",color:this.props.color},primary:{display:"flex",width:"100%"},sidebar:{minWidth:"56px",maxWidth:"56px",flexBasis:"56"},content:{background:"none",flex:"1",maxWidth:"95%"},secondary:{flexBasis:"42",textAlign:"center"},sidebarIcon:{marginTop:"-12px",marginLeft:"-12px",marginBottom:"-12px"}},clickable:{tile:{cursor:"pointer"}},divider:{tile:{boxShadow:"inset 0 -1px 0 rgba(0,0,0,.12)"}},condensed:{tile:{paddingBottom:"0",paddingTop:"0"},sidebar:{minWidth:"28px",maxWidth:"28px",flexBasis:"28"}}}},o.prototype.styles=function(){return this.css({clickable:null!=this.props.onClick})},o.prototype.handleClick=function(t){return null!=this.props.onClick?this.props.onClick(t):void 0},o.prototype.handleControlsClick=function(t){return null!=this.props.onClick?this.props.onClick(t,this.props.children):void 0},o.prototype.render=function(){var e,i,n,r,o;return t.createElement("div",{is:"tile",onClick:this.props.controls?this.handleControlsClick:this.handleClick,className:"flexbox-fix"},"[object Array]"===Object.prototype.toString.call(this.props.children)?(r=this.props.children,o=r[0],i=2<=r.length?s.call(r,1):[],r,t.createElement("div",{is:"primary",className:"flexbox-fix"},t.createElement("div",{is:"sidebar",key:"sidebar-"+o},"Icon"===o.type.name?t.createElement("div",{is:"sidebarIcon"},o):o),t.createElement("div",{is:"content",key:"content-"+i},function(){var r,o,s;for(s=[],n=r=0,o=i.length;o>r;n=++r)e=i[n],s.push(t.createElement("div",{key:n},e));return s}()))):t.createElement("div",{is:"primary"},t.createElement("div",{is:"content"},this.props.children)),this.props.secondaryAction?t.createElement("div",{is:"secondary"},this.props.secondaryAction):void 0)},o}(t.Component),module.exports=e}).call(void 0);