Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] [extensibility] [tags] chore: extensible TagHero #4041

Merged
merged 1 commit into from
Sep 29, 2024
Merged
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
41 changes: 33 additions & 8 deletions extensions/tags/js/src/forum/components/TagHero.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from 'flarum/common/Component';
import textContrastClass from 'flarum/common/helpers/textContrastClass';
import tagIcon from '../../common/helpers/tagIcon';
import classList from 'flarum/common/utils/classList';
import ItemList from 'flarum/common/utils/ItemList';

export default class TagHero extends Component {
view() {
Expand All @@ -13,15 +14,39 @@ export default class TagHero extends Component {
className={classList('Hero', 'TagHero', { 'TagHero--colored': color, [textContrastClass(color)]: color })}
style={color ? { '--hero-bg': color } : undefined}
>
<div className="container">
<div className="containerNarrow">
<h1 className="Hero-title">
{tag.icon() && tagIcon(tag, {}, { useColor: false })} {tag.name()}
</h1>
<div className="Hero-subtitle">{tag.description()}</div>
</div>
</div>
<div className="container">{this.viewItems().toArray()}</div>
</header>
);
}

/**
* @returns {ItemList}
*/
viewItems() {
const items = new ItemList();

items.add('content', <div className="containerNarrow">{this.contentItems().toArray()}</div>, 80);

return items;
}

/**
* @returns {ItemList}
*/
contentItems() {
const items = new ItemList();
const tag = this.attrs.model;

items.add(
'tag-title',
<h1 className="Hero-title">
{tag.icon() && tagIcon(tag, {}, { useColor: false })} {tag.name()}
</h1>,
100
);

items.add('tag-subtitle', <div className="Hero-subtitle">{tag.description()}</div>, 90);

return items;
}
}
Loading