@dracoui/ember
Version:
Draco Design System for Ember
3 lines (2 loc) • 3.52 kB
JavaScript
import{DracoBadgeSizeValues as e,DracoBadgeColorValues as t,DracoBadgeIconPositionValues as i,DracoBadgeTypeValues as s}from"./types.js";import{assert as n}from"@ember/debug";import o from"@glimmer/component";import{precompileTemplate as r}from"@ember/template-compilation";import{setComponentTemplate as a}from"@ember/component";var c=r('<span\n class={{this.classNames}}\n ...attributes\n>\n {{#if this.badgeText}}\n {{#if this.icon}}\n {{#if (eq this.iconPosition "leading")}}\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n\n <span class="draco-badge__text">\n {{this.badgeText}}\n </span>\n {{else}}\n <span class="draco-badge__text">\n {{this.badgeText}}\n </span>\n\n <Draco::Icon @name={{this.icon}} @size={{this.iconSize}} />\n {{/if}}\n {{else}}\n <span class="draco-badge__text">\n {{this.badgeText}}\n </span>\n {{/if}}\n {{/if}}\n\n {{#if (eq this.type "chip")}}\n {{#each (array "top" "bottom" "left" "right") as |side|}}\n <svg\n width={{if (or (eq side "top") (eq side "bottom")) "100%" "1"}}\n height={{if (or (eq side "left") (eq side "right")) "100%" "1"}}\n stroke="currentColor"\n stroke-dasharray="3.3 1"\n aria-hidden="true"\n class="draco-badge--dashed-border draco-badge--dashed-border--{{side}}"\n >\n <line\n x1={{if (or (eq side "top") (eq side "bottom")) "0" "0.5"}}\n y1={{if (or (eq side "left") (eq side "right")) "0" "0.5"}}\n x2={{if (or (eq side "top") (eq side "bottom")) "100%" "0.5"}}\n y2={{if (or (eq side "left") (eq side "right")) "100%" "0.5"}}\n ></line>\n </svg>\n {{/each}}\n {{/if}}\n\n {{yield}}\n</span>');const d=s.Pill,l=e.Medium,g=t.Primary,h=i.Leading,u=Object.values(e),b=Object.values(s),f=Object.values(t),m=Object.values(i);class p extends o{get size(){const{size:e=l}=this.args;return n(`@size for "Draco::Badge" must be one of the following ${u.join(", ")}; received: ${e}`,u.includes(e)),e}get color(){const{color:e=g}=this.args;return n(`@color for "Draco::Badge" must be one of the following ${f.join(", ")}; received: ${e}`,f.includes(e)),"chip"!==this.type||e.includes("-subtle")?e:`${e}-subtle`}get iconSize(){const{iconSize:e}=this.args;if(!e)switch(this.size){case"small":return 16;case"medium":return 20;case"large":return 26}return e}get icon(){const{icon:e}=this.args;return e}get iconPosition(){const{iconPosition:e=h}=this.args;return n(`@iconPosition for "Draco::Button" can't be used if @isIconOnly is '${this.args.isIconOnly}'`,!(this.args.iconPosition&&this.args.isIconOnly)),n(`@iconPosition for "Draco::Button" must be one of the following: ${m.join(", ")}; received: ${e}`,m.includes(e)),e}get type(){const{type:e=d}=this.args;return n(`@type for "Draco::Badge" must be one of the following ${b.join(", ")}; received: ${e}`,b.includes(e)),e}get badgeText(){const{text:e,label:t}=this.args;return n('Cannot use both @text and @label arguments on "Draco::Badge" simultaneously',!(e&&t)),e||t}get classNames(){const e=["draco-badge"];return e.push(`draco-badge--${this.size}`),e.push(`draco-badge--${this.color}`),e.push(`draco-badge--${this.type}`),e.join(" ")}}a(c,p);export{f as AVAILABLE_COLORS,m as AVAILABLE_ICON_POSITIONS,u as AVAILABLE_SIZES,b as AVAILABLE_TYPES,g as DEFAULT_COLOR,h as DEFAULT_ICON_POSITION,l as DEFAULT_SIZE,d as DEFAULT_TYPE,p as default};
//# sourceMappingURL=index.js.map