Giter Site home page Giter Site logo

derianandre / sass-color-system Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 19 KB

A simple color system made with Sass using CSS variables

License: GNU General Public License v3.0

HTML 17.18% SCSS 82.82%
sass scss color color-system css css3 css3-variables

sass-color-system's Introduction

Sass-Color-System

A simple color system made with Sass using CSS variables Using HSLA and variables you can achieve a simple effective color system that can be more complex to your needs.

  $color: hsl(0, 50%, 50%);
  --color-alpha: 1;
  --color-h:  #{color.hue($color)};
  --color-s:  #{color.saturation($color)};
  --color-l:  #{color.lightness($color)};
  --color-hsl: 
    hsl(
      var(--color-hue,        var(--#{$name}-h)),
      var(--color-saturation, var(--#{$name}-s)),
      var(--color-lightness,  var(--#{$name}-l))
    );
  --color-hsla: 
    hsla(
      var(--color-hue,        var(--#{$name}-h)),
      var(--color-saturation, var(--#{$name}-s)),
      var(--color-lightness,  var(--#{$name}-l)),
      var(--color-alpha,      var(--alpha-color))
    );

Using sass:color we can convert any color into hsl, with that we can separate into css variables and we can modify them to our needs.

If we want to make it slightly more transparent then we only need to change a variable instead of rewrting a property:

  .div {
    background-color: hsla(0, 50%, 50%, 1);
  }
  .div:hover {
    background-color: hsla(0, 80%, 40%, 0.5);
  }

With my color system:

  .better-div {
    backgorund-color: var(--color-hsla);
  }
  .better-div:hover {
    --color-saturation: 80%;
    --color-lightness : 40%;
    --color-alpha     : 0.50;
  }

The best thing is that we can do this for hue, saturation, lightness and alpha values to every single color.

With this aproach we can save really a lot of time and rewrites (long term). This aproach seems like more coding, this is probably not the best way when you are writing a simple web/app but for a larger system this can be really helpful. Also if you use a post-processor code can have a smaller foot-print.

sass-color-system's People

Contributors

derianandre avatar

Watchers

 avatar

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.