tags: refactor tag lists to use ViewComponent.
This commit is contained in:
@@ -22,4 +22,32 @@ module ComponentsHelper
|
||||
def render_post_navbar(post, **options)
|
||||
render PostNavbarComponent.new(post: post, **options)
|
||||
end
|
||||
|
||||
# A simple vertical tag list with no post counts. Used in related tags.
|
||||
def render_simple_tag_list(tag_names, **options)
|
||||
tags = TagListComponent.tags_from_names(tag_names)
|
||||
render TagListComponent.new(tags: tags, **options).with_variant(:simple)
|
||||
end
|
||||
|
||||
# A horizontal tag list, with tags grouped by category. Used in post
|
||||
# tooltips, on the comments index, and in the modqueue.
|
||||
def render_inline_tag_list(post, **options)
|
||||
render TagListComponent.new(tags: post.tags, **options).with_variant(:inline)
|
||||
end
|
||||
|
||||
def render_inline_tag_list_from_names(tag_names, **options)
|
||||
tags = TagListComponent.tags_from_names(tag_names)
|
||||
render TagListComponent.new(tags: tags, **options).with_variant(:inline)
|
||||
end
|
||||
|
||||
# A vertical tag list, with tags split into categories. Used on post show pages.
|
||||
def render_categorized_tag_list(post, **options)
|
||||
render TagListComponent.new(tags: post.tags, **options).with_variant(:categorized)
|
||||
end
|
||||
|
||||
# A vertical tag list, used in the post index sidebar.
|
||||
def render_search_tag_list(tag_names, **options)
|
||||
tags = TagListComponent.tags_from_names(tag_names)
|
||||
render TagListComponent.new(tags: tags, **options).with_variant(:search)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user