From 9eae560cae4f631caf0e7ed25240dad13db04399 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 7 Dec 2019 00:16:59 -0800 Subject: [PATCH] Make sidenotes mobile-friendly --- themes/vanilla/assets/scss/sidenotes.scss | 45 +++++++++++++++++----- themes/vanilla/layouts/shortcodes/sidenote | 7 ++-- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/themes/vanilla/assets/scss/sidenotes.scss b/themes/vanilla/assets/scss/sidenotes.scss index 1a57352..b7bbcc8 100644 --- a/themes/vanilla/assets/scss/sidenotes.scss +++ b/themes/vanilla/assets/scss/sidenotes.scss @@ -4,16 +4,6 @@ $sidenote-width: 350px; $sidenote-offset: 15px; .sidenote { - &.right .sidenote-content { - right: 0; - margin-right: -($sidenote-width + $sidenote-offset); - } - - &.left .sidenote-content { - left: 0; - margin-left: -($sidenote-width + $sidenote-offset); - } - &:hover { .sidenote-label { background-color: $primary-color; @@ -32,12 +22,47 @@ $sidenote-offset: 15px; border-bottom: 2px solid $primary-color; } +.sidenote-checkbox { + display: none; +} + .sidenote-content { display: block; position: absolute; width: $sidenote-width; margin-top: -1.5em; + &.sidenote-right { + right: 0; + margin-right: -($sidenote-width + $sidenote-offset); + } + + &.sidenote-left { + left: 0; + margin-left: -($sidenote-width + $sidenote-offset); + } + + @media screen and + (max-width: $container-width + 2 * ($sidenote-width + 2 * $sidenote-offset)) { + position: static; + margin-top: 10px; + margin-bottom: 10px; + width: 100%; + display: none; + + .sidenote-checkbox:checked ~ & { + display: block; + } + + &.sidenote-left { + margin-left: 0px; + } + + &.sidenote-right { + margin-right: 0px; + } + } + @include bordered-block; padding: 10px; box-sizing: border-box; diff --git a/themes/vanilla/layouts/shortcodes/sidenote b/themes/vanilla/layouts/shortcodes/sidenote index 9fe4b50..455b908 100644 --- a/themes/vanilla/layouts/shortcodes/sidenote +++ b/themes/vanilla/layouts/shortcodes/sidenote @@ -1,6 +1,7 @@ - - - + + + + {{ .Inner }}