Remove almost all data-hx-boost attributes

Since 16e80b5ae, <body> no longer has overflow, thus no scroll.  As a
consequence, htmx no longer is able to scroll up <main> when it changes
due to the default, implicit `show:true` applied to the request: is
calls <main>’s scrollIntoView, however there is nothing to scroll to.

I probably could fix it by changing the target of `show`, or even add
a `scroll` directive to all boosted links, but at this point i think it
is better no not boost links at all, as they do what i want—show the new
page from the top—with less markup, plus the browser now show a loading
animation, and it is not that slower, too.
This commit is contained in:
jordi fita mas 2024-09-08 01:29:30 +02:00
parent 2eecdcfc3e
commit 82da7f4697
15 changed files with 35 additions and 54 deletions

View File

@ -15,7 +15,7 @@
<body class="filters-visible">
<header>
<h1><img src="/static/numerus.svg" alt="Numerus" width="168" height="21"></h1>
<nav aria-label="{{( pgettext "Main" "title" )}}" data-hx-target="main" data-hx-boost="true">
<nav aria-label="{{( pgettext "Main" "title" )}}">
<ul>
<li><a{{if requestURIMatches (companyURI "/") }} aria-current="page"{{ end }} href="{{ companyURI "/" }}">{{( pgettext "Dashboard" "nav" )}}</a></li>
<li><a{{if requestURIHasPrefix (companyURI "/quotes") }} aria-current="page"{{ end }} href="{{ companyURI "/quotes" }}">{{( pgettext "Quotations" "nav" )}}</a></li>
@ -30,9 +30,10 @@
<summary aria-label="{{( gettext "Profile menu" )}}">
<i class="ri-user-6-line ri-2x"></i>
</summary>
<ul role="menu" class="action-menu" data-hx-push-url="false" data-hx-swap="beforeend">
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/profile" }}" data-hx-boost="true">
<a role="menuitem" href="{{ companyURI "/profile" }}"
data-hx-push-url="false" data-hx-swap="beforeend" data-hx-boost="true">
<i class="ri-user-6-line"></i>
{{( pgettext "Account" "menu" )}}
</a>
@ -68,7 +69,8 @@
</a>
</li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/switch-company" }}" data-hx-boost="true">
<a role="menuitem" href="{{ companyURI "/switch-company" }}"
data-hx-push-url="false" data-hx-swap="beforeend" data-hx-boost="true">
<i class="ri-briefcase-line"></i>
{{( pgettext "Switch Company" "menu" )}}
</a>

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.CompanySwitchPage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{ template "title" . }}</a>
@ -14,7 +14,7 @@
{{ define "content" }}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.CompanySwitchPage*/ -}}
<section class="dialog-content" id="switch-company-dialog-content" data-hx-target="this">
<section class="dialog-content">
<h2>{{ template "title" . }}</h2>
<table>
<thead>

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.TaxDetailsPage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{ template "title" . }}</a>

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.ContactsIndexPage*/ -}}
<nav data-hx-boost="true" data-hx-target="main">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Contacts" "title" )}}</a>
@ -55,8 +55,7 @@
{{ with .Contacts }}
{{- range $contact := . }}
<tr>
<td><a href="{{ companyURI "/contacts/"}}{{ .Slug }}" data-hx-target="main"
data-hx-boost="true">{{ .Name }}</a></td>
<td><a href="{{ companyURI "/contacts/"}}{{ .Slug }}">{{ .Name }}</a></td>
<td><a href="mailto:{{ .Email }}">{{ .Email }}</a></td>
<td><a href="tel:{{ .Phone }}">{{ .Phone }}</a></td>
<td
@ -75,9 +74,7 @@
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/contacts"}}/{{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<a role="menuitem" href="{{ companyURI "/contacts"}}/{{ .Slug }}">
<i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}}
</a>

View File

@ -5,8 +5,8 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.expensesIndexPage*/ -}}
<nav data-hx-target="main">
<p data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Expenses" "title" )}}</a>
</p>
@ -28,7 +28,6 @@
name="action" value="export"
>{{( pgettext "Export list" "action" )}}</button>
<a class="primary button"
data-hx-boost="true"
href="{{ companyURI "/expenses/new" }}">{{( pgettext "New expense" "action" )}}</a>
</p>
</form>
@ -116,9 +115,7 @@
<details class="menu">
{{- $label := .InvoiceNumber | printf (gettext "Actions for expense %s") -}}
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu"
data-hx-target="main" data-hx-boost="true"
>
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/expenses"}}/{{ .Slug }}">
<i class="ri-edit-line"></i>

View File

@ -5,7 +5,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newExpensePage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/expenses"}}">{{( pgettext "Expenses" "title" )}}</a> /

View File

@ -5,14 +5,13 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentAccountIndexPage*/ -}}
<nav data-hx-target="main">
<p data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Payment Accounts" "title" )}}</a>
</p>
<a class="primary button"
data-hx-boost="true"
href="{{ companyURI "/payment-accounts/new" }}">{{( pgettext "New payment account" "action" )}}</a>
</nav>
{{- end }}

View File

@ -9,8 +9,8 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentIndexPage*/ -}}
<nav data-hx-target="main">
<p data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
{{ if .Expense }}
<a href="{{ companyURI "/expenses" }}">{{( pgettext "Expenses" "title" )}}</a> /
@ -22,9 +22,7 @@
<a>{{ template "title" . }}</a>
</p>
<a class="primary button"
data-hx-boost="true"
href="{{ .BaseURI }}/new">
<a class="primary button" href="{{ .BaseURI }}/new">
{{- if .Invoice -}}
{{( pgettext "New collection" "action" )}}
{{- else -}}
@ -101,9 +99,7 @@
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ $.BaseURI }}/{{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<a role="menuitem" href="{{ $.BaseURI }}/{{ .Slug }}">
<i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}}
</a>

View File

@ -9,7 +9,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
{{ if .Expense }}

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.profileForm*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "User Settings" "title" )}}</a>

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editQuotationPage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /

View File

@ -4,8 +4,8 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.QuotesIndexPage*/ -}}
<nav data-hx-target="main">
<p data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Quotations" "title" )}}</a>
</p>
@ -29,7 +29,7 @@
<button type="submit"
name="action" value="export"
>{{( pgettext "Export list" "action" )}}</button>
<a class="primary button" data-hx-boost="true"
<a class="primary button"
href="{{ companyURI "/quotes/new" }}">{{( pgettext "New quotation" "action" )}}</a>
</p>
</form>
@ -84,8 +84,7 @@
aria-label="{{ $title }}"
title="{{ $title }}"/></td>
<td>{{ .Date|formatDate }}</td>
<td><a href="{{ companyURI "/quotes/"}}{{ .Slug }}" data-hx-target="main"
data-hx-boost="true">{{ .Number }}</a></td>
<td><a href="{{ companyURI "/quotes/"}}{{ .Slug }}">{{ .Number }}</a></td>
<td>{{ .CustomerName }}</td>
<td>
<details class="quote-status menu">
@ -130,25 +129,19 @@
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/quotes"}}/{{ .Slug }}/edit"
data-hx-target="main" data-hx-boost="true"
>
<a role="menuitem" href="{{ companyURI "/quotes"}}/{{ .Slug }}/edit">
<i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}}
</a>
</li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/quotes/new"}}?duplicate={{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<a role="menuitem" href="{{ companyURI "/quotes/new"}}?duplicate={{ .Slug }}">
<i class="ri-file-copy-line"></i>
{{( pgettext "Duplicate" "action" )}}
</a>
</li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/invoices/new"}}?quote={{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<a role="menuitem" href="{{ companyURI "/invoices/new"}}?quote={{ .Slug }}">
<i class="ri-bill-line"></i>
{{( pgettext "Create invoice" "action" )}}
</a>

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newQuotePage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /

View File

@ -4,7 +4,7 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newQuoteProductsPage*/ -}}
<nav data-hx-target="main" data-hx-boost="true">
<nav>
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /

View File

@ -5,20 +5,17 @@
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.quote*/ -}}
<nav>
<p data-hx-target="main" data-hx-boost="true">
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /
<a>{{ .Number }}</a>
</p>
<p>
<a class="button primary"
data-hx-target="main" data-hx-boost="true"
href="{{ companyURI "/invoices/new"}}?quote={{ .Slug }}">{{( pgettext "Create invoice" "action" )}}</a>
<a class="button primary"
data-hx-target="main" data-hx-boost="true"
href="{{ companyURI "/quotes/new"}}?duplicate={{ .Slug }}">{{( pgettext "Duplicate" "action" )}}</a>
<a class="button primary"
data-hx-target="main" data-hx-boost="true"
href="{{ companyURI "/quotes/"}}{{ .Slug }}/edit">{{( pgettext "Edit" "action" )}}</a>
<a class="primary button"
href="{{ companyURI "/quotes/" }}{{ .Slug }}.pdf"