Giter VIP home page Giter VIP logo

cssgram's Introduction

CSSgram

CDNJS

CSSGram is an Instagram filter library written in Sass and CSS.

What is This?

Simply put, CSSgram is a library for editing your images with Instagram-like filters directly using CSS. What we're doing is adding filters to the images, as well as applying color and/or gradient overlays via various blending techniques to mimic filter effects. This means less manual image processing and more fun filter effects on the web!

We're using pseudo-elements (i.e. ::before and ::after) to create the filter effects, so you must apply these filters on a containing element (i.e. not a replaced element like <img>). The recommendation is to wrap your images in a <figure> tag. More about the tag here.

Browser Support

This library uses CSS Filters and CSS Blend Modes. These features are supported in the following browsers:

Chrome logo Firefox logo Internet Explorer logo Edge logo Opera logo Safari logo
43+ ✔ 38+ ✔ Nope ✘ 13 ✔ 32+ ✔ 8+ ✔

For more information, check on Can I Use.

Usage

There are currently 2 ways to consume this library:

Use CSS classes

When using CSS classes, you can simply add the class with the filter name to the element containing your image.

  1. Include the CDN link in your <head> tag: <link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">. We're also on CDNJS which means another option is <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cssgram/0.1.10/cssgram.min.css">
  • Alternatively, you can download the CSSgram library locally and link to the it within your project: <link rel="stylesheet" href="css/vendor/cssgram.min.css">
  • Add a class to your image element with the name of the filter you would like to use

For example:

<!-- HTML -->
<figure class="aden">
  <img src="../img.png">
</figure>

Alternatively, you can just download and link to any individual css file (e.g. <link rel="stylesheet" href="css/vendor/aden.min.css">) if you're using only one of the styles.

Available Classes

For use in HTML markup:

  • 1977: class="_1977"
  • Aden: class="aden"
  • Amaro: class="amaro"
  • Brannan: class="brannan"
  • Brooklyn: class="brooklyn"
  • Clarendon: class="clarendon"
  • Gingham: class="gingham"
  • Hudson: class="hudson"
  • Inkwell: class="inkwell"
  • Kelvin: class="kelvin"
  • Lark: class="lark"
  • Lo-fi: class="lofi"
  • Mayfair: class="mayfair"
  • Moon: class="moon"
  • Nashville: class="nashville"
  • Perpetua: class="perpetua"
  • Reyes: class="reyes"
  • Rise: class="rise"
  • Slumber: class="slumber"
  • Stinson: class="stinson"
  • Toaster: class="toaster"
  • Valencia: class="valencia"
  • Walden: class="walden"
  • Willow: class="willow"
  • X-Pro-2: class="xpro2"

Use Sass @extend or @mixin

If you use custom naming in your CSS architecture, you can add the .scss files for the provided styles within your project and then @extend the filter effects within your style definitions. If you think extends are stupid, I will fight you 😊.

  1. Download the scss/ folder contents
  • Include a link to scss/cssgram.scss via an @import statement in your Sass manifest file (i.e. main.scss). It may look like: @import 'vendor/cssgram'
  • Extend the placeholder selector (e.g. @extend %aden or using mixins @include aden()) in your element.

For example:

<!-- HTML -->
<figure class="viz--beautiful">
  <img src="../img.png">
</figure>
// Sass
.viz--beautiful {
  @extend %aden;
}

or using mixins (more flexible)

// Sass (without adding new CSS3 filters)
.viz--beautiful {
  @include aden();
}

// Sass (adding new CSS3 filters)
.viz--beautiful {
  @include aden(blur(2px) /*...*/);
}

Alternatively, if you're using only one of the styles, you can download and link any individual .scss file in your Sass manifest (i.e. scss/aden.scss).

Available Placeholders

For use in Sass stylesheets:

Extends

  • 1977: @extend %_1977
  • Aden: @extend %aden
  • Amaro: @extend %amaro
  • Brannan: @extend %brannan
  • Brooklyn: @extend %brooklyn
  • Clarendon: @extend %clarendon
  • Gingham: @extend %gingham
  • Hudson: @extend %hudson
  • Inkwell: @extend %inkwell
  • Kelvin: @extend %kelvin
  • Lark: @extend %lark
  • Lo-fi: @extend %lofi
  • Mayfair: @extend %mayfair
  • Moon: @extend %moon
  • Nashville: @extend %nashville
  • Perpetua: @extend %perpetua
  • Reyes: @extend %reyes
  • Rise: @extend %rise
  • Slumber: @extend %slumber
  • Stinson: @extend %stinson
  • Toaster: @extend %toaster
  • Valencia: @extend %valencia
  • Walden: @extend %walden
  • Willow: @extend %willow
  • X-Pro-2: @extend %xpro2

Mixins (You can add more CSS3 filters as arguments)

  • 1977: @include _1977()
  • Aden: @include aden()
  • Amaro: @include amaro()
  • Brannan: @include brannan()
  • Brooklyn: @include brooklyn()
  • Clarendon: @include clarendon()
  • Gingham: @include gingham()
  • Hudson: @include hudson()
  • Inkwell: @include inkwell()
  • Kelvin: @include kelvin()
  • Lark: @include lark()
  • Lo-fi: @include lofi()
  • Mayfair: @include mayfair()
  • Moon: @include moon()
  • Nashville: @include nashville()
  • Perpetua: @include perpetua()
  • Reyes: @include reyes()
  • Rise: @include rise()
  • Slumber: @include slumber()
  • Stinson: @include stinson()
  • Toaster: @include toaster()
  • Valencia: @include valencia()
  • Walden: @include walden()
  • Willow: @include willow()
  • X-Pro-2: @include xpro2()

