Skip to content

Commit

Permalink
Simplify function signature
Browse files Browse the repository at this point in the history
Just use a boolean, keep things simple
  • Loading branch information
cincodenada committed Feb 27, 2021
1 parent 4c7c440 commit de8b101
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ function NonBreakingSpace() {

function labelFromString(
version: string | boolean | null | undefined,
action: string
removed?: boolean
) {
if (typeof version !== "string") {
return <>{"?"}</>;
}
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 (
Expand Down Expand Up @@ -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;
}

Expand All @@ -153,18 +153,15 @@ const CellText = React.memo(
isSupported: "no",
label: (
<>
{labelFromString(added, "added")}
<NonBreakingSpace />{labelFromString(removed, "removed")}
{labelFromString(added)}
<NonBreakingSpace />{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",
};
}

Expand Down

0 comments on commit de8b101

Please sign in to comment.