Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8829/fix/redesign sort UI #9489

Merged
merged 38 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
191d60b
Redesigned UI of sort options into dropdown menu in /search
aarasawa Jun 25, 2024
87c9497
Merge branch '8829/fix/redesign-sort-ui' of https://github.com/aarasa…
aarasawa Jun 25, 2024
6ec2171
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jun 26, 2024
fbfaba3
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jun 29, 2024
08bf155
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 5, 2024
3ce6633
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 8, 2024
a04a603
Redesigned UI of sort options into dropdown menu in /search
aarasawa Jun 25, 2024
a1fd84d
Reimplemented dropdown menu with details element
aarasawa Jul 8, 2024
b253403
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2024
268c571
Merge branch '8829/fix/redesign-sort-ui' of https://github.com/aarasa…
aarasawa Jul 8, 2024
eb07841
Merge branch '8829/fix/redesign-sort-ui' of https://github.com/aarasa…
aarasawa Jul 8, 2024
ffed8b4
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 9, 2024
27c815e
Reimplemented dropdown menu closer to cta-btn and added CSS component
aarasawa Jul 10, 2024
72da7f1
Create sort-dropper.less
aarasawa Jul 10, 2024
a343b01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2024
6017d1a
Update static/css/components/sort-dropper.less
aarasawa Jul 11, 2024
38d4d4a
finalized dropdown menu CSS changes and resolved overridden anchor ta…
aarasawa Jul 11, 2024
d1a46b6
Merge branch '8829/fix/redesign-sort-ui' of https://github.com/aarasa…
aarasawa Jul 11, 2024
5e9a299
Added i18n internationalization support for dropdown text and CSS cha…
aarasawa Jul 12, 2024
7ff54ae
Added CSS style revisions to better understand sort option selection
aarasawa Jul 13, 2024
5d77cd3
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 13, 2024
2e8d81f
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 15, 2024
122cdb0
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 17, 2024
523bc41
Updated sort-dropper.less
aarasawa Jul 17, 2024
d8bb0bb
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Jul 23, 2024
fb397ca
Swapped dropdown menu caret icons to stay consistent with Want to Rea…
aarasawa Jul 23, 2024
39b5186
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Aug 20, 2024
7b19d16
rm work_count sort
mekarpeles Aug 22, 2024
353d3bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 22, 2024
4aba40d
increase bundle size
mekarpeles Aug 22, 2024
067efa2
Merge branch 'master' into 8829/fix/redesign-sort-ui
mekarpeles Aug 22, 2024
d2193c5
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Sep 3, 2024
f2bc782
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Sep 8, 2024
64d33a6
Merge branch 'master' into 8829/fix/redesign-sort-ui
mekarpeles Sep 20, 2024
cb8e320
Merge branch 'master' into 8829/fix/redesign-sort-ui
mekarpeles Sep 26, 2024
c27c075
Merge branch 'internetarchive:master' into 8829/fix/redesign-sort-ui
aarasawa Sep 26, 2024
e940e20
Adding empty div seems to fix rendering problem in authors template
aarasawa Sep 28, 2024
370c08f
fix author page sort styling
mekarpeles Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
},
{
"path": "static/build/page-user.css",
"maxSize": "28KB"
"maxSize": "30KB"
}
]
}
16 changes: 6 additions & 10 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6075,18 +6075,10 @@ msgstr ""
msgid "On leaf number %(page_num)d:"
msgstr ""

#: search/sort_options.html
msgid "Sorted by"
msgstr ""

#: search/sort_options.html
msgid "Relevance"
msgstr ""

#: search/sort_options.html
msgid "Work Count"
msgstr ""

#: search/sort_options.html
msgid "Random"
msgstr ""
Expand Down Expand Up @@ -6116,11 +6108,15 @@ msgid "Top Rated"
msgstr ""

#: search/sort_options.html
msgid "Any"
msgid "Work Title (beta: Librarian only)"
msgstr ""

