Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonaskuske/postcss-smoothscroll-anchor-polyfill

⚙ Transform CSS for use with smoothscroll-anchor-polyfill
https://github.com/jonaskuske/postcss-smoothscroll-anchor-polyfill

anchor postcss postcss-plugin scroll smooth-scroll smooth-scrolling smoothscroll smoothscroll-anchor-polyfill

Last synced: 24 days ago
JSON representation

⚙ Transform CSS for use with smoothscroll-anchor-polyfill

Awesome Lists containing this project

README

        


NPM version
Build status
License

 
 

postcss-smoothscroll-anchor-polyfill


PostCSS plugin that updates the standard scroll-behavior property to work with smoothscroll-anchor-polyfill

 
 

```css
html {
scroll-behavior: smooth;
}
```

compiles to:

```css
html {
font-family: "scroll-behavior:smooth";
scroll-behavior: smooth;
}
```

or if all browsers in your [browserslist](https://github.com/browserslist/browserslist) support [CSS Custom Properties](https://caniuse.com/#feat=css-variables):

```css
html {
--scroll-behavior: smooth;
scroll-behavior: smooth;
}
```

 

## Existing `font` and `font-family`

Existing `font` and `font-family` declarations are kept and [smoothscroll-anchor-polyfill](https://github.com/jonaskuske/smoothscroll-anchor-polyfill) will still work:

> 👉🏻 Even though the original font declarations are kept, using `html { }` only for `scroll-behavior` and declaring your font styles on `body { }` is prefered.

```css
html {
scroll-behavior: smooth;
font-family: "Helvetica Neue";
}

/* Compiles to: */

html {
scroll-behavior: smooth;
font-family: "scroll-behavior:smooth", "Helvetica Neue";
}
```

```css
html {
scroll-behavior: smooth;
font: strong 1em/1.4 "Helvetica Neue";
}

/* Compiles to: */

html {
scroll-behavior: smooth;
font: strong 1em/1.4 "Helvetica Neue";
font-family: "scroll-behavior:smooth", "Helvetica Neue";
}
```

 

## Installation

**npm**:

```
npm install postcss-smoothscroll-anchor-polyfill --save-dev
```

**or yarn**:

```bash
yarn add --dev postcss-smoothscroll-anchor-polyfill
```

 

## Usage

```js
postcss([ require('postcss-smoothscroll-anchor-polyfill') ])
```

See [PostCSS](https://github.com/postcss/postcss) docs for examples for your environment.

 

## Thanks to

This PostCSS plugin is based on a fork of [postcss-object-fit-images](https://github.com/ronik-design/postcss-object-fit-images), which was built by:

* [Michael Shick](https://www.github.com/mshick)
* [Federico Brigante](https://www.github.com/bfred-it)