@@ -44,6 +44,11 @@ customElements.define(
4444 content = this . querySelector ( 'progress' ) . innerHTML ;
4545 }
4646
47+ // We need different styles for the content depending on the presence of a prpl-badge.
48+ const contentSpecificStyles = content . includes ( '<prpl-badge' )
49+ ? 'bottom: 50%;'
50+ : 'top: -1em; padding-top: 50%;' ;
51+
4752 props . background =
4853 this . getAttribute ( 'background' ) || props . background ;
4954 props . color = this . getAttribute ( 'color' ) || props . color ;
@@ -58,39 +63,15 @@ customElements.define(
5863
5964 this . innerHTML = `
6065 <div style="padding: ${ props . contentPadding } ;
61- background: ${
62- props . background
63- } ; border-radius:var(--prpl-border-radius-big); aspect-ratio: 2 / 1; overflow: hidden; position: relative; margin-bottom: ${
64- props . marginBottom
65- } ;">
66- <div style="width: 100%; aspect-ratio: 1 / 1; border-radius: 100%; position: relative; background: radial-gradient(${
67- props . background
68- } 0 ${ props . cutout } , transparent ${
69- props . cutout
70- } 100%), conic-gradient(from ${ props . start } , ${
71- props . color
72- } calc(${ props . maxDeg } * ${
73- props . value
74- } ), var(--prpl-color-gray-1) calc(${ props . maxDeg } * ${
75- props . value
76- } ) ${ props . maxDeg } , transparent ${
77- props . maxDeg
78- } ); text-align: center;">
66+ background: ${ props . background } ; border-radius:var(--prpl-border-radius-big); aspect-ratio: 2 / 1; overflow: hidden; position: relative; margin-bottom: ${ props . marginBottom } ;">
67+ <div style="width: 100%; aspect-ratio: 1 / 1; border-radius: 100%; position: relative; background: radial-gradient(${ props . background } 0 ${ props . cutout } , transparent ${ props . cutout } 100%), conic-gradient(from ${ props . start } , ${ props . color } calc(${ props . maxDeg } * ${ props . value } ), var(--prpl-color-gray-1) calc(${ props . maxDeg } * ${ props . value } ) ${ props . maxDeg } , transparent ${ props . maxDeg } ); text-align: center;">
7968 <span style="font-size: var(--prpl-font-size-small); position: absolute; top: 50%; color: var(--prpl-color-gray-5); width: 10%; text-align: center; left:0;">0</span>
80- <span style="font-size: ${
81- props . contentFontSize
82- } ; top: -1em; display: block; padding-top: 50%; font-weight: 600; text-align: center; position: absolute; color: var(--prpl-color-gray-5); width: 100%; line-height: 1.2;">
83- <span style="display:inline-block;width: 50%; ${
84- content . includes ( '<prpl-badge' )
85- ? 'margin-top: -1em;'
86- : ''
87- } ">
69+ <span style="font-size: ${ props . contentFontSize } ; ${ contentSpecificStyles } display: block; font-weight: 600; text-align: center; position: absolute; color: var(--prpl-color-gray-5); width: 100%; line-height: 1.2;">
70+ <span style="display:inline-block;width: 50%;">
8871 ${ content }
8972 </span>
9073 </span>
91- <span style="font-size: var(--prpl-font-size-small); position: absolute; top: 50%; color: var(--prpl-color-gray-5); width: 10%; text-align: center; right:0;">${
92- props . max
93- } </span>
74+ <span style="font-size: var(--prpl-font-size-small); position: absolute; top: 50%; color: var(--prpl-color-gray-5); width: 10%; text-align: center; right:0;">${ props . max } </span>
9475 </div>
9576 </div>
9677 ` ;
0 commit comments