Skip to content

Instantly share code, notes, and snippets.

@Rplus
Last active April 20, 2016 13:20
Show Gist options
  • Select an option

  • Save Rplus/c8cbdaa2444e766aa0e06c6d1bb87507 to your computer and use it in GitHub Desktop.

Select an option

Save Rplus/c8cbdaa2444e766aa0e06c6d1bb87507 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
title Document
style.
.component {
background-color: #efefef;
border: 1px solid rgba(0, 0, 0, 0.1);
margin: 10px;
padding: 10px;
}
.component::before {
content: "600px +";
}
.component span {
color: deeppink;
}
@media (max-width: 600px) {
.component::before {
content: "600px-";
}
}
@media (max-width: 400px) {
.component::before {
content: "400px-";
}
}
body
mixin component($width)
- $width = $width || '600+'
.component
p
| This is a #[span component]. Under 400px, this component will prefix by #{$width}.
+component()
.iframify(data-width='600px')
+component(600)
.iframify(data-width='400px')
+component(400)
script(src="js.js")
/* global location */
(function () {
var iframify = document.querySelectorAll('.iframify');
if (!iframify.length) {
return;
}
if (!location.hash) {
window.iframifyResize = (iframe) => {
iframe.height = iframe.contentWindow.document.documentElement.offsetHeight;
};
[].forEach.call(iframify, (item, i) => {
var width = item.getAttribute('data-width');
item.insertAdjacentHTML('afterend', `<iframe src="${location.href}/#iframify-${i}" width="${width}" frameborder="0" onload="iframifyResize(this)">`);
});
} else {
var index = +location.hash.replace('#iframify-', '');
document.body.style.margin = 0;
document.body.innerHTML = iframify[index].innerHTML; // clear other node
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment