Skip to content

Commit 242c2f8

Browse files
authored
fix(baseline): checkmarks weren't reflecting mobile status (#11002)
1 parent 81ec2a7 commit 242c2f8

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

Diff for: client/src/document/baseline-indicator.tsx

+42-17
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,35 @@ import { useLocation } from "react-router";
77

88
import "./baseline-indicator.scss";
99

10-
import type { SupportStatus } from "../../../libs/types/web-features";
10+
import type {
11+
SupportStatus,
12+
browserIdentifier,
13+
} from "../../../libs/types/web-features";
1114

12-
const ENGINES = [
13-
{ name: "Blink", browsers: ["Chrome", "Edge"] },
14-
{ name: "Gecko", browsers: ["Firefox"] },
15-
{ name: "WebKit", browsers: ["Safari"] },
15+
interface BrowserGroup {
16+
name: string;
17+
ids: browserIdentifier[];
18+
}
19+
20+
const ENGINES: {
21+
name: string;
22+
browsers: BrowserGroup[];
23+
}[] = [
24+
{
25+
name: "Blink",
26+
browsers: [
27+
{ name: "Chrome", ids: ["chrome", "chrome_android"] },
28+
{ name: "Edge", ids: ["edge"] },
29+
],
30+
},
31+
{
32+
name: "Gecko",
33+
browsers: [{ name: "Firefox", ids: ["firefox", "firefox_android"] }],
34+
},
35+
{
36+
name: "WebKit",
37+
browsers: [{ name: "Safari", ids: ["safari", "safari_ios"] }],
38+
},
1639
];
1740

1841
const LOCALIZED_BCD_IDS = {
@@ -52,25 +75,27 @@ export function BaselineIndicator({ status }: { status: SupportStatus }) {
5275
pathname
5376
)}&level=${level}`;
5477

55-
const supported = (browser: string) => {
56-
const version: string | undefined = status.support?.[browser.toLowerCase()];
57-
return Boolean(status.baseline || version);
78+
const supported = (browser: BrowserGroup) => {
79+
return browser.ids
80+
.map((id) => status.support?.[id])
81+
.every((version) => Boolean(version));
5882
};
5983

60-
const engineTitle = (browsers: string[]) =>
84+
const engineTitle = (browsers: BrowserGroup[]) =>
6185
browsers
6286
.map((browser, index, array) => {
6387
const previous = index > 0 ? supported(array[index - 1]) : undefined;
6488
const current = supported(browser);
89+
const name = browser.name;
6590
return typeof previous === "undefined"
6691
? current
67-
? `Supported in ${browser}`
68-
: `Not widely supported in ${browser}`
92+
? `Supported in ${name}`
93+
: `Not widely supported in ${name}`
6994
: current === previous
70-
? ` and ${browser}`
95+
? ` and ${name}`
7196
: current
72-
? `, and supported in ${browser}`
73-
: `, and not widely supported in ${browser}`;
97+
? `, and supported in ${name}`
98+
: `, and not widely supported in ${name}`;
7499
})
75100
.join("");
76101

@@ -105,12 +130,12 @@ export function BaselineIndicator({ status }: { status: SupportStatus }) {
105130
<span key={name} className="engine" title={engineTitle(browsers)}>
106131
{browsers.map((browser) => (
107132
<span
108-
key={browser}
109-
className={`browser ${browser.toLowerCase()} ${
133+
key={browser.ids[0]}
134+
className={`browser ${browser.ids[0]} ${
110135
supported(browser) ? "supported" : ""
111136
}`}
112137
role="img"
113-
aria-label={`${browser} ${
138+
aria-label={`${browser.name} ${
114139
supported(browser) ? "check" : "cross"
115140
}`}
116141
/>

Diff for: libs/types/web-features.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface FeatureData {
2222
| [usage_stats_url, usage_stats_url, ...usage_stats_url[]]; // A single URL or an array of two or more
2323
}
2424

25-
type browserIdentifier =
25+
export type browserIdentifier =
2626
| "chrome"
2727
| "chrome_android"
2828
| "edge"

0 commit comments

Comments
 (0)