diff --git a/assets/misuzu.css/forum/float.css b/assets/misuzu.css/forum/float.css new file mode 100644 index 00000000..4d1aaf10 --- /dev/null +++ b/assets/misuzu.css/forum/float.css @@ -0,0 +1,12 @@ +.forum-float { + position: sticky; + z-index: 1000; +} + +.forum-float-top { + top: 2px; +} + +.forum-float-bottom { + bottom: 2px; +} diff --git a/assets/misuzu.css/forum/status.css b/assets/misuzu.css/forum/status.css index 176f7d1c..958962ed 100644 --- a/assets/misuzu.css/forum/status.css +++ b/assets/misuzu.css/forum/status.css @@ -3,6 +3,7 @@ align-items: center; min-height: 40px; margin: 2px 0; + position: sticky; } .forum__status__icon { diff --git a/assets/misuzu.css/main.css b/assets/misuzu.css/main.css index d761e8a0..f79865d8 100644 --- a/assets/misuzu.css/main.css +++ b/assets/misuzu.css/main.css @@ -150,6 +150,7 @@ html { @include forum/actions.css; @include forum/categories.css; @include forum/confirm.css; +@include forum/float.css; @include forum/header.css; @include forum/leaderboard.css; @include forum/poll.css; diff --git a/templates/forum/forum.twig b/templates/forum/forum.twig index 52d52af6..59649b84 100644 --- a/templates/forum/forum.twig +++ b/templates/forum/forum.twig @@ -1,4 +1,5 @@ {% extends 'forum/master.twig' %} +{% from 'macros.twig' import pagination %} {% from 'forum/macros.twig' import forum_category_listing, forum_topic_listing, forum_category_buttons, forum_header, forum_category_tools %} {% set title = forum_info.name %} @@ -8,29 +9,45 @@ }) %} {% block content %} - {{ forum_header(forum_info.name, forum_breadcrumbs, true, canonical_url, [ - { - html: '<i class="far fa-check-circle"></i> <span class="js-action-text">Mark as Read</span>', - display: forum_show_mark_as_read, - method: 'POST', - url: url('forum-mark-as-read', { category: forum_info.id }), - disableWith: 'Marking as read...', - disableWithTarget: '.js-action-text', - withCsrf: true, - refreshOnSuccess: true, - } - ]) }} + <div class="forum-float forum-float-top"> + {{ forum_header(forum_info.name, forum_breadcrumbs, true, canonical_url, [ + { + html: '<i class="far fa-check-circle"></i> <span class="js-action-text">Mark as Read</span>', + display: forum_show_mark_as_read, + method: 'POST', + url: url('forum-mark-as-read', { category: forum_info.id }), + disableWith: 'Marking as read...', + disableWithTarget: '.js-action-text', + withCsrf: true, + refreshOnSuccess: true, + } + ]) }} + </div> {% if forum_children|length > 0 %} {{ forum_category_listing(forum_children, 'Forums') }} {% endif %} {% if forum_info.mayHaveTopics %} - {% set category_tools = forum_category_tools(forum_info, forum_perms, forum_pagination) %} - {{ category_tools }} - {{ forum_topic_listing(forum_topics) }} - {{ category_tools }} - {% endif %} + {% set can_topic = not forum_info.archived and forum_perms.can_create_topic %} + {% set topics_pagination = pagination(forum_pagination, 'forum-category', {'forum': forum_info.id}) %} - {{ forum_header('', forum_breadcrumbs) }} + {{ forum_topic_listing(forum_topics) }} + + {% if can_topic or topics_pagination|trim|length > 0 %} + <div class="forum-float forum-float-bottom"> + <div class="container forum__actions"> + <div class="forum__actions__buttons"> + {% if can_topic %} + <a href="{{ url('forum-topic-new', {'forum': forum_info.id}) }}" class="input__button forum__actions__button">New Topic</a> + {% endif %} + </div> + + <div class="forum__actions__pagination"> + {{ topics_pagination }} + </div> + </div> + </div> + {% endif %} + {% endif %} {% endblock %} diff --git a/templates/forum/macros.twig b/templates/forum/macros.twig index c0aef375..67bdb009 100644 --- a/templates/forum/macros.twig +++ b/templates/forum/macros.twig @@ -81,36 +81,6 @@ </div> {% endmacro %} -{% macro forum_category_tools(info, perms, pagination_info) %} - {% from 'macros.twig' import pagination %} - - {% if info.forum_id is defined %} - {% set forum_id = info.forum_id %} - {% set is_archived = info.forum_archived != 0 %} - {% else %} - {% set forum_id = info.id %} - {% set is_archived = info.archived %} - {% endif %} - - {% set is_locked = is_archived %} - {% set can_topic = not is_locked and perms.can_create_topic %} - {% set pag = pagination(pagination_info, 'forum-category', {'forum': forum_id}) %} - - {% if can_topic or pag|trim|length > 0 %} - <div class="container forum__actions"> - <div class="forum__actions__buttons"> - {% if can_topic %} - <a href="{{ url('forum-topic-new', {'forum': forum_id}) }}" class="input__button forum__actions__button">New Topic</a> - {% endif %} - </div> - - <div class="forum__actions__pagination"> - {{ pag }} - </div> - </div> - {% endif %} -{% endmacro %} - {% macro forum_topic_tools(info, pagination_info, can_reply) %} {% from 'macros.twig' import pagination %} @@ -283,33 +253,6 @@ </div> {% endmacro %} -{% macro forum_topic_redirect(redirect) %} - {% from _self import forum_topic_notice %} - {% if redirect is not empty %} - {% set body %} - This topic redirects to <span class="forum__status__emphasis"><a href="{{ redirect.linkTarget }}" class="link">{{ redirect.linkTarget }}</a></span>. - {% endset %} - {{ forum_topic_notice('share', body) }} - {% endif %} -{% endmacro %} - -{% macro forum_topic_locked(locked, archived) %} - {% from _self import forum_topic_notice %} - {% if locked is not null or archived %} - {% set body %} - {% if archived %} - This topic has been <span class="forum__status__emphasis">archived</span>. - {% else %} - This topic was locked - <time class="forum__status__emphasis" - datetime="{{ locked|date('c') }}" - title="{{ locked|date('r') }}">{{ locked|time_format }}</time>. - {% endif %} - {% endset %} - {{ forum_topic_notice(archived ? 'archive' : 'lock', body) }} - {% endif %} -{% endmacro %} - {% macro forum_topic_listing(topics, title) %} {% from _self import forum_topic_entry %} {% from 'macros.twig' import container_title %} diff --git a/templates/forum/topic.twig b/templates/forum/topic.twig index 3a833b57..dc837055 100644 --- a/templates/forum/topic.twig +++ b/templates/forum/topic.twig @@ -1,15 +1,6 @@ {% extends 'forum/master.twig' %} {% from 'macros.twig' import pagination %} -{% - from 'forum/macros.twig' - import - forum_post_listing, - forum_topic_buttons, - forum_topic_locked, - forum_header, - forum_topic_tools, - forum_topic_redirect -%} +{% from 'forum/macros.twig' import forum_post_listing, forum_topic_buttons, forum_topic_notice, forum_header %} {% set title = topic_info.title %} {% set canonical_url = url('forum-topic', { @@ -17,8 +8,6 @@ 'page': topic_pagination.page > 1 ? topic_pagination.page : 0, }) %} -{% set topic_tools = forum_topic_tools(topic_info, topic_pagination, can_reply) %} -{% set topic_notice = forum_topic_locked(topic_info.lockedTime, category_info.archived) ~ forum_topic_redirect(topic_redir_info|default(null)) %} {% set topic_actions = [ { html: '<i class="fas fa-trash-alt fa-fw"></i> <span class="js-action-text">Delete</span>', @@ -86,11 +75,47 @@ ] %} {% block content %} - {{ forum_header(topic_info.title, topic_breadcrumbs, false, canonical_url, topic_actions) }} - {{ topic_notice|raw }} - {{ topic_tools }} + <div class="forum-float forum-float-top"> + {{ forum_header(topic_info.title, topic_breadcrumbs, false, canonical_url, topic_actions) }} + + {% if topic_info.locked or category_info.archived %} + {% set body %} + {% if category_info.archived %} + This topic has been <span class="forum__status__emphasis">archived</span>. + {% else %} + This topic was locked + <time class="forum__status__emphasis" datetime="{{ topic_info.lockedTime|date('c') }}" + title="{{ topic_info.lockedTime|date('r') }}">{{ topic_info.lockedTime|time_format }}</time>. + {% endif %} + {% endset %} + + {{ forum_topic_notice(category_info.archived ? 'archive' : 'lock', body) }} + {% endif %} + + {% if topic_redir_info is defined %} + {% set body %} + This topic redirects to <span class="forum__status__emphasis"><a href="{{ topic_redir_info.linkTarget }}" class="link">{{ topic_redir_info.linkTarget }}</a></span>. + {% endset %} + {{ forum_topic_notice('share', body) }} + {% endif %} + </div> + {{ forum_post_listing(topic_posts, topic_user_id, topic_perms) }} - {{ topic_tools }} - {{ topic_notice|raw }} - {{ forum_header('', topic_breadcrumbs) }} + + <div class="forum-float forum-float-bottom"> + {% set posts_pagination = pagination(topic_pagination, 'forum-topic', {'topic': topic_info.id}) %} + {% if can_reply or posts_pagination|trim|length > 0 %} + <div class="container forum__actions"> + <div class="forum__actions__buttons"> + {% if can_reply %} + <a href="{{ url('forum-reply-new', {'topic': topic_info.id}) }}" class="input__button">Reply</a> + {% endif %} + </div> + + <div class="forum__actions__pagination"> + {{ posts_pagination }} + </div> + </div> + {% endif %} + </div> {% endblock %}