chunk.Y5OHTPF7.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {
  2. watch
  3. } from "./chunk.XX234VRK.js";
  4. import {
  5. T,
  6. e,
  7. h,
  8. n,
  9. o,
  10. r
  11. } from "./chunk.5PIDMFOE.js";
  12. import {
  13. __decorateClass
  14. } from "./chunk.IHGPZX35.js";
  15. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/progress-ring/progress-ring.scss
  16. var progress_ring_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 --track-color: var(--sl-color-gray-200);\n --indicator-color: var(--sl-color-primary-500);\n display: inline-flex;\n}\n\n.progress-ring {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n position: relative;\n}\n\n.progress-ring__image {\n transform: rotate(-90deg);\n transform-origin: 50% 50%;\n}\n\n.progress-ring__track {\n stroke: var(--track-color);\n}\n\n.progress-ring__indicator {\n stroke: var(--indicator-color);\n transition: 0.35s stroke-dashoffset, 0.35s stroke;\n}\n\n.progress-ring__label {\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 text-align: center;\n user-select: none;\n}";
  17. // src/components/progress-ring/progress-ring.ts
  18. var SlProgressRing = class extends h {
  19. constructor() {
  20. super(...arguments);
  21. this.size = 128;
  22. this.strokeWidth = 4;
  23. }
  24. firstUpdated() {
  25. this.updateProgress();
  26. }
  27. handlePercentageChange() {
  28. this.updateProgress();
  29. }
  30. updateProgress() {
  31. const radius = this.indicator.r.baseVal.value;
  32. const circumference = radius * 2 * Math.PI;
  33. const offset = circumference - this.percentage / 100 * circumference;
  34. this.indicator.style.strokeDasharray = `${circumference} ${circumference}`;
  35. this.indicator.style.strokeDashoffset = `${offset}`;
  36. }
  37. render() {
  38. return T`
  39. <div
  40. part="base"
  41. class="progress-ring"
  42. role="progressbar"
  43. aria-valuemin="0"
  44. aria-valuemax="100"
  45. aria-valuenow="${this.percentage}"
  46. >
  47. <svg class="progress-ring__image" width=${this.size} height=${this.size}>
  48. <circle
  49. class="progress-ring__track"
  50. stroke-width="${this.strokeWidth}"
  51. stroke-linecap="round"
  52. fill="transparent"
  53. r=${this.size / 2 - this.strokeWidth * 2}
  54. cx=${this.size / 2}
  55. cy=${this.size / 2}
  56. ></circle>
  57. <circle
  58. class="progress-ring__indicator"
  59. stroke-width="${this.strokeWidth}"
  60. stroke-linecap="round"
  61. fill="transparent"
  62. r=${this.size / 2 - this.strokeWidth * 2}
  63. cx=${this.size / 2}
  64. cy=${this.size / 2}
  65. ></circle>
  66. </svg>
  67. <span part="label" class="progress-ring__label">
  68. <slot></slot>
  69. </span>
  70. </div>
  71. `;
  72. }
  73. };
  74. SlProgressRing.styles = r(progress_ring_default);
  75. __decorateClass([
  76. o(".progress-ring__indicator")
  77. ], SlProgressRing.prototype, "indicator", 2);
  78. __decorateClass([
  79. e({ type: Number })
  80. ], SlProgressRing.prototype, "size", 2);
  81. __decorateClass([
  82. e({ attribute: "stroke-width", type: Number })
  83. ], SlProgressRing.prototype, "strokeWidth", 2);
  84. __decorateClass([
  85. e({ type: Number, reflect: true })
  86. ], SlProgressRing.prototype, "percentage", 2);
  87. __decorateClass([
  88. watch("percentage")
  89. ], SlProgressRing.prototype, "handlePercentageChange", 1);
  90. SlProgressRing = __decorateClass([
  91. n("sl-progress-ring")
  92. ], SlProgressRing);
  93. var progress_ring_default2 = SlProgressRing;
  94. export {
  95. progress_ring_default2 as progress_ring_default
  96. };