@dracoui/ember
Version:
Draco Design System for Ember
3 lines (2 loc) • 2.72 kB
JavaScript
import{_ as e,a as r}from"../../../_rollupPluginBabelHelpers-CLoDr8uC.js";import{DracoAvatarShapeValues as s,DracoAvatarSizeValues as t}from"./types.js";import{assert as a}from"@ember/debug";import{action as i}from"@ember/object";import{isPresent as o}from"@ember/utils";import n from"@glimmer/component";import{tracked as l}from"@glimmer/tracking";import{precompileTemplate as h}from"@ember/template-compilation";import{setComponentTemplate as p}from"@ember/component";var m,c,g,d=h('<span class={{this.classNames}} ...attributes>\n <img\n src={{this.src}}\n draggable={{false}}\n width={{if (eq this.size "small") 30 (if (eq this.size "medium") 39 47)}}\n height={{if (eq this.size "small") 30 (if (eq this.size "medium") 39 47)}}\n {{on "load" this.handleImageLoad}}\n {{on "error" this.handleImageError}}\n style={{if this.hasError "display: none;"}}\n class={{if this.isLoading "draco-avatar__image--loading"}}\n />\n\n {{#if (or this.isLoading this.hasError)}}\n <span class="draco-avatar__placeholder">\n {{#if this.hasError}}\n <span class="draco-avatar__error">{{this.alt}}</span>\n {{else}}\n <Draco::Skeleton @size={{this.size}} />\n {{/if}}\n </span>\n {{/if}}\n</span>\n');const u=t.Medium,f=s.Circle,b=Object.values(t),v=Object.values(s);let y=(c=e((m=class extends n{constructor(...e){super(...e),r(this,"hasError",c,this),r(this,"isLoading",g,this)}handleImageLoad(){this.isLoading=!1,this.hasError=!1}handleImageError(){this.isLoading=!1,this.hasError=!0}get shape(){const{shape:e=f}=this.args;return a(`@shape for "Draco::Avatar" must be one of the following: ${v.join(", ")}; received: ${e}`,v.includes(e)),e}get alt(){const{alt:e}=this.args;return e?e.replace("@","").slice(0,2).toUpperCase():""}get size(){const{size:e=u}=this.args;return a(`@size for "Draco::Avatar" must be one of the following ${b.join(", ")}; received: ${e}`,b.includes(e)),e}get src(){return o(this.args.src)?this.args.src:""}get classNames(){const e=["draco-avatar"];return e.push(`draco-avatar--size-${this.size}`),e.push(`draco-avatar--shape-${this.shape}`),e.join(" ")}}).prototype,"hasError",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),g=e(m.prototype,"isLoading",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),e(m.prototype,"handleImageLoad",[i],Object.getOwnPropertyDescriptor(m.prototype,"handleImageLoad"),m.prototype),e(m.prototype,"handleImageError",[i],Object.getOwnPropertyDescriptor(m.prototype,"handleImageError"),m.prototype),m);p(d,y);export{v as AVAILABLE_SHAPES,b as AVAILABLE_SIZES,f as DEFAULT_SHAPE,u as DEFAULT_SIZE,y as default};
//# sourceMappingURL=index.js.map