From 8b4e76d504e3a483aecfd34636650dd7b6c756f9 Mon Sep 17 00:00:00 2001 From: merwhite11 Date: Mon, 16 Sep 2024 16:12:05 -0700 Subject: [PATCH] Bug fixes --- openlibrary/macros/SearchResultsWork.html | 5 +-- openlibrary/macros/StarRatingsComponent.html | 7 ++-- openlibrary/macros/StarRatingsStats.html | 15 ++++---- static/css/components/readerStats.less | 37 +++++++++----------- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/openlibrary/macros/SearchResultsWork.html b/openlibrary/macros/SearchResultsWork.html index dcb90ee3d497..06d3ef850c92 100644 --- a/openlibrary/macros/SearchResultsWork.html +++ b/openlibrary/macros/SearchResultsWork.html @@ -113,9 +113,10 @@

$ungettext('%(count)s edition', '%(count)s editions', doc.edition_count, count=doc.edition_count) - $if doc.get('languages'): + $if doc.get('languages') and doc_type in ['infogami_work', 'solr_work']: - $:ungettext('in %(count)d language', 'in %(count)d languages', len(doc.languages), count=len(doc.languages), langs=commify_list([get_language_name('/languages/' + lang) for lang in doc.languages])) + $ langs = [get_language_name(lang.key if hasattr(lang, 'key') else '/languages' + lang) for lang in doc.languages] + $:ungettext('in %(count)d language', 'in %(count)d languages', len(doc.languages), count=len(doc.languages), langs=commify_list(langs)) diff --git a/openlibrary/macros/StarRatingsComponent.html b/openlibrary/macros/StarRatingsComponent.html index 10f2a36b64c3..abc5bea3c7e7 100644 --- a/openlibrary/macros/StarRatingsComponent.html +++ b/openlibrary/macros/StarRatingsComponent.html @@ -3,12 +3,11 @@ $ rounded_avg = "%.1f" % ratings_average $ formatted_ratings_count = "{:,}".format(ratings_count) if ratings_count else "" $ ratings_label = _('rating') if ratings_count == 1 else _('ratings') -$ star_class = 'readers-stats__star' if page_type == 'book_page' else 'readers-stats__star--byline' -$ half_star_class = 'readers-stats__star--half' if page_type == 'book_page' else 'readers-stats__star--byline-half' +$ small = "star--small" if page_type != 'book_page' else '' $if ratings_average: $ stats_decimal = (float(ratings_average) - int(ratings_average)) - $:(''.format(star_class) * int(ratings_average)) + $:(''.format(small) * int(ratings_average)) $if (stats_decimal >= 0.5) and (stats_decimal < 1): - $:(''.format(half_star_class)) + $:_('%(ratings_avg)s (%(ratings_count)s %(ratings_label)s)', ratings_avg=rounded_avg, ratings_count=formatted_ratings_count, ratings_label=ratings_label) diff --git a/openlibrary/macros/StarRatingsStats.html b/openlibrary/macros/StarRatingsStats.html index a4d1ac594f0c..c09db1a12566 100644 --- a/openlibrary/macros/StarRatingsStats.html +++ b/openlibrary/macros/StarRatingsStats.html @@ -7,22 +7,19 @@ $ want_to_read_count = "{:,}".format(stats_by_bookshelf.get('want-to-read', 0)) $ currently_reading_count = "{:,}".format(stats_by_bookshelf.get('currently-reading', 0)) $ already_read_count = "{:,}".format(stats_by_bookshelf.get('already-read', 0)) +$ review_count_class = 'readers-stats__review-count--none' if ratings_count == 0 else '' $ id = '--mobile' if mobile else '' diff --git a/static/css/components/readerStats.less b/static/css/components/readerStats.less index 348af6aaa665..8bf08cf7136b 100644 --- a/static/css/components/readerStats.less +++ b/static/css/components/readerStats.less @@ -3,6 +3,21 @@ * https://github.com/internetarchive/openlibrary/wiki/Design-Pattern-Library#readerstats */ +.star { + color: @gold; + font-size: 1.5em; + &__small { + font-size: 1em; + } + &--half { + color: @gold; + margin: 0 0 0 -5px; + background: linear-gradient(90deg, @gold 50%, @light-grey 50%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + } +} + .readers-stats { color: @grey; font-size: @font-size-label-large; @@ -12,7 +27,7 @@ display: inline-block; padding-bottom: 10px; - &:not(:last-child):after { + &:not(:first-child,:last-child):after { content: "·"; margin: 0 4px; } @@ -22,24 +37,4 @@ display: inline-block; margin: 0 4px; } - - &__star { - color: @gold; - font-size: 1.5em; - } - &__star--half { - color: @gold; - margin: 0 0 0 -5px; - background: linear-gradient(90deg, @gold 50%, @light-grey 50%); - -webkit-background-clip: text; - -webkit-text-fill-color: transparent; - } - &__star--byline { - color: @gold; - font-size: 1em; - } - &__star--byline-half { - color: @gold; - font-size: 1em; - } }