Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const Gauge = props => {
const score = Math.round(props.score * 100);
const rawBaseScore = props.diff ? props.diff.baseValue : props.score;
const baseScore = Math.round(rawBaseScore * 100);
const label = props.diff ? getDiffLabel(props.diff) : 'neutral';
// 352 is ~= 2 * Math.PI * gauge radius (56)
// https://codepen.io/xgad/post/svg-radial-progress-meters
// score of 50: `stroke-dasharray: 176 352`;
// The roundcap on the arc makes it extend slightly past where it should, so we need to adjust it by a few pts.
const baseDasharrayScore = Math.max(0, props.score * 352 - 2);
const baseStrokeDasharray = `${baseDasharrayScore} 352`;
const delta = Math.abs(baseScore - score);
const deltaDasharrayScore = Math.max(0, (delta / 100) * 352 - 2);
const deltaStrokeDasharray = `${deltaDasharrayScore} 352`;
const deltaTransform = `rotate(${(Math.min(score, baseScore) / 100) * 360}deg)`;
const indicatorTransform = `rotate(${props.score * 360}deg)`;
return (
<div>
<div></div></div>
const ScoreDiff = props => {
return (
<i>
arrow_forward
</i>
);
};
/** @type {LHCI.NumericAuditDiff|undefined} */
let diff = undefined;
if (baseLhr) {
const baseCategory = baseLhr.categories[categoryId];
if (baseCategory) {
diff = {
auditId: '',
type: 'score',
baseValue: baseCategory.score,
compareValue: category.score,
};
const delta = renderScore(category.score - baseCategory.score);
classes = `build-score-comparison-item--${getDiffLabel(diff)}`;
deltaEl = (
<div>
{delta < 0 ? delta : `+${delta}`}
</div>
);
}
}
return (
<div>
<div>{category.title}</div>
{deltaEl}
</div>
);
const ScoreOnlyDetails = props => {
const {audit, baseAudit} = props.pair;
if (!baseAudit) return null;
return (
<div>
<i>
arrow_forward
</i>
</div>
);
};