1
1
mirror of https://github.com/primer/css.git synced 2024-12-25 23:23:47 +03:00
css/docs/content/tools/deprecations.md

83 lines
1.8 KiB
Markdown
Raw Normal View History

2019-09-05 22:20:46 +03:00
---
title: Deprecation data
---
2019-09-05 21:55:25 +03:00
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](#node) or as [JSON](#json).
2019-09-05 21:55:25 +03:00
To deprecate a class, variable, or mixin, add the element to the [deprecations.js](https://github.com/primer/css/blob/main/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:
```js
const deprecations = {
"deprecated-1": "replacement",
"deprecated-2": ["replacement-1", "replacement-2"],
"deprecated-3": null
}
```
2019-09-05 21:55:25 +03:00
2019-09-05 22:20:46 +03:00
## JSON
2019-09-05 21:55:25 +03:00
The JSON data is available in the unpacked node module's `dist/deprecations.json`, and is an object with the following structure:
```json
{
"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.
2019-09-05 21:55:25 +03:00
```json
{
"selectors": {
"deprecated-class": "replacement-class"
2019-09-05 21:55:25 +03:00
}
}
```
* `variables` is an object mapping SCSS variables to their replacement SCSS variable.
2019-09-05 21:55:25 +03:00
```json
{
"variables": {
"$deprecated-variable": "$replacement-variable"
2019-09-05 21:55:25 +03:00
}
}
```
* `mixins` is an object mapping SCSS mixins to their replacement SCSS mixins.
```json
{
"mixins": {
"deprecated-mixin": "replacement-mixin"
}
}
```
2019-09-05 21:55:25 +03:00
2019-09-05 22:20:46 +03:00
## Node
2019-09-05 21:55:25 +03:00
The Node API for selector deprecations is available at
`@primer/css/deprecations`.
### Example:
2019-09-05 21:55:25 +03:00
```js
const {
deprecatedSelectors,
deprecatedSassVariables,
deprecatedSassMixins
} = require('@primer/css/deprecations')
```