Created
July 1, 2015 14:52
-
-
Save eduardoboucas/0f33426463aefc41ab61 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---- | |
| // libsass (v3.2.5) | |
| // ---- | |
| @import "include-media"; | |
| /// | |
| /// Generates a JSON string with each breakpoint's value and information about | |
| /// which of the breakpoints are currently active (i.e. viewport width >= breakpoint) | |
| /// | |
| /// @param {String} $target-name - Name of breakpoint to evaluate | |
| /// | |
| /// @return {String} - Resulting JSON string | |
| /// | |
| /// @example json - For a width of 900px | |
| /// '{"phone":{"value": "320px", "active": true}, "tablet":{"value": "768px", "active": true}, "desktop":{"value": "1024px", "active": false}}' | |
| /// | |
| @function im-breakpoints-to-json($target-name) { | |
| $breakpoints-json: (); | |
| $target-value: map-get($breakpoints, $target-name); | |
| @each $name, $value in $breakpoints { | |
| $breakpoint: '"#{$name}":{"value": "#{$value}", "active": #{$target-value >= $value}}'; | |
| $breakpoints-json: append($breakpoints-json, $breakpoint, 'comma'); | |
| } | |
| @return '{#{$breakpoints-json}}'; | |
| } | |
| /// | |
| /// Generates the media queries necessary to export breakpoints | |
| /// | |
| /// @param {String} $element - Element to append JSON data to | |
| /// | |
| @mixin im-export($element) { | |
| @each $name, $value in $breakpoints { | |
| @include media('>=#{$name}') { | |
| #{$element} { | |
| content: im-breakpoints-to-json($name); | |
| display: block; | |
| height: 0; | |
| overflow: hidden; | |
| width: 0; | |
| } | |
| } | |
| } | |
| } | |
| @include im-export(if(variable-exists('im-export-element'), $im-export-element + '::after', 'body::after')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @media (min-width: 320px) { | |
| body::after { | |
| content: "{\"phone':{\"value\": '320px\", \"active\": true}, \"tablet':{\"value\": '768px\", \"active\": false}, \"desktop':{\"value\": '1024px\", \"active\": false}}"; | |
| display: block; | |
| height: 0; | |
| overflow: hidden; | |
| width: 0; | |
| } | |
| } | |
| @media (min-width: 768px) { | |
| body::after { | |
| content: "{\"phone':{\"value\": '320px\", \"active\": true}, \"tablet':{\"value\": '768px\", \"active\": true}, \"desktop':{\"value\": '1024px\", \"active\": false}}"; | |
| display: block; | |
| height: 0; | |
| overflow: hidden; | |
| width: 0; | |
| } | |
| } | |
| @media (min-width: 1024px) { | |
| body::after { | |
| content: "{\"phone':{\"value\": '320px\", \"active\": true}, \"tablet':{\"value\": '768px\", \"active\": true}, \"desktop':{\"value\": '1024px\", \"active\": true}}"; | |
| display: block; | |
| height: 0; | |
| overflow: hidden; | |
| width: 0; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment