Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions components/baseline-indicator/icons/status/pending-removal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions components/baseline-indicator/server.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@

@mixin light-dark --baseline-img, url("./icons/status/obsolete.svg"),
url("./icons/status/obsolete-dark.svg");

&.to-be-removed {
--baseline-bg: #fceeee;
--baseline-engine-bg: #f3dddd;
--baseline-pill-bg: #b3261e;
--baseline-pill-color: #f1f3f4;

@mixin light-dark --baseline-img,
url("./icons/status/pending-removal.svg"),
url("./icons/status/pending-removal-dark.svg");
}
}

&[open] {
Expand Down
78 changes: 53 additions & 25 deletions components/baseline-indicator/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { html } from "@lit-labs/ssr";
import { nothing } from "lit";
import { unsafeHTML } from "lit/directives/unsafe-html.js";

import { ServerComponent } from "../server/index.js";

Expand Down Expand Up @@ -79,6 +80,7 @@
const level = status.feature.discouraged
? "discouraged"
: status.baseline || "not";
const removalDate = status.feature.discouraged?.removal_date;

Check failure on line 83 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Property 'removal_date' does not exist on type 'Discouraged'.

const feedbackLink = `${SURVEY_URL}?page=${encodeURIComponent(context.url)}&level=${level}`;

Expand Down Expand Up @@ -130,10 +132,35 @@
}
};

const renderAlternatives =
/**
* @param {string} instruction
* @param {import("@rari").Alternative[]} [alternatives]

Check failure on line 138 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Namespace '"/home/runner/work/fred/fred/types/rari"' has no exported member 'Alternative'.
*/
(instruction, alternatives) =>
alternatives && alternatives.length > 0
? html`<p>${instruction}</p>
<ul class="alternatives">
${alternatives.map(
({ name, description, mdn_url }) =>
html`<li>
<a
href=${mdn_url.replace(
"/docs",
`/${context.locale}/docs`,
)}
title=${description}
>${name}</a
>
</li>`,
)}
</ul>`
: nothing;

const openByDefault = level === "discouraged";

return html`<details
class="baseline-indicator ${level}"
class="baseline-indicator ${level} ${removalDate ? "to-be-removed" : ""}"
data-glean-toggle-open="baseline_toggle_open"
?open=${openByDefault}
?data-open-by-default=${openByDefault}
Expand Down Expand Up @@ -167,7 +194,9 @@
</div>
${level === "low"
? html`<div class="pill">${context.l10n`Newly available`}</div>`
: nothing}
: level === "discouraged" && removalDate
? html`<div class="pill">${context.l10n`To be removed`}</div>`
: nothing}
<div class="browsers">
${ENGINES.map(
({ name, browsers }) =>
Expand Down Expand Up @@ -219,29 +248,28 @@
? html`<p>* ${context.l10n("baseline-asterisk")}</p>`
: nothing}`
: level === "discouraged"
? html`<p>
${context.l10n`Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.`}
</p>
${status.alternatives && status.alternatives.length > 0
? html`<p>
${context.l10n`Consider using the following features instead:`}
</p>
<ul class="alternatives">
${status.alternatives.map(
({ name, description, mdn_url }) =>
html`<li>
<a
href=${mdn_url.replace(
"/docs",
`/${context.locale}/docs`,
)}
title=${description}
>${name}</a
>
</li>`,
)}
</ul>`
: nothing}`
? removalDate
? html`<p>
${context.l10n`This feature is pending removal from browsers. Using it now may lead to broken functionality in future updates.`}
${unsafeHTML(
status.feature.discouraged?.reason_html || nothing,

Check failure on line 255 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Property 'reason_html' does not exist on type 'Discouraged'.
)}
${renderAlternatives(
context.l10n`Use the following features instead:`,
status.alternatives,

Check failure on line 259 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Property 'alternatives' does not exist on type 'Baseline'.
)}
</p>`
: html`<p>
${context.l10n`Avoid using this feature in new projects.`}
${unsafeHTML(
status.feature.discouraged?.reason_html || nothing,

Check failure on line 265 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Property 'reason_html' does not exist on type 'Discouraged'.
)}
${context.l10n`This feature may be a candidate for removal from web standards or browsers.`}
</p>
${renderAlternatives(
context.l10n`Consider using the following features instead:`,
status.alternatives,

Check failure on line 271 in components/baseline-indicator/server.js

View workflow job for this annotation

GitHub Actions / lint

Property 'alternatives' does not exist on type 'Baseline'.
)}`
: html`<p>${context.l10n("baseline-not-extra")}</p>`}
<ul>
<li>
Expand Down
Loading