Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions com.woltlab.wcf/templates/contentInteraction.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
{/capture}
{assign var='__contentInteractionShareButton' value=$__contentInteractionShareButton|trim}

{if $__contentInteractionPagination || $__contentInteractionButtons || $__contentInteractionDropdownItems || $__contentInteractionShareButton}
<div class="contentInteraction">
{if $__contentInteractionPagination}
{if $contentInteractionTabsComponent|isset || $__contentInteractionPagination || $__contentInteractionButtons || $__contentInteractionDropdownItems || $__contentInteractionShareButton}
<div class="contentInteraction{if $contentInteractionTabsComponent|isset} contentInteraction--withTabs{/if}">
{if $contentInteractionTabsComponent|isset}
{unsafe:$contentInteractionTabsComponent->render()}
{elseif $__contentInteractionPagination}
<div class="contentInteractionPagination paginationTop">
{@$__contentInteractionPagination}
</div>
Expand Down
13 changes: 13 additions & 0 deletions com.woltlab.wcf/templates/shared_contentInteractionTabs.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<ul class="contentInteractionTabs">
{foreach from=$tabs item='tab'}
<li class="contentInteractionTab{if $tab->active} contentInteractionTab--active{/if}">
<a
href="{$tab->link}"
class="contentInteractionTab__link"
{if $tab->active} aria-current="page"{/if}
>
{lang}{$tab->title}{/lang}

This comment was marked as resolved.

</a>
</li>
{/foreach}
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace wcf\system\view\component;

use wcf\system\WCF;

/**
* Represents the component of the tabs shown in the content interaction section.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class ContentInteractionTabsComponent
{
/**
* @var list<ContentInteractionTab>
*/
private array $tabs = [];

public function addTab(string $title, string $link, bool $active = false): void
{
if ($active && $this->getActiveTab() !== null) {
throw new \BadMethodCallException("The tab '{$this->getActiveTab()->link}' is already marked as active");
}

$this->tabs[] = new ContentInteractionTab($title, $link, $active);

This comment was marked as resolved.

}

private function getActiveTab(): ?ContentInteractionTab
{
return \array_find($this->tabs, static fn($tab) => $tab->active);
}

public function render(): string
{
if (!$this->tabs === []) {
return '';
}

return WCF::getTPL()->render(
'wcf',
'shared_contentInteractionTabs',
[
'tabs' => $this->tabs,
],
);
}
}

/** @internal */
final class ContentInteractionTab
{
public function __construct(
public readonly string $title,
public readonly string $link,
public readonly bool $active,
) {}
}
66 changes: 61 additions & 5 deletions wcfsetup/install/files/style/layout/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,7 @@ fieldset {

.contentInteraction {
display: flex;
justify-content: space-between;
margin-top: 20px;

@include screen-xs {
flex-wrap: wrap;
}
}

.contentInteractionPagination {
Expand Down Expand Up @@ -520,6 +515,9 @@ fieldset {
}

.content {
container-type: inline-size;
container-name: content;

.contentInteraction + .section,
.contentInteraction + form {
margin-top: 20px;
Expand Down Expand Up @@ -571,3 +569,61 @@ fieldset {
}
}
}

.contentInteraction--withTabs {
border-bottom: solid 1px var(--wcfContentBorderInner);
}

.contentInteractionTabs {
display: flex;
gap: 10px;
}

.contentInteractionTab {
display: flex;
white-space: nowrap;
}

.contentInteractionTab__link {
display: flex;
padding: 5px 10px;
color: var(--wcfContentDimmedText);
font-size: var(--wcfFontSizeSection);
font-weight: 600;
position: relative;
}

.contentInteractionTab__link::after {
content: "";
left: 0;
right: 0;
bottom: -1px;
position: absolute;
height: 3px;
}

.contentInteractionTab--active .contentInteractionTab__link {
color: var(--wcfContentText);
}

.contentInteractionTab__link:hover {
color: var(--wcfContentText);
}

.contentInteractionTab__link:hover::after {
background-color: var(--wcfContentBorderInner);
}

.contentInteractionTab--active .contentInteractionTab__link::after {
background-color: var(--wcfTabularBoxHeadline);
}

@container content (width < 800px) {
.contentInteraction {
flex-direction: column;
}

.contentInteractionButtonContainer {
order: -1;
}
}