1
1
mirror of https://github.com/primer/css.git synced 2024-12-25 15:14:59 +03:00
css/docs/content/tools/deprecations.md
Jon Rohan be518b8023
Updating deprecations.js file to be more straightforward (#1581)
* Updating deprecations.js file to be more straightforward

* Create poor-coins-fix.md

* Remove tests

* Adding more info about the deprecation to the doc

* Title section

* Moving data to deprecations.json

* Moving data to deprecations.json

* Lint only scss files
2021-09-10 10:54:26 -07:00

1.8 KiB

title
Deprecation data

As of version 12.7.0, we publish CSS selector and SCSS variable deprecation data (as of 14.0.0) with @primer/css. You can access the data via the Node API or as JSON.

To deprecate a class, variable, or mixin, add the element to the deprecations.js file with it's replacement value.

The replacement can be:

  • A String for a direct replacement.
  • An Array for multiple replacement options.
  • null to indicate there is no replacement.

This could look something like this:

const deprecations = {
  "deprecated-1": "replacement",
  "deprecated-2": ["replacement-1", "replacement-2"],
  "deprecated-3": null
}

JSON

The JSON data is available in the unpacked node module's dist/deprecations.json, and is an object with the following structure:

{
  "selectors" {...},
  "variables": {...},
  "mixins": {...}
}
  • selectors is an object mapping CSS selectors to their replacements. If the replacement is an Array, then there's multiple options. If the replacement is null then there are no replacements.

    {
      "selectors": {
        "deprecated-class": "replacement-class"
      }
    }
    
  • variables is an object mapping SCSS variables to their replacement SCSS variable.

    {
      "variables": {
        "$deprecated-variable": "$replacement-variable"
      }
    }
    
  • mixins is an object mapping SCSS mixins to their replacement SCSS mixins.

    {
      "mixins": {
        "deprecated-mixin": "replacement-mixin"
      }
    }
    

Node

The Node API for selector deprecations is available at @primer/css/deprecations.

Example:

const {
  deprecatedSelectors,
  deprecatedSassVariables,
  deprecatedSassMixins
} = require('@primer/css/deprecations')