#: search/sort_options.html
msgid "Work Title (beta: Librarian only)"
msgid "Work Count"
msgstr ""

#: search/sort_options.html
msgid "Any"
msgstr ""

#: search/sort_options.html
Expand Down
100 changes: 68 additions & 32 deletions openlibrary/templates/search/sort_options.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
$def with (selected_sort, exclude=None, default_sort='relevance', search_scheme='works')

<span class="tools">
<img src="/images/icons/icon_sort.png" class="" alt="$_('Sorting by')" width="9" height="11" class="sorter" />
$_('Sorted by'):
<span class="sort">
$code:
sort_option_names = {
'relevance': _("Relevance"),
'random': _("Random"),
'index': _("List Order"),
'last_modified': _("Last Modified"),
'editions': _("Most Editions"),
'old': _("First Published"),
'new': _("Most Recent"),
'rating': _("Top Rated"),
'readinglog': _("Reading Log"),
mekarpeles marked this conversation as resolved.
Show resolved Hide resolved
'want_to_read': _("Want to Read"),
'currently_reading': _("Currently Reading"),
'already_read': _("Already Read"),
mekarpeles marked this conversation as resolved.
Show resolved Hide resolved
'title': _("Work Title (beta: Librarian only)")
}

def get_selected_sort_name(selected_sort, default_sort, sort_option_names):
if selected_sort and selected_sort.startswith('random'):
return sort_option_names['random']
return sort_option_names.get(selected_sort, sort_option_names.get(default_sort, _("Sorting by")))

selected_sort_name = get_selected_sort_name(selected_sort, default_sort, sort_option_names)

if search_scheme == 'authors':
sort_options = [
{ 'sort': 'relevance', 'name': _("Relevance"), 'ga_key': 'Relevance' },
Expand Down Expand Up @@ -38,34 +59,49 @@
]
if ctx.user and (ctx.user.is_admin() or ctx.user.is_librarian()):
sort_options.append({ 'sort': 'title', 'name': _("Work Title (beta: Librarian only)"), 'ga_key': 'Title' })
$for sort_option in sort_options:
$if exclude and sort_option['sort'] in exclude:
$continue
$ is_selected = sort_option.get('selected') or sort_option['sort'] == selected_sort or (selected_sort is None and sort_option['sort'] == default_sort)
$if is_selected:
<a><strong>$sort_option['name']</strong></a>
$else:
<a href="$changequery(page=None, sort=cond(sort_option['sort'] == default_sort, None, sort_option['sort']))"
data-ol-link-track="SearchSort|$sort_option['ga_key']"
rel="nofollow"
>$sort_option['name']</a>
$if sort_option.get('sub_sorts') and is_selected:
<select
data-ol-link-track="SearchSort|$sort_option['ga_key']SubSort"
onchange="window.location.href = this.value"
>
$for sub_sort in sort_option['sub_sorts']:
$ is_selected = sub_sort['sort'] == selected_sort
<option
value="$changequery(page=None, sort=cond(sub_sort['sort'] == default_sort, None, sub_sort['sort']))"
$cond(is_selected, 'selected')
>$sub_sort['name']</option>
</select>
$if not loop.last:
|
<span class="sort-dropper">
<details>
<summary>
<img src="/images/icons/icon_sort.png" alt="$_('Sorting by')" width="9" height="11" />
<p>$selected_sort_name</p>
</summary>
<span class="sort-content">
<span class="sort-content-inner">
$for sort_option in sort_options:
$if exclude and sort_option['sort'] in exclude:
$continue
$ is_selected = sort_option.get('selected') or sort_option['sort'] == selected_sort or (selected_sort is None and sort_option['sort'] == default_sort)
$if is_selected:
<a class="sort-selected">$sort_option['name']</a>
$else:
<a href="$changequery(page=None, sort=cond(sort_option['sort'] == default_sort, None, sort_option['sort']))"
data-ol-link-track="SearchSort|$sort_option['ga_key']"
rel="nofollow"
>
$sort_option['name']
</a>
$if sort_option.get('sub_sorts') and is_selected:
$for sub_sort in sort_option['sub_sorts']:
$ is_selected = sub_sort['sort'] == selected_sort
$if is_selected:
<a class="sort-subsort-selected">$sub_sort['name']</a>
$else:
<a class="sort-subsort"
href="$changequery(page=None, sort=cond(sub_sort['sort'] == default_sort, None, sub_sort['sort']))"
data-ol-link-track="SearchSort|$sort_option['ga_key']SubSort"
>
$sub_sort['name']
</a>
</span>
</span>
</details>
</span>
$if selected_sort and selected_sort.startswith('random') and not is_bot():
(<a href="$changequery(page=None, sort='random_%s' % today().timestamp())"
data-ol-link-track="SearchSort|RandomShuffle"
rel="nofollow"
>$_('Shuffle')</a>)
<a class="sort-random-shuffle"
href="$changequery(page=None, sort='random_%s' % today().timestamp())"
data-ol-link-track="SearchSort|RandomShuffle"
rel="nofollow"
>
$_('Shuffle')
</a>
</span>
1 change: 1 addition & 0 deletions openlibrary/templates/type/author/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ <h2 class="collapse">
</h2>
<p id="books">
$if books_count > 1:
<div></div>
$:render_template("search/sort_options.html", books.sort, exclude='relevance', default_sort='editions')

