From beea22e71529a7989c99b65fb7012beddb1bf187 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Sat, 3 Apr 2021 14:31:23 -0700 Subject: [PATCH] Simplify function signature Just use a boolean, keep things simple --- .../browser-compatibility-table/feature-row.tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/client/src/document/ingredients/browser-compatibility-table/feature-row.tsx b/client/src/document/ingredients/browser-compatibility-table/feature-row.tsx index 61101436dca6..4f33bea0e880 100644 --- a/client/src/document/ingredients/browser-compatibility-table/feature-row.tsx +++ b/client/src/document/ingredients/browser-compatibility-table/feature-row.tsx @@ -103,7 +103,7 @@ function NonBreakingSpace() { function labelFromString( version: string | boolean | null | undefined, - action: string + removed?: boolean ) { if (typeof version !== "string") { return <>{"?"}; @@ -111,7 +111,7 @@ function labelFromString( if (!version.startsWith("≤")) { return <>{version}; } - const actionDescription = action === "removed" ? "ended" : "started"; + const actionDescription = removed ? "ended" : "started"; const versionDescription = `version ${version.slice(1)} or earlier`; const title = `Support ${actionDescription} in ${versionDescription} (specific version unknown)`; return ( @@ -144,7 +144,7 @@ const CellText = React.memo( status = { isSupported: "no" }; break; default: - status = { isSupported: "yes", label: labelFromString(added, "added") }; + status = { isSupported: "yes", label: labelFromString(added) }; break; } @@ -153,18 +153,15 @@ const CellText = React.memo( isSupported: "no", label: ( <> - {labelFromString(added, "added")} - — {labelFromString(removed, "removed")} + {labelFromString(added)} + — {labelFromString(removed, true)} ), }; } else if (currentSupport && currentSupport.partial_implementation) { status = { isSupported: "partial", - label: - typeof added === "string" - ? labelFromString(added, "added") - : "Partial", + label: typeof added === "string" ? labelFromString(added) : "Partial", }; }