From 2a9c375273dc8ace8965e326d11c02b9029e5161 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 18 Apr 2025 12:28:46 +0300 Subject: [PATCH] adjust header --- app/javascript/elements/scroll_buttons.js | 12 +++++++++--- app/views/submit_form/show.html.erb | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/javascript/elements/scroll_buttons.js b/app/javascript/elements/scroll_buttons.js index 0fdfcab4..9a7caf12 100644 --- a/app/javascript/elements/scroll_buttons.js +++ b/app/javascript/elements/scroll_buttons.js @@ -5,7 +5,9 @@ export default class extends HTMLElement { window.addEventListener('scroll', this.onScroll.bind(this)) window.addEventListener('resize', this.onResize.bind(this)) - this.onResize() + if (!this.isNarrow() && this.isHeaderNotVisible()) { + this.showButtons({ animate: false }) + } } disconnectedCallback () { @@ -22,7 +24,7 @@ export default class extends HTMLElement { } isNarrow () { - return window.innerWidth < 1366 + return window.innerWidth < 1230 } onScroll () { @@ -38,7 +40,11 @@ export default class extends HTMLElement { return rect.bottom <= 0 || rect.top >= window.innerHeight } - showButtons () { + showButtons ({ animate } = { animate: true }) { + if (animate) { + this.classList.add('transition-transform', 'duration-300') + } + this.classList.remove('hidden', '-translate-y-10', 'opacity-0') this.classList.add('translate-y-0', 'opacity-100') } diff --git a/app/views/submit_form/show.html.erb b/app/views/submit_form/show.html.erb index 566413ba..491256a6 100644 --- a/app/views/submit_form/show.html.erb +++ b/app/views/submit_form/show.html.erb @@ -8,10 +8,10 @@
- <%# flex block w-full sticky top-0 z-50 space-x-2 items-center bg-yellow-100 p-2 border-y border-yellow-200 %> + <%# flex block w-full sticky top-0 z-50 space-x-2 items-center bg-yellow-100 p-2 border-y border-yellow-200 transition-transform duration-300 %> <%= local_assigns[:banner_html] || capture do %> <%= render('submit_form/banner') %> -
+
<%= @submitter.submission.template.name %>
@@ -36,16 +36,23 @@
-