chunk.XA5TQN33.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {
  2. e as e2
  3. } from "./chunk.YXKHB4AC.js";
  4. import {
  5. T,
  6. e,
  7. h,
  8. n,
  9. r,
  10. r2
  11. } from "./chunk.5PIDMFOE.js";
  12. import {
  13. __decorateClass
  14. } from "./chunk.IHGPZX35.js";
  15. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/avatar/avatar.scss
  16. var avatar_default = ":host {\n position: relative;\n box-sizing: border-box;\n}\n:host *, :host *:before, :host *:after {\n box-sizing: inherit;\n}\n\n[hidden] {\n display: none !important;\n}\n\n:host {\n display: inline-block;\n --size: 3rem;\n}\n\n.avatar {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n position: relative;\n width: var(--size);\n height: var(--size);\n background-color: var(--sl-color-gray-300);\n font-family: var(--sl-font-sans);\n font-size: calc(var(--size) * 0.5);\n font-weight: var(--sl-font-weight-normal);\n color: var(--sl-color-white);\n overflow: hidden;\n user-select: none;\n vertical-align: middle;\n}\n\n.avatar--circle {\n border-radius: var(--sl-border-radius-circle);\n}\n\n.avatar--rounded {\n border-radius: var(--sl-border-radius-medium);\n}\n\n.avatar--square {\n border-radius: 0;\n}\n\n.avatar__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n\n.avatar__initials {\n line-height: 1;\n text-transform: uppercase;\n}\n\n.avatar__image {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n}";
  17. // src/components/avatar/avatar.ts
  18. var SlAvatar = class extends h {
  19. constructor() {
  20. super(...arguments);
  21. this.hasError = false;
  22. this.shape = "circle";
  23. }
  24. render() {
  25. return T`
  26. <div
  27. part="base"
  28. class=${e2({
  29. avatar: true,
  30. "avatar--circle": this.shape === "circle",
  31. "avatar--rounded": this.shape === "rounded",
  32. "avatar--square": this.shape === "square"
  33. })}
  34. aria-label=${this.alt}
  35. >
  36. ${this.initials ? T` <div part="initials" class="avatar__initials">${this.initials}</div> ` : T`
  37. <div part="icon" class="avatar__icon">
  38. <slot name="icon">
  39. <sl-icon name="person-fill" library="system"></sl-icon>
  40. </slot>
  41. </div>
  42. `}
  43. ${this.image && !this.hasError ? T`
  44. <img part="image" class="avatar__image" src="${this.image}" @error="${() => this.hasError = true}" />
  45. ` : ""}
  46. </div>
  47. `;
  48. }
  49. };
  50. SlAvatar.styles = r(avatar_default);
  51. __decorateClass([
  52. r2()
  53. ], SlAvatar.prototype, "hasError", 2);
  54. __decorateClass([
  55. e()
  56. ], SlAvatar.prototype, "image", 2);
  57. __decorateClass([
  58. e()
  59. ], SlAvatar.prototype, "alt", 2);
  60. __decorateClass([
  61. e()
  62. ], SlAvatar.prototype, "initials", 2);
  63. __decorateClass([
  64. e({ reflect: true })
  65. ], SlAvatar.prototype, "shape", 2);
  66. SlAvatar = __decorateClass([
  67. n("sl-avatar")
  68. ], SlAvatar);
  69. var avatar_default2 = SlAvatar;
  70. export {
  71. avatar_default2 as avatar_default
  72. };