mdn / mdn/fred

Replace light-dark @mixin with native light-dark image support

Open
#1,865 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
233
Forks
61
Avg merge
1d 1h
Merged PRs (30d)
82

Description

light-dark() supports images now - which is the only thing we're using postcss-mixins for.

We should therefore be able to replace our uses of @mixin light-dark with native light-dark(), and remove the postcss plugin, and stylelint overrides (e.g. https://github.com/mdn/fred/pull/1861)

However, currently the postcss-light-dark plugin adds a @supports (color: light-dark(red, red)) block which would expose light-dark(<image>, <image>) on browsers which don't support it.

Setting preserve: false on this plugin will allow us to make the switch now, until postcss-light-dark detects image support and uses an appropriate @support block.

We also need to force the postcss-light-dark plugin on, until upstream supports light-dark(<image>, <image>), otherwise it'll stop transpiling once light-dark(<colour>, <colour>) is Widely Available (and we drop support for Firefox 115).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the @mixin light-dark uses, the postcss-mixins and postcss-light-dark configuration, and the stylelint overrides referenced in the issue. Check the existing CSS build and lint checks first. Done means native light-dark() handles images, postcss-mixins and unnecessary overrides are removed, and postcss-light-dark uses preserve: false and remains forced on for image support.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
build-system, frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.