mekarpeles marked this conversation as resolved.
Show resolved Hide resolved
<p>
Expand Down
118 changes: 118 additions & 0 deletions static/css/components/sort-dropper.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.sort-dropper {
display: inline-flex;
}

.sort-content {
display: flex;
background: @white;
}

.sort-content-inner {
display: flex;
flex-direction: column;
position: absolute;
margin-top: 10px;
background-color: @lightest-grey;
border: 1px solid;
border-radius: 5px;
border-color: @light-grey;
z-index: @z-index-level-1;

a {
text-decoration: none;
color: @grey;
padding-right: 25px;
border: 2px solid transparent;

&:link,
&:visited {
color: @black;
}

aarasawa marked this conversation as resolved.
Show resolved Hide resolved
&:hover {
color: @grey;
border-color: @primary-blue;
}

&.sort-selected::before {
color: @grey;
padding-right: 5px;
}

&.sort-subsort-selected::before {
color: @grey;
padding-right: 5px;
}
}

a::before {
content: "✓";
margin: 5px 10px;
color: transparent;
}

a.sort-subsort {
padding-left: 20px;

&::before {
content: "✓";
margin: 5px 10px;
color: transparent;
}

&-selected {
padding-left: 20px;
padding-right: 10px;
color: @grey;
}
}

}

.sort details {
border-radius: 5px;
background: @lightest-grey;
border: 1px solid;
border-color: @mid-grey;

summary {
font-size: 1rem;
color: @black;
display: inline-flex;
list-style-type: none;
cursor: pointer;
align-items: center;
justify-content: center;
text-align: center;
}

summary p {
padding: 2px 10px;
margin: 0;
border-right: 1px solid;
border-color: @gray-d1cfd0;
}

&[open] {
background: @lighter-grey;
}
}

.sort details summary img {
margin-left: 10px;
}

.sort details summary::after {
content: "▾";
color: @dark-grey;
padding: 2px 10px;
}

.sort details[open] summary::after {
content: "▴";
}

.sort-random-shuffle {
display: inline-flex;
padding: 5px;
}
2 changes: 2 additions & 0 deletions static/css/page-user.less
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,5 @@ tr.table-row.selected{
@import (less) "components/mybooks-dropper.less";
// Import styles for search box
@import (less) "components/searchbox.less";
// Import styles for sort options
@import (less) "components/sort-dropper.less";