From 8841de68ac2c9679282379803a5f69210977891a Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 4 Dec 2021 06:04:13 -0600 Subject: [PATCH] posts: add adjustable thumbnail sizes (#4932). Add a menu in the top right of the post index page that lets you select the thumbnail size. This menu is currently hidden until the new thumbnails have been generated. On desktop, there are five thumbnail sizes: * Small: 150x150 (https://danbooru.donmai.us/posts?size=150) * Medium: 180x180 (https://danbooru.donmai.us/posts?size=180) * Large: 225x225 (https://danbooru.donmai.us/posts?size=225) * Huge: 270x270 (https://danbooru.donmai.us/posts?size=270) * Gigantic: 360x360 (https://danbooru.donmai.us/posts?size=360) On mobile, there are four sizes: * Small: 150x150 / 3 posts per row (https://danbooru.donmai.us/posts?size=150) * Medium: 180x180 / 2 posts per row (https://danbooru.donmai.us/posts?size=180) * Large: 225x225 / 2 posts per row (https://danbooru.donmai.us/posts?size=225) * Huge: 360x360 / 1 posts per row (https://danbooru.donmai.us/posts?size=360) There are two extra sizes that aren't listed in the menu: * 225x360 (https://danbooru.donmai.us/posts?size=225w) * 270x360 (https://danbooru.donmai.us/posts?size=270w) These sizes are good for tall thumbnails, but not so much for wide thumbnails. They aren't listed because in practice they're a bit too big. The 225x225 and 270x270 sizes are really just 360x360 thumbnails scaled down in HTML. This means 225x225 and 360x360 thumbnails both use the same amount of bandwidth. Thumbnail size is currently a per-search option, not a persistent account-level setting. This changes the HTML structure of thumbnails somewhat, so this may break userscripts and custom CSS. --- app/components/popup_menu_component.rb | 9 +- .../popup_menu_component.html.erb | 8 +- .../popup_menu_component.scss | 3 +- app/components/post_gallery_component.rb | 12 +- .../post_gallery_component.html.erb | 4 +- .../post_gallery_component.scss | 32 ++++-- app/components/post_preview_component.rb | 59 +++++++--- .../post_preview_component.html.erb | 12 +- .../post_preview_component.scss | 28 ++--- app/controllers/posts_controller.rb | 2 +- app/helpers/icon_helper.rb | 4 + app/javascript/src/javascripts/posts.js | 13 ++- app/javascript/src/styles/base/020_base.scss | 6 +- .../src/styles/common/utilities.scss | 8 ++ app/views/iqdb_queries/_matches.html.erb | 4 +- app/views/modqueue/_post.html.erb | 2 +- app/views/posts/index.html.erb | 107 ++++++++++++++---- .../posts/partials/index/_posts.html.erb | 2 +- app/views/posts/update.js.erb | 2 +- app/views/uploads/_related_posts.html.erb | 2 +- 20 files changed, 224 insertions(+), 95 deletions(-) diff --git a/app/components/popup_menu_component.rb b/app/components/popup_menu_component.rb index 620a3e33b..8e9021be4 100644 --- a/app/components/popup_menu_component.rb +++ b/app/components/popup_menu_component.rb @@ -2,7 +2,14 @@ class PopupMenuComponent < ApplicationComponent include ViewComponent::SlotableV2 - delegate :ellipsis_icon, to: :helpers + attr_reader :classes + + renders_one :button renders_many :items + + # @param classes [String] A list of CSS classes for the root element. + def initialize(classes: nil) + @classes = classes + end end diff --git a/app/components/popup_menu_component/popup_menu_component.html.erb b/app/components/popup_menu_component/popup_menu_component.html.erb index 7e4904443..c7abca8c3 100644 --- a/app/components/popup_menu_component/popup_menu_component.html.erb +++ b/app/components/popup_menu_component/popup_menu_component.html.erb @@ -1,6 +1,10 @@ -