Skip to content

Instantly share code, notes, and snippets.

View ljungmark's full-sized avatar
🍻
/dance

ʟᴊᴜɴɢᴍ•ʀᴋ ljungmark

🍻
/dance
View GitHub Profile
@eduardoboucas
eduardoboucas / im-to-em.md
Last active February 15, 2023 02:56
📐 Converting include-media breakpoints to em units

'At' sign

include-media — em units

Get include-media here.

If you're using include-media to manage your breakpoints, you might want to have it generate media queries in em units but still declare the breakpoints in px for convenience.

We decided not to add this to the library core, as it's outside the scope of the project, but you can achieve that with a tiny function:

// this is the service worker which intercepts all http requests
self.addEventListener('fetch', function fetcher (event) {
var request = event.request;
// check if request
if (request.url.indexOf('assets.contentful.com') > -1) {
// contentful asset detected
event.respondWith(
caches.match(event.request).then(function(response) {
// return from cache, otherwise fetch from network
return response || fetch(request);