css: replace more css with tailwind-style classes.

This commit is contained in:
evazion
2022-12-11 17:29:53 -06:00
parent fc7bc64d4c
commit 1c2042285f
20 changed files with 120 additions and 237 deletions

View File

@@ -9,7 +9,7 @@ class PostPreviewComponent < ApplicationComponent
with_collection_parameter :post
attr_reader :post, :tags, :size, :show_deleted, :link_target, :pool, :similarity, :recommended, :show_votes, :fit, :show_size, :save_data, :current_user, :options
attr_reader :post, :tags, :size, :classes, :show_deleted, :link_target, :pool, :similarity, :recommended, :show_votes, :fit, :show_size, :save_data, :current_user, :options
delegate :external_link_to, :time_ago_in_words_tagged, :duration_to_hhmmss, :render_post_votes, :empty_heart_icon, :sound_icon, to: :helpers
delegate :image_width, :image_height, :file_ext, :file_size, :duration, :is_animated?, to: :media_asset
@@ -19,6 +19,7 @@ class PostPreviewComponent < ApplicationComponent
# @param tags [String] The current tag search, if any.
# @param size [String] The size of the thumbnail. One of "150", "180", "225",
# "225w", "270", "270w", or "360".
# param classes [String] A list of CSS classes to apply to the container.
# @param show_deleted [Boolean] If true, show thumbnails for deleted posts.
# If false, hide thumbnails of deleted posts.
# @param show_votes [Boolean] If true, show scores and vote buttons beneath the thumbnail.
@@ -30,11 +31,12 @@ class PostPreviewComponent < ApplicationComponent
# @param fit [Symbol] If `:fixed`, make the thumbnail container a fixed size
# (e.g. 180x180), even if the thumbnail image is smaller than that. If `:compact`,
# make the thumbnail container shrink to the same size as the thumbnail image.
def initialize(post:, tags: "", size: DEFAULT_SIZE, show_deleted: false, show_votes: false, link_target: post, pool: nil, similarity: nil, recommended: nil, show_size: nil, save_data: CurrentUser.save_data, fit: :compact, current_user: CurrentUser.user, **options)
def initialize(post:, tags: "", size: DEFAULT_SIZE, classes: nil, show_deleted: false, show_votes: false, link_target: post, pool: nil, similarity: nil, recommended: nil, show_size: nil, save_data: CurrentUser.save_data, fit: :compact, current_user: CurrentUser.user, **options)
super
@post = post
@tags = tags.presence
@size = size.presence || DEFAULT_SIZE
@classes = classes
@show_deleted = show_deleted
@show_votes = show_votes
@link_target = link_target
@@ -52,7 +54,7 @@ class PostPreviewComponent < ApplicationComponent
post.present? && post.visible?(current_user) && (!post.is_deleted? || show_deleted)
end
def article_attrs(classes = nil)
def article_attrs
{ class: [classes, *preview_class].compact.join(" "), **data_attributes }
end