From b15b48f702fe37e25fe09777d24520a0501ca521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20W=C3=B3jcik?= Date: Sat, 13 Sep 2025 06:56:44 +0000 Subject: [PATCH] =?UTF-8?q?BTHLABS-55:=20Inline=20create=20save=20form=20C?= =?UTF-8?q?o-authored-by:=20Tomek=20W=C3=B3jcik=20=20?= =?UTF-8?q?Co-committed-by:=20Tomek=20W=C3=B3jcik=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/static/ui/css/hotpocket-backend.css | 21 +++++++- ...tpocket-backend.ui.InlineCreateSaveForm.js | 53 +++++++++++++++++++ .../apps/ui/templates/ui/page.html | 35 ++++++------ 3 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 services/backend/hotpocket_backend/apps/ui/static/ui/js/hotpocket-backend.ui.InlineCreateSaveForm.js diff --git a/services/backend/hotpocket_backend/apps/ui/static/ui/css/hotpocket-backend.css b/services/backend/hotpocket_backend/apps/ui/static/ui/css/hotpocket-backend.css index 5388a61..862105d 100644 --- a/services/backend/hotpocket_backend/apps/ui/static/ui/css/hotpocket-backend.css +++ b/services/backend/hotpocket_backend/apps/ui/static/ui/css/hotpocket-backend.css @@ -23,7 +23,6 @@ body, html { } body > .ui-viewport { - padding-bottom: 3.5rem; padding-top: 3.5rem; } @@ -103,3 +102,23 @@ body.ui-mode-standalone #offcanvas-controls .offcanvas-body { #BrowseSavesView-Search .form-select { min-width: 10rem; } + +#navbar .ui-inline-create-save-form { + bottom: 0px; + right: 0px; + top: 0px; + width: 500px; +} + +@media screen and (max-width: 767px) { + #navbar .ui-inline-create-save-form { + right: 0.5rem; + width: calc(100vw - 0.5rem - 0.5rem); + } +} + +@media screen and (min-width: 768px) { + #InlineCreateSaveForm { + position: relative; + } +} diff --git a/services/backend/hotpocket_backend/apps/ui/static/ui/js/hotpocket-backend.ui.InlineCreateSaveForm.js b/services/backend/hotpocket_backend/apps/ui/static/ui/js/hotpocket-backend.ui.InlineCreateSaveForm.js new file mode 100644 index 0000000..10304c9 --- /dev/null +++ b/services/backend/hotpocket_backend/apps/ui/static/ui/js/hotpocket-backend.ui.InlineCreateSaveForm.js @@ -0,0 +1,53 @@ +/*! + * HotPocket by BTHLabs (https://hotpocket.app/) + * Copyright 2025-present BTHLabs (https://bthlabs.pl/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +((HotPocket, htmx) => { + class InlineCreateSaveForm { + constructor (app) { + this.app = app; + this.element = null; + this.buttonTrigger = null; + this.form = null; + } + onLoad = (event) => { + console.log('UI.InlineCreateSaveForm.onLoad()', event); + this.element = document.getElementById('InlineCreateSaveForm'); + this.buttonTrigger = this.element.querySelector('.ui-inline-create-save-form-trigger'); + this.buttonClose = this.element.querySelector('.ui-inline-create-save-form-close'); + this.form = this.element.querySelector('.ui-inline-create-save-form'); + + this.buttonTrigger.addEventListener('click', this.onTriggerClick); + this.buttonClose.addEventListener('click', this.onCloseClick); + }; + onTriggerClick = (event) => { + event.preventDefault(); + + this.form.classList.remove('d-none'); + this.form.classList.add('d-flex'); + }; + onCloseClick = (event) => { + event.stopPropagation(); + event.preventDefault(); + + this.form.classList.add('d-none'); + this.form.classList.remove('d-flex'); + }; + } + + HotPocket.addPlugin('UI.InlineCreateSaveForm', (app) => { + return new InlineCreateSaveForm(app); + }); +})(window.HotPocket, window.htmx); diff --git a/services/backend/hotpocket_backend/apps/ui/templates/ui/page.html b/services/backend/hotpocket_backend/apps/ui/templates/ui/page.html index e20f7c8..0706850 100644 --- a/services/backend/hotpocket_backend/apps/ui/templates/ui/page.html +++ b/services/backend/hotpocket_backend/apps/ui/templates/ui/page.html @@ -40,7 +40,25 @@ {% endif %} - + {% endif %} +