Giter VIP home page Giter VIP logo

sass-extras's Introduction

Sass::Extras

Build Status

A collection of miscellaneous SASS extensions. Mostly concerned with colour manipulation.

Installation

Add this line to your application's Gemfile:

gem 'sass-extras'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sass-extras

Usage

Just require this gem in your project, and it will extend the Sass::Script::Functions module with a selection of functions that will be available in your .sass or .scss files.

Notice: All examples are in SCSS syntax.

Contrast Color

Will adjust a colour so that it conforms to the WAI and WCAG 2.0 & 2.1 recommendations for minimum contrast for text.

span {
  color: contrast-color($text-color, $background-color);
}

Inline Image with a Colour

Generate a data URL for an image of a given colour. Useful for e.g. backgrounds with an alpha channel in browsers that does not support rgba.

a {
  background: url(inline-color-image(rgba(102, 54, 32, 0.5)));
}

SVG gradients

Generate data URI for SVG images with either a linear or a radial gradient.

Optional first argument is the colour of the gradient, going from solid to total transparent for the linear and 20% opacity for the radial gradient.

Optional second argument is the height of the generated image.

.scrollbox {
  background-image: radial-gradient-image-data-url(black);
  &:before {
    background-image: linear-gradient-image-data-url(white);
  }
  /* some positioning etc. */
}

YUV color space

Offers two methods for generating colours based on the YUV space: yuv(y, u, v) and yuva(y, u, v, alpha).

a {
  background-color: yuva(10%, 0, 0, 0.5); /* #191919, 50% alpha */
}

Besides that, a couple of helper functions to adjust brightness based on the YUV colour space, is provided.

set-brightness($color, $amount);
increase-brightness($color, $amount);
reduce-brightness($color, $amount);
add-brightness($color, $amount);
detract-brightness($color, $amount);

Contributing

  1. Fork it ( http://github.com/tobiashm/sass-extras/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

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.