Contributing

Either:

  1. Create an issue

Or:

  1. Fork this repository
  2. Clone the fork onto your system
  3. npm install dependencies (must have Node installed)
  4. Run gulp to compile CSS and the test site
  5. Make changes and check the test site with your changes (see file structure outline below)
  6. Submit a PR referencing the issue with a smile 😄

Filters are really fun to create! Reference photos created by Miles Croxford can be found here.

File Structure Outline

  • source/css/cssgram.css contains each of the CSS classes you can apply to your <img> to give it the filter. You should use source/css/cssgram.min.css for production if you want access to all of the library
  • source/scss/ contains the source files for individual classes and placeholder selectors you can use to extend CSS classes in Sass
  • site/ is the public facing website
  • site/test is how you test filters if you're developing, remember to change is_done for the filter you are creating in site/filters.json.

Note: This will also have mixin options and a PostCSS Component.

cssgram's People

Contributors

bennettfeely avatar bobeta avatar bunomonteiro avatar fernahh avatar giraugh avatar greenturtwig avatar jackpu avatar jkeener avatar kittygiraudel avatar lshun avatar m1 avatar martinbjeldbak avatar matsieftw avatar mislav avatar navjotahuja92 avatar peterdavehello avatar praseetha-kr avatar prayagverma avatar raphaklaus avatar semicolonexpected avatar spencerking avatar theknarf avatar tombyrer avatar tylercrumpton avatar una avatar wbinnssmith avatar wesleycsj avatar yuxiangdai avatar z11h 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  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

cssgram's Issues

Prefix class names with `filter-`?

Advantages:

  • prevents an onboarding devs say "What the ___ is 'hudson'?"
  • allows global search/replace/delete

Disadvantages:

  • larger files (mostly negated by gzip)
  • more typing (reduced by editors' autocomplete, copy/paste|search/replace
  • add extra coding to gulpfile

Could prefix with cssgram- also, less clear, but helps in finding this repo.

Single Source of Truth for Site & Test Page

Currently both use their own filters list:

test page:

  {% set filters = [
    {name: 'aden',       is_done: true},
    {name: 'amaro',      is_done: false},
    {name: 'brannan',    is_done: false},
    {name: 'crema',      is_done: false},
    {name: 'earlybird',  is_done: true},
    {name: 'hefe',       is_done: false},
    {name: 'hudson',     is_done: true},
    {name: 'inkwell',    is_done: true},
    {name: 'juno',       is_done: false},
    {name: 'lark',       is_done: true},
    {name: 'lofi',       is_done: true},
    {name: 'ludwig',     is_done: false},
    {name: 'mayfair',    is_done: true},
    {name: 'nashville',  is_done: true},
    {name: 'perpetua',   is_done: true},
    {name: 'reyes',      is_done: true},
    {name: 'rise',       is_done: false},
    {name: 'sierra',     is_done: false},
    {name: 'slumber',    is_done: false},
    {name: 'valencia',   is_done: false},
    {name: 'willow',     is_done: false},
    {name: 'xpro2',      is_done: true},
  ] %}

demo site:

  {% set filters = [
    {name: 'Aden',       usage: 'aden'},
    {name: 'Reyes',      usage: 'reyes'},
    {name: 'Perpetua',   usage: 'perpetua'},
    {name: 'Inkwell',    usage: 'inkwell'},
    {name: 'Earlybird',  usage: 'earlybird'},
    {name: 'Toaster',    usage: 'toaster'},
    {name: 'Walden',     usage: 'walden'},
    {name: 'Hudson',     usage: 'hudson'},
    {name: 'Gingham',    usage: 'gingham'},
    {name: 'Mayfair',    usage: 'mayfair'},
    {name: 'Lo-Fi',      usage: 'lofi'},
    {name: 'X-Pro2 II',  usage: 'xpro2'},
    {name: '1977',       usage: '_1977'},
    {name: 'Brooklyn',   usage: 'brooklyn'},
    {name: 'Nashville',  usage: 'nashville'},
    {name: 'Lark',       usage: 'lark'},
  ] %}

These could likely be combined:

  {% set filters = [
     {name: 'Aden',      is_done: true,      usage: 'aden'},
     {name: 'Amaro',     is_done: false,     usage:'tbd'},
  ] %}

And only the finished filters would show up with usage on the demo site. That being said, we need parity with all of the test files and existing filters that exist first See #96

code repetition

There is a repetition of the code in the CSS file because "shared" is imported all SCSS files

`shared.scss` double import.

Hi,

I'm not sure this is an issue, you may have your reasons to do it.

In cssgram.scss we import shared.scss but we also do it in every filter .scss.

Is there a reason to do that? The resulting CSS is double the size. If there's a reason to it, we may need a small settings.scssfile to choose filters, different variables, or even if we want to create the class or live happyly ever after only with extend.

Give Image Example Options

These should be clickable (i.e. click to change it to the cactus example, etc.) or allow people to insert their own images

Code Syntax Styling

Needs some work -- give it a background so it stands out from the white text behind it

Copy Editing

Make sure that the usage of this library is clear

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.