diff --git a/components/baseline-indicator/icons/status/pending-removal-dark.svg b/components/baseline-indicator/icons/status/pending-removal-dark.svg new file mode 100644 index 000000000..64d6df0dc --- /dev/null +++ b/components/baseline-indicator/icons/status/pending-removal-dark.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/components/baseline-indicator/icons/status/pending-removal.svg b/components/baseline-indicator/icons/status/pending-removal.svg new file mode 100644 index 000000000..69629e5a7 --- /dev/null +++ b/components/baseline-indicator/icons/status/pending-removal.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/components/baseline-indicator/server.css b/components/baseline-indicator/server.css index a77e28f38..d3332d8d8 100644 --- a/components/baseline-indicator/server.css +++ b/components/baseline-indicator/server.css @@ -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] { diff --git a/components/baseline-indicator/server.js b/components/baseline-indicator/server.js index 389bc5677..4cfc85754 100644 --- a/components/baseline-indicator/server.js +++ b/components/baseline-indicator/server.js @@ -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"; @@ -79,6 +80,7 @@ export class BaselineIndicator extends ServerComponent { const level = status.feature.discouraged ? "discouraged" : status.baseline || "not"; + const removalDate = status.feature.discouraged?.removal_date; const feedbackLink = `${SURVEY_URL}?page=${encodeURIComponent(context.url)}&level=${level}`; @@ -130,10 +132,35 @@ export class BaselineIndicator extends ServerComponent { } }; + const renderAlternatives = + /** + * @param {string} instruction + * @param {import("@rari").Alternative[]} [alternatives] + */ + (instruction, alternatives) => + alternatives && alternatives.length > 0 + ? html`

${instruction}

+ ` + : nothing; + const openByDefault = level === "discouraged"; return html`
${level === "low" ? html`
${context.l10n`Newly available`}
` - : nothing} + : level === "discouraged" && removalDate + ? html`
${context.l10n`To be removed`}
` + : nothing}
${ENGINES.map( ({ name, browsers }) => @@ -219,29 +248,28 @@ export class BaselineIndicator extends ServerComponent { ? html`

* ${context.l10n("baseline-asterisk")}

` : nothing}` : level === "discouraged" - ? html`

- ${context.l10n`Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.`} -

- ${status.alternatives && status.alternatives.length > 0 - ? html`

- ${context.l10n`Consider using the following features instead:`} -

- ` - : nothing}` + ? removalDate + ? html`

+ ${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, + )} + ${renderAlternatives( + context.l10n`Use the following features instead:`, + status.alternatives, + )} +

` + : html`

+ ${context.l10n`Avoid using this feature in new projects.`} + ${unsafeHTML( + status.feature.discouraged?.reason_html || nothing, + )} + ${context.l10n`This feature may be a candidate for removal from web standards or browsers.`} +

+ ${renderAlternatives( + context.l10n`Consider using the following features instead:`, + status.alternatives, + )}` : html`

${context.l10n("baseline-not-extra")}

`}