diff --git a/README.md b/README.md index aef44bd..351bcc2 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ If you use custom naming in your CSS architecture, you can add the `.scss` files 1. [Download the `scss/` folder contents](https://github.com/una/CSSgram/tree/master/source/scss) * 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`) in your element. +* Extend the placeholder selector (e.g. `@extend %aden` or using mixins `@include aden()`) in your element. For example: @@ -92,12 +92,28 @@ For example: } ``` +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, you can just download and link any individual `.scss` file in your Sass manifest (i.e. `scss/aden.scss`), if you're just using one of the styles. ### Available Placeholders _For use in Sass stylesheets:_ +**Extends** + * Aden: `@extend %aden` * Reyes: `@extend %reyes` * Perpetua: `@extend %perpetua` @@ -117,6 +133,27 @@ _For use in Sass stylesheets:_ * Clarendon: `@extend %clarendon` * Willow: `@extend %willow` +**Mixins** (You can add more CSS3 filters as arguments) + +* Aden: `@include aden()` +* Reyes: `@include reyes()` +* Perpetua: `@include perpetua()` +* Inkwell: `@include inkwell()` +* Toaster: `@include toaster()` +* Walden: `@include walden()` +* Hudson: `@include hudson()` +* Gingham: `@include gingham()` +* Mayfair: `@include mayfair()` +* Lo-fi: `@include lofi()` +* X-Pro II: `@include xpro2()` +* 1977: `@include _1977()` +* Brooklyn: `@include brooklyn()` +* Nashville: `@include nashville()` +* Lark: `@include lark()` +* Moon: `@include moon()` +* Clarendon: `@include clarendon()` +* Willow: `@include willow()` + ## Contributing Either: @@ -165,4 +202,4 @@ Filters are really fun to create! Reference photos created by [Miles Croxford](h - `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're creating in `site/filters.json`. -Note: this will also have mixin options and a PostCSS Component. \ No newline at end of file +Note: this will also have mixin options and a PostCSS Component. diff --git a/site/index.html b/site/index.html index 7035843..49f8cb6 100644 --- a/site/index.html +++ b/site/index.html @@ -1,26 +1,390 @@ - + CSSGram - + + + + +
+ +

A tiny (<1kb gzipped!) library for recreating Instagram filters with CSS filters and blend modes.

+
+ +
+
+
+ Choose a sample image: + atx image + bike image + cacti image + lakegeneva image + tahoe image +
+ +
+ + Hovering over any of these images (or clicking on mobile) will remove the filter effect to visualize the changes. +
+ +
+ +
+

What is This?

+ +

For more background on CSS Image Effects, you can check out my blog series here, or watch my video from CSS Conf EU, which gives a baseline on blend modes and filters.

+ +

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

+ +

We are 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 content-block 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. This features are supported in the following browsers:

+ + + +

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.

+ +

The quickest way to do this is to link to our CDN in your <head> tag: <link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">. Then, add a class to your figure element + with the name of the filter you would like to use (shown below)

+ +

If you want to work locally, do the following:

+ +
    +
  1. Download the CSSgram Library
  2. +
  3. Link to the CSSgram library within your project: +
    <link rel="stylesheet" href="css/vendor/cssgram.min.css">
  4. +
  5. Add a class to your figure element with the name of the filter you would like to use
  6. +
+ +

For example:

+ +

+      <!-- HTML -->
+      <figure class="aden">
+        <img src="../img.png">
+      </figure>
+    
+ + Alternatively, you can just download and link to any individual css file:
<link rel="stylesheet" href="css/vendor/aden.min.css">, if you're just using one of the styles.
+ +

Available Classes

+ For use in HTML markup: + + +
+ +

Use Sass @extends

+ +

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
  2. +
  3. 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';
  4. +
  5. Extend the silent placeholder selector @extend %aden; (or using mixins @include aden();) in your element.
  6. +
+ +

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, you can just download and link any individual .scss file in your Sass manifest:
(i.e. scss/aden.scss), if you're just using one of the styles.
+ +

Available Extends

+ For use in Sass elements: + +
+
+ + + + -
+

A tiny (<1kb gzipped!) library for recreating Instagram filters with CSS filters and blend modes.

@@ -29,12 +393,12 @@

A tiny (<1kb gzipped!) library for recreating
Choose a sample image: - atx image - bike image - cacti image - lakegeneva image - tahoe image -
+ atx image + bike image + cacti image + lakegeneva image + tahoe image +

A tiny (<1kb gzipped!) library for recreating #nofilter -
  • -
    - -
    1977
    -
    -
  • -
  • -
    - -
    Aden
    -
    -
  • -
  • -
    - -
    Brooklyn
    -
    -
  • -
  • -
    - -
    Clarendon
    -
    -
  • -
  • -
    - -
    Earlybird
    -
    -
  • -
  • -
    - -
    Gingham
    -
    -
  • -
  • -
    - -
    Hudson
    -
    -
  • -
  • -
    - -
    Inkwell
    -
    -
  • -
  • -
    - -
    Lark
    -
    -
  • -
  • -
    - -
    Lo-Fi
    -
    -
  • -
  • -
    - -
    Mayfair
    -
    -
  • -
  • -
    - -
    Moon
    -
    -
  • -
  • -
    - -
    Nashville
    -
    -
  • -
  • -
    - -
    Perpetua
    -
    -
  • -
  • -
    - -
    Reyes
    -
    -
  • -
  • -
    - -
    Rise
    -
    -
  • -
  • -
    - -
    Slumber
    -
    -
  • -
  • -
    - -
    Toaster
    -
    -
  • -
  • -
    - -
    Walden
    -
    -
  • -
  • -
    - -
    Willow
    -
    -
  • -
  • -
    - -
    X-pro II
    -
    -
  • - +
  • +
    + +
    1977
    +
    +
  • +
  • +
    + +
    Aden
    +
    +
  • +
  • +
    + +
    Brooklyn
    +
    +
  • +
  • +
    + +
    Clarendon
    +
    +
  • +
  • +
    + +
    Earlybird
    +
    +
  • +
  • +
    + +
    Gingham
    +
    +
  • +
  • +
    + +
    Hudson
    +
    +
  • +
  • +
    + +
    Inkwell
    +
    +
  • +
  • +
    + +
    Lark
    +
    +
  • +
  • +
    + +
    Lo-Fi
    +
    +
  • +
  • +
    + +
    Mayfair
    +
    +
  • +
  • +
    + +
    Moon
    +
    +
  • +
  • +
    + +
    Nashville
    +
    +
  • +
  • +
    + +
    Perpetua
    +
    +
  • +
  • +
    + +
    Reyes
    +
    +
  • +
  • +
    + +
    Rise
    +
    +
  • +
  • +
    + +
    Slumber
    +
    +
  • +
  • +
    + +
    Toaster
    +
    +
  • +
  • +
    + +
    Walden
    +
    +
  • +
  • +
    + +
    Willow
    +
    +
  • +
  • +
    + +
    X-pro II
    +
    +
  • +

    @@ -184,9 +548,11 @@

    What is This?

    For more background on CSS Image Effects, you can check out my blog series here, or watch my video from CSS Conf EU, which gives a baseline on blend modes and filters.

    -

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

    +

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

    -

    We are 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 content-block like <img>. The recommendation is to wrap your images in a <figure> tag. More about the tag here.

    +

    We are 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 content-block like <img>. The recommendation is to + wrap your images in a <figure> tag. More about the tag here.

    Browser Support

    @@ -201,7 +567,7 @@

    Browser Support

    For more information, check on Can I Use.

    -
    +
    @@ -213,13 +579,15 @@

    Use CSS classes

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

    -

    The quickest way to do this is to link to our CDN in your <head> tag: <link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">. Then, add a class to your figure element with the name of the filter you would like to use (shown below)

    +

    The quickest way to do this is to link to our CDN in your <head> tag: <link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">. Then, add a class to your figure element + with the name of the filter you would like to use (shown below)

    If you want to work locally, do the following:

    1. Download the CSSgram Library
    2. -
    3. Link to the CSSgram library within your project:
      <link rel="stylesheet" href="css/vendor/cssgram.min.css">
    4. +
    5. Link to the CSSgram library within your project: +
      <link rel="stylesheet" href="css/vendor/cssgram.min.css">
    6. Add a class to your figure element with the name of the filter you would like to use
    @@ -237,39 +605,40 @@

    Use CSS classes

    Available Classes

    For use in HTML markup: +
  • 1977: class="_1977"
  • +
  • Aden: class="aden"
  • +
  • Brooklyn: class="brooklyn"
  • +
  • Clarendon: class="clarendon"
  • +
  • Earlybird: class="earlybird"
  • +
  • Gingham: class="gingham"
  • +
  • Hudson: class="hudson"
  • +
  • Inkwell: class="inkwell"
  • +
  • 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"
  • +
  • Toaster: class="toaster"
  • +
  • Walden: class="walden"
  • +
  • Willow: class="willow"
  • +
  • X-pro II: class="xpro2"
  • +

    Use Sass @extends

    -

    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 😊.

    +

    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
    2. 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';
    3. -
    4. Extend the silent placeholder selector @extend %aden; in your element.
    5. +
    6. Extend the silent placeholder selector @extend %aden; (or using mixins @include aden();) in your element.

    For example:

    @@ -288,43 +657,91 @@

    Use Sass @extends

    } + 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, you can just download and link any individual .scss file in your Sass manifest:
    (i.e. scss/aden.scss), if you're just using one of the styles.

    Available Extends

    For use in Sass elements: -
    +
  • 1977: @extend %_1977;
  • +
  • Aden: @extend %aden;
  • +
  • Brooklyn: @extend %brooklyn;
  • +
  • Clarendon: @extend %clarendon;
  • +
  • Earlybird: @extend %earlybird;
  • +
  • Gingham: @extend %gingham;
  • +
  • Hudson: @extend %hudson;
  • +
  • Inkwell: @extend %inkwell;
  • +
  • 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;
  • +
  • Toaster: @extend %toaster;
  • +
  • Walden: @extend %walden;
  • +
  • Willow: @extend %willow;
  • +
  • X-pro II: @extend %xpro2;
  • + + +

    Available Mixins

    + + + For use in Sass elements: +
    + (You can add more CSS3 filters as arguments) +
    + + +
    + - - \ No newline at end of file + + } + document.addEventListener("click", function(event) { + if (/demo__option-img/.test(event.target.className)) pickSample(event.target) + }, false) + inputField.addEventListener("input", function() { + updateImages(this.value) + }, false) + inputField.addEventListener("focus", function() { + this.select() + }, false) + pickSample(document.querySelector(".demo__option-img")) + + + +