Skip to content

Commit

Permalink
refactor(core): further improve improve extensibility of `PostStreamS…
Browse files Browse the repository at this point in the history
…crubber`
  • Loading branch information
DavideIadeluca committed Sep 18, 2024
1 parent 22d5e4c commit 8131b47
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions framework/core/js/src/forum/components/PostStreamScrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class PostStreamScrubber extends Component {
);
}

scrubberItems(viewing, unreadCount, _unreadPercent, styleUnread) {
scrubberItems(viewing, unreadCount, unreadPercent, styleUnread) {
const items = new ItemList();

items.add(
Expand All @@ -82,21 +82,7 @@ export default class PostStreamScrubber extends Component {

items.add(
'scrollbar',
<div className="Scrubber-scrollbar">
<div className="Scrubber-before" />
<div className="Scrubber-handle">
<div className="Scrubber-bar" />
<div className="Scrubber-info">
<strong>{viewing}</strong>
<span className="Scrubber-description"></span>
</div>
</div>
<div className="Scrubber-after" />

<div className="Scrubber-unread" oncreate={styleUnread} onupdate={styleUnread}>
{app.translator.trans('core.forum.post_scrubber.unread_text', { count: unreadCount })}
</div>
</div>,
<div className="Scrubber-scrollbar">{this.scrollbarItems(viewing, unreadCount, unreadPercent, styleUnread).toArray()}</div>,
90
);

Expand All @@ -111,6 +97,35 @@ export default class PostStreamScrubber extends Component {
return items;
}

scrollbarItems(viewing, unreadCount, _unreadPercent, styleUnread) {
const items = new ItemList();

items.add('before', <div className="Scrubber-before" />, 100);

items.add(
'handle',
<div className="Scrubber-handle">
<div className="Scrubber-bar" />
<div className="Scrubber-info">
<strong>{viewing}</strong>
<span className="Scrubber-description"></span>
</div>
</div>,
90
);

items.add('after', <div className="Scrubber-after" />, 80);

items.add(
'unread',
<div className="Scrubber-unread" oncreate={styleUnread} onupdate={styleUnread}>
{app.translator.trans('core.forum.post_scrubber.unread_text', { count: unreadCount })}
</div>,
70
);

return items;
}
onupdate(vnode) {
super.onupdate(vnode);

Expand Down

0 comments on commit 8131b47

Please sign in to comment.