Rename v1 to web-check-live

This commit is contained in:
Alicia Sykes
2024-05-08 21:23:03 +01:00
parent e5738d1f5b
commit 7e27143a90
77 changed files with 240 additions and 240 deletions

View File

@@ -0,0 +1,52 @@
import { Card } from 'web-check-live/components/Form/Card';
import { ExpandableRow } from 'web-check-live/components/Form/Row';
const processScore = (percentile: number) => {
return `${Math.round(percentile * 100)}%`;
}
interface Audit {
id: string,
score?: number | string,
scoreDisplayMode?: string,
title?: string,
description?: string,
displayValue?: string,
};
const makeValue = (audit: Audit) => {
let score = audit.score;
if (audit.displayValue) {
score = audit.displayValue;
} else if (audit.scoreDisplayMode) {
score = audit.score === 1 ? '✅ Pass' : '❌ Fail';
}
return score;
};
const LighthouseCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const lighthouse = props.data;
const categories = lighthouse?.categories || {};
const audits = lighthouse?.audits || [];
return (
<Card heading={props.title} actionButtons={props.actionButtons}>
{ Object.keys(categories).map((title: string, index: number) => {
const scoreIds = categories[title].auditRefs.map((ref: { id: string }) => ref.id);
const scoreList = scoreIds.map((id: string) => {
return { lbl: audits[id].title, val: makeValue(audits[id]), title: audits[id].description, key: id }
})
return (
<ExpandableRow
key={`lighthouse-${index}`}
lbl={title}
val={processScore(categories[title].score)}
rowList={scoreList}
/>
);
}) }
</Card>
);
}
export default LighthouseCard;