Skip to content

Instantly share code, notes, and snippets.

@eduardoboucas
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save eduardoboucas/435348b29b688445263d to your computer and use it in GitHub Desktop.

Select an option

Save eduardoboucas/435348b29b688445263d to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// Include Media (v1.3.0)
// ----
@import "include-media";
@function getBreakpoints($targetName) {
$json: '{';
$targetValue: map-get($breakpoints, $targetName);
@each $name, $value in $breakpoints {
@if $json != '{' {
$json: $json + ', ';
}
$state: if($targetValue >= $value, true, false);
$json: $json + '"#{$name}": #{$state}';
}
$json: $json + '}';
@return $json;
}
@mixin exportBreakpoints() {
@each $name, $value in $breakpoints {
@include media('>=#{$name}') {
body {
content: getBreakpoints($name);
}
}
}
}
@include exportBreakpoints();
/*
function isBreakpointActive(breakpoint) {
var breakpoints = readBreakpoints();
return breakpoints[breakpoint];
}
function readBreakpoints() {
var breakpoints = window.getComputedStyle(document.body).content.replace(/'/g, '');
return JSON.parse(breakpoints);
}
*/
@media (min-width: 320px) {
body {
content: '{"phone": true, "tablet": false, "desktop": false}';
}
}
@media (min-width: 768px) {
body {
content: '{"phone": true, "tablet": true, "desktop": false}';
}
}
@media (min-width: 1024px) {
body {
content: '{"phone": true, "tablet": true, "desktop": true}';
}
}
/*
function isBreakpointActive(breakpoint) {
var breakpoints = readBreakpoints();
return breakpoints[breakpoint];
}
function readBreakpoints() {
var breakpoints = window.getComputedStyle(document.body).content.replace(/'/g, '');
return JSON.parse(breakpoints);
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment