Skip to content

Commit

Permalink
feat(html): add 'default' option to sort menus
Browse files Browse the repository at this point in the history
This should make it more clear which option is selected. The default one
is the same as "least recently added" aka from oldest to newest created.
The wording could be made better, but that's something we'll do later.
  • Loading branch information
vednoc committed Jul 4, 2021
1 parent 40a8b00 commit 4559fe3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion handlers/core/search.go
Expand Up @@ -35,7 +35,7 @@ func Search(c *fiber.Ctx) error {
case "leastviews":
return s[i].Views < s[j].Views
default:
return s[i].CreatedAt.Unix() > s[j].CreatedAt.Unix()
return s[i].CreatedAt.Unix() < s[j].CreatedAt.Unix()
}
})

Expand Down
2 changes: 1 addition & 1 deletion handlers/style/explore.go
Expand Up @@ -40,7 +40,7 @@ func GetExplore(c *fiber.Ctx) error {
case "leastviews":
return s[i].Views < s[j].Views
default:
return s[i].CreatedAt.Unix() > s[j].CreatedAt.Unix()
return s[i].CreatedAt.Unix() < s[j].CreatedAt.Unix()
}
})

Expand Down
3 changes: 2 additions & 1 deletion views/partials/form-sort.html
@@ -1,8 +1,9 @@
<label for="sort">Sort by</label>
<div class="sort flex ai:c">
<select id="sort" name="sort">
<option {{ if eq .Sort "" }}selected{{ end }} value="default">Default</option>
<option {{ if eq .Sort "newest" }}selected{{ end }} value="newest">Recently added</option>
<option {{ if eq .Sort "oldest" }}selected{{ end }} value="oldest">Least recenetly added</option>
<option {{ if eq .Sort "oldest" }}selected{{ end }} value="oldest">Least recently added</option>
<option {{ if eq .Sort "recentlyupdated" }}selected{{ end }} value="recentlyupdated">Recently updated</option>
<option {{ if eq .Sort "leastupdated" }}selected{{ end }} value="leastupdated">Least recently updated</option>
<option {{ if eq .Sort "mostinstalls" }}selected{{ end }} value="mostinstalls">Most installs</option>
Expand Down

0 comments on commit 4559fe3

Please sign in to comment.