@harpercollins/harpercollins-design-system 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ interface TrafficLightsExtended extends TrafficLights {
15
15
  export type TrafficLightRanges = TrafficLights | TrafficLightsExtended;
16
16
  interface ProgressCircleProps {
17
17
  size?: "tiny" | "small" | "medium" | "large";
18
- value: number;
18
+ value: number | null | undefined;
19
19
  kind?: "default" | "danger" | "success" | "traffic-light";
20
20
  trafficLightRanges?: TrafficLightRanges;
21
21
  }
@@ -7,3 +7,6 @@ export declare const Default: Story;
7
7
  export declare const Danger: Story;
8
8
  export declare const TrafficLight: Story;
9
9
  export declare const TrafficLightWithCustomRanges: Story;
10
+ export declare const ZeroValue: Story;
11
+ export declare const NullValue: Story;
12
+ export declare const UndefinedValue: Story;
package/dist/esm/index.js CHANGED
@@ -757,7 +757,7 @@ function oc(e,t){const n=tc(e,t);return"production"!==process.env.NODE_ENV?(...t
757
757
  transition: width 1s ease;
758
758
  animation: ${Uw} 3s ease infinite;
759
759
  transform: rotate(180deg);
760
- `;function Jw({ariaLabel:t,percentage:n}){return e(Yw,{role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,children:e(Kw,{style:{width:`${n}%`}})})}function Xw({size:n="medium",value:o=0,kind:r="default",trafficLightRanges:a={red:{min:0,max:20,text:""},redLow:{min:20,max:40,text:""},orange:{min:40,max:60,text:""},green:{min:60,max:80,text:""},greenHigh:{min:80,max:100,text:""}}}){const i={mini:"0.8rem",tiny:"1rem",small:"1.2rem",medium:"1.6rem",large:"2rem"}[n],l={mini:50,tiny:75,small:100,medium:150,large:200}[n],s=(({kind:e,percentage:t,trafficLightRanges:n})=>{const o="var(--color--primary)",r="var(--color--danger)",a="var(--color--green-dark)",i="var(--color--red)",l="var(--color--orange-dark)",s="var(--color--green-dark)";return(()=>{if("traffic-light"===e){const e=Object.entries(n).find((([,e])=>t>=e.min&&t<=e.max))?.[0];return"red"===e||"redLow"===e?i:"orange"===e?l:"green"===e||"greenHigh"===e?s:"#d7d7d7"}return"danger"===e?r:"success"===e?a:"default"===e?o:"#d7d7d7"})()})({kind:r,percentage:Math.round(o),trafficLightRanges:a}),d=l/7,[p,f]=c(0);u((()=>{f(o)}),[o]);const m=(l-d)/2,g=m*Math.PI*2,h=p*g/100;return t("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,children:[e("circle",{fill:"white",stroke:"#d7d7d7",cx:l/2,cy:l/2,r:m,strokeWidth:`${d}px`}),e("circle",{fill:"none",stroke:s,cx:l/2,cy:l/2,r:m,strokeWidth:`${d}px`,transform:`rotate(-90 ${l/2} ${l/2})`,strokeDasharray:`${h}, ${g-h}`,strokeLinecap:"round",style:{transition:"all 0.5s"}}),e("text",{fill:"black",fontSize:i,fontWeight:"bold",x:"50%",y:"50%",dy:"6%",textAnchor:"middle",children:(v=o,v>=0&&v<=100?`${o}%`:"-")})]});var v}const Qw=rn.div`
760
+ `;function Jw({ariaLabel:t,percentage:n}){return e(Yw,{role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,children:e(Kw,{style:{width:`${n}%`}})})}function Xw({size:n="medium",value:o,kind:r="default",trafficLightRanges:a={red:{min:0,max:20,text:""},redLow:{min:20,max:40,text:""},orange:{min:40,max:60,text:""},green:{min:60,max:80,text:""},greenHigh:{min:80,max:100,text:""}}}){const i={mini:"0.8rem",tiny:"1rem",small:"1.2rem",medium:"1.6rem",large:"2rem"}[n],l={mini:50,tiny:75,small:100,medium:150,large:200}[n],s=o?(({kind:e,percentage:t,trafficLightRanges:n})=>{const o="var(--color--primary)",r="var(--color--danger)",a="var(--color--green-dark)",i="var(--color--red)",l="var(--color--orange-dark)",s="var(--color--green-dark)";return(()=>{if("traffic-light"===e){const e=Object.entries(n).find((([,e])=>t>=e.min&&t<=e.max))?.[0];return"red"===e||"redLow"===e?i:"orange"===e?l:"green"===e||"greenHigh"===e?s:"#d7d7d7"}return"danger"===e?r:"success"===e?a:"default"===e?o:"#d7d7d7"})()})({kind:r,percentage:Math.round(o),trafficLightRanges:a}):void 0,d=l/7,[p,f]=c(0);u((()=>{f(o)}),[o]);const m=(l-d)/2,g=m*Math.PI*2,h=p?p*g/100:0;return t("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,children:[e("circle",{fill:"white",stroke:"#d7d7d7",cx:l/2,cy:l/2,r:m,strokeWidth:`${d}px`}),e("circle",{fill:"none",stroke:s,cx:l/2,cy:l/2,r:m,strokeWidth:`${d}px`,transform:`rotate(-90 ${l/2} ${l/2})`,strokeDasharray:`${h}, ${g-h}`,strokeLinecap:"round",style:{transition:"all 0.5s"}}),e("text",{fill:"black",fontSize:i,fontWeight:"bold",x:"50%",y:"50%",dy:"6%",textAnchor:"middle",children:null!=o&&(v=o,v>=0&&v<=100)?`${o}%`:"-"})]});var v}const Qw=rn.div`
761
761
  display: flex;
762
762
  flex-direction: column;
763
763
  align-items: flex-start;