Created
February 6, 2020 11:09
-
-
Save shapeshifta78/8da9a37301273e2e82af1173df848f1f to your computer and use it in GitHub Desktop.
This file contains 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
let view; | |
const viewporter = {}; | |
const html = document.documentElement; | |
viewporter.getView = () => { | |
try { | |
view = window | |
.getComputedStyle(html, ":after") | |
.getPropertyValue("content") | |
.replace(/["']/g, ""); | |
} catch (error) { | |
view = "undefined"; | |
} | |
return view; | |
}; | |
// split view names and return only the main part | |
viewporter.mainView = () => viewporter.getView().split("-")[0]; | |
export const getView = viewporter.getView; | |
// convenience functions for common view names | |
export const isLarge = () => viewporter.mainView() === "large"; | |
export const isMedium = () => viewporter.mainView() === "medium"; | |
export const isSmall = () => viewporter.mainView() === "small"; |
This file contains 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
html:after { | |
@include media("", tablet) { | |
content: "small"; | |
} | |
@include media(tablet, desktop) { | |
content: "medium"; | |
} | |
@include media(desktop, "") { | |
content: "large"; | |
} | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment