Skip to content

Commit

Permalink
Merge pull request #389 from jovandeginste/wo-no-name
Browse files Browse the repository at this point in the history
Refactor(views): Improve workout and route segment name display
  • Loading branch information
jovandeginste authored Jan 8, 2025
2 parents 04ff381 + 577ef91 commit d6b62f2
Show file tree
Hide file tree
Showing 24 changed files with 1,046 additions and 998 deletions.
5 changes: 4 additions & 1 deletion views/equipment/show.templ
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/jovandeginste/workout-tracker/pkg/database"
"github.com/jovandeginste/workout-tracker/views/helpers"
"github.com/jovandeginste/workout-tracker/views/partials"
"github.com/jovandeginste/workout-tracker/views/workouts"
)

templ Show(e *database.Equipment) {
Expand Down Expand Up @@ -123,7 +124,9 @@ templ Show(e *database.Equipment) {
</div>
</td>
<td>
<a href={ templ.SafeURL(helpers.RouteFor(ctx, "workout-show", w.ID)) }>{ w.Name }</a>
<a href={ templ.SafeURL(helpers.RouteFor(ctx, "workout-show", w.ID)) }>
@workouts.Name(&w, 20)
</a>
</td>
<td class="hidden sm:table-cell">
@partials.SnippetDate(w.Date)
Expand Down
48 changes: 22 additions & 26 deletions views/equipment/show_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions views/route_segments/details.templ
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package route_segments

import (
"fmt"
"github.com/invopop/ctxi18n/i18n"
"github.com/jovandeginste/workout-tracker/pkg/database"
"github.com/jovandeginste/workout-tracker/views/helpers"
"github.com/jovandeginste/workout-tracker/views/partials"
)

templ Name(s *database.RouteSegment, maxLength int) {
if s.Name == "" {
<i>(no name)</i>
} else if maxLength > 0 && len(s.Name) > maxLength {
<abbr title={ s.Name }>{ fmt.Sprintf("%.*s", maxLength, s.Name) }...</abbr>
} else {
{ s.Name }
}
}

templ details(s *database.RouteSegment) {
{{ preferredUnits := helpers.CurrentUser(ctx).PreferredUnits() }}
<table>
Expand Down
Loading

0 comments on commit d6b62f2

Please sign in to comment.