Giter Site home page Giter Site logo

larsenwork / postcss-easing-gradients Goto Github PK

View Code? Open in Web Editor NEW
916.0 11.0 22.0 1.18 MB

PostCSS plugin to create smooth linear-gradients that approximate easing functions.

Home Page: https://www.npmjs.com/package/postcss-easing-gradients

License: MIT License

JavaScript 100.00%
postcss-plugin postcss css gradients

postcss-easing-gradients's People

Contributors

larsenwork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postcss-easing-gradients's Issues

Issues with CSS variables

Hi there,

Great plugin, but it doesn't seem to work with CSS variables.

// Works
background: linear-gradient(to right, green, ease, red);

// Fails
:root {
--red: red;
--green: green;
}

background: linear-gradient(to right, var(--green), ease, var(--red));

Option to start or stop at different locations

Sometimes I need to start a gradient at a point past 0% or stop it before 100%. Would it be possible to add support for this?

For example, a gradient such as:

linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.5) 25%, rgba(0, 0, 0, 0) 100%)

Not working with postcss-js?

It seems easing-gradients isn't working with postcss-js:

import postcssJs from 'postcss-js'
import rtlcss from 'rtlcss'
import gradients from 'postcss-easing-gradients'

const process = postcssJs.sync([ rtlcss, gradients ])

const css = {
  left: '5px',
  background: 'linear-gradient(to bottom, black, cubic-bezier(0.48, 0.3, 0.64, 1), transparent)'
}

console.log(process(css))
/*
{
  right: "5px",
  background: "linear-gradient(to bottom, black, cubic-bezier(0.48, 0.3, 0.64, 1), transparent)"
}
*/

As you can see it's not webpack or postcss-js issue, because rtlcss works fine.

Compatibility with PostCSS 8

Thanks for your PostCSS plugin!

As you probably know, PostCSS 8 was released a few days ago. It would be great if you could make this plugin compatible with the latest version. The creators of the project have even released this migration guide.

Work with postcss-easings

Just tried to install both these packages:

Added both to .postcssrc.js:

module.exports = {
    plugins: ['postcss-easing-gradients', 'postcss-easings']
};

But this code is not processed:

background-image: linear-gradient(to right, black, ease-in-sine, transparent);

I tried to change order of plugins but it's not working too.

BUG: Multiple backgrounds fails with wrong generated syntax of 1st

$bg-color: #181818;

$gradient-primary-raw: linear-gradient(
  0deg,
  $color-primary,
  $color-primary2
);

background-image: linear-gradient(to right, $bg-color, $bg-color), $gradient-primary-raw;

generate this
background-image: linear-gradient(0deg; #181818; #181818), ...correct second gradient here...

Expected code
background-image: linear-gradient(0deg, #181818, #181818), ...correct second gradient here...

How to fix that? I mean, what plugin replace , with ; ???
That occurs only if I use variable with prepared gradient inside background-image that have multiple backgrounds.

Make a PR to the CSS Images specification

Related to w3c/csswg-drafts#1332, might I recommend making a PR or reaching out to the community to help you write a PR to add easing to the color stop syntax?

Here is the section that would need updating:
https://drafts.csswg.org/css-images-4/#color-stop-syntax

And here is the source bikeshed file that would be updated:
https://github.com/w3c/csswg-drafts/blob/master/css-images-4/Overview.bs#L1131-L1139


If this were added to the official spec, I would love to include this plugin in PostCSS Preset Env.

color stop positions

I'm not used to how PostCSS works under the hood so this might be a silly question.

Is it possible this plugin could support a subset of the positional arguments for color stops eg:

linear-gradient(
  to top,
  black 0%,
  ease-in-out,
  transparent 15%,
  linear,
  transparent 100%
);

I understand that this probably not possible to polyfill the entire set of positional arguments (calc, mixing %/px etc.) but surely just linearly interpolating between percentages should be possible given the output css uses percentages?

I came across this limitation while using mask-image with the linear gradient as a fade-out on the bottom of an image. This problem would usually be easily alleviated with background-size but, unfortunately, mask-image-size works differently such in such a way that anywhere not covered by mask-image is masked out. So the image fades nicely then just becomes transparent for the most part.

confused about docs

Hi, thank you for your code. I'm a bit confused by your docs and demos, though.

  • In demo I find a 'precision' option passed to this plugin. This is not mentioned in your docs.
    .pipe(
      gulpPostcss([
        easingGradient({
          // Default settings
          precision: 0.1,
          alphaDecimals: 5,
        }),
      ])
  • In demo pcss I found:

background: linear-gradient(to right, green, steps(4, skip-none), red);

What's steps? it's not standard css syntax, If I'm not wrong..

Could you please exaplain and/or update your docs and demos?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.