diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ea9467..a000683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.0.13 +## 15/10/2022 + +1. [](#improved) + * Animate banner show/hide + # v1.0.12 ## 14/10/2022 diff --git a/blueprints.yaml b/blueprints.yaml index db7ecae..55066c1 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Custom Banner slug: custom-banner type: plugin -version: 1.0.12 +version: 1.0.13 description: Add a custom banner to your Grav site icon: bookmark author: diff --git a/css/custom-banner.css b/css/custom-banner.css index fb1e852..d6c6c77 100644 --- a/css/custom-banner.css +++ b/css/custom-banner.css @@ -3,6 +3,21 @@ div.custom-banner-container { position: fixed; width: 100%; z-index: 10000; + + /* Animate show/hide */ + -webkit-transition: all 0.2s ease-in-out 0s; + -moz-transition: all 0.2s ease-in-out 0s; + -ms-transition: all 0.2s ease-in-out 0s; + transition: all 0.2s ease-in-out 0s; + + /* Hidden by default */ + opacity: 0; + visibility: hidden; +} + +div.custom-banner-container.shown { + opacity: 1; + visibility: visible; } div.custom-banner-body { diff --git a/custom-banner.php b/custom-banner.php index 923d86c..3dee579 100644 --- a/custom-banner.php +++ b/custom-banner.php @@ -121,7 +121,7 @@ public function onOutputGenerated(): void // Generate banner HTML // Content $content = $config['content']; - $hidden = ($config['cdn-fix'] ? 'none' : 'block'); + $hidden = ($config['cdn-fix'] ? '' : 'shown'); $button_text = $config['button-text']; $button_url = $config['button-url']; $dismiss_text = $config['dismiss-text']; @@ -134,7 +134,7 @@ public function onOutputGenerated(): void $box_shadow = ($config['box-shadow'] ? '5px 5px 0.75rem gray' : 'none'); $banner = << +
$content
diff --git a/js/custom-banner.js b/js/custom-banner.js index a42cff4..3b6f921 100644 --- a/js/custom-banner.js +++ b/js/custom-banner.js @@ -1,10 +1,10 @@ function custom_button_dismiss() { document.cookie = 'custom-banner-dismiss=true; max-age=1800; SameSite=Strict'; - document.getElementsByClassName('custom-banner-container')[0].style.display = 'none'; + document.getElementsByClassName('custom-banner-container')[0].classList.remove('shown'); } function custom_button_show() { - document.getElementsByClassName('custom-banner-container')[0].style.display = 'block'; + document.getElementsByClassName('custom-banner-container')[0].classList.add('shown'); } let hidden = document.cookie