uploads: allow changing thumbnail size on My Uploads / All Uploads pages.
* Add a "Size" menu to the My Uploads / All Uploads pages to allow changing the thumbnail size. * Make the My Uploads / All Uploads pages use the same thumbnail size as the post index page. * Change the "Gallery | Table" links on the My Uploads page to icons.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationComponent < ViewComponent::Base
|
||||
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :external_link_to, :tag_class, to: :helpers
|
||||
delegate :edit_icon, :delete_icon, :undelete_icon, :flag_icon, :upvote_icon, :downvote_icon, :link_icon, :sticky_icon, :unsticky_icon, :hashtag_icon, to: :helpers
|
||||
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :external_link_to, :tag_class, :current_page_path, to: :helpers
|
||||
delegate :edit_icon, :delete_icon, :undelete_icon, :flag_icon, :upvote_icon, :downvote_icon, :link_icon, :sticky_icon, :unsticky_icon, :hashtag_icon, :caret_down_icon, to: :helpers
|
||||
|
||||
def policy(subject)
|
||||
Pundit.policy!(current_user, subject)
|
||||
|
||||
11
app/components/preview_size_menu_component.rb
Normal file
11
app/components/preview_size_menu_component.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# The dropdown menu for selecting the thumbnail size. Used on the post index
|
||||
# page, the upload index page, and the media assets index page.
|
||||
class PreviewSizeMenuComponent < ApplicationComponent
|
||||
attr_reader :current_size
|
||||
|
||||
def initialize(current_size:)
|
||||
@current_size = current_size.to_i
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
<%= render PopupMenuComponent.new(classes: "preview-size-menu") do |menu| %>
|
||||
<% menu.button do %>
|
||||
<span class="text-sm">Size <%= caret_down_icon %></span>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<%= link_to "Small", current_page_path(size: 150), class: ("font-bold" if current_size == 150), rel: "nofollow" %>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<%= link_to "Medium", current_page_path(size: 180), class: ("font-bold" if current_size == 180), rel: "nofollow" %>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<%= link_to "Large", current_page_path(size: 225), class: ("font-bold" if current_size == 225), rel: "nofollow" %>
|
||||
<% end %>
|
||||
|
||||
<%# Mobile only %>
|
||||
<% menu.item do %>
|
||||
<%= link_to "Huge", current_page_path(size: 360), class: ["mobile-only", ("font-bold" if current_size == 360)], rel: "nofollow" %>
|
||||
<% end %>
|
||||
|
||||
<%# Desktop only %>
|
||||
<% menu.item do %>
|
||||
<%= link_to "Huge", current_page_path(size: 270), class: ["desktop-only", ("font-bold" if current_size == 270)], rel: "nofollow" %>
|
||||
<% end %>
|
||||
|
||||
<%# Desktop only %>
|
||||
<% menu.item do %>
|
||||
<%= link_to "Gigantic", current_page_path(size: 360), class: ["desktop-only", ("font-bold" if current_size == 360)], rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -0,0 +1 @@
|
||||
../../javascript/src/javascripts/preview_size_menu_component.js
|
||||
Reference in New Issue
Block a user