Skip to content

Commit 0ca99dc

Browse files
feat: improve extensibility of WelcomeHero (#4199)
1 parent 12fc3ae commit 0ca99dc

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

framework/core/js/src/forum/components/WelcomeHero.tsx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,43 @@ export default class WelcomeHero extends Component<IWelcomeHeroAttrs> {
2626

2727
return (
2828
<header className="Hero WelcomeHero">
29-
<div className="container">
30-
<Button
31-
icon="fas fa-times"
32-
onclick={slideUp}
33-
className="Hero-close Button Button--icon Button--link"
34-
aria-label={app.translator.trans('core.forum.welcome_hero.hide')}
35-
/>
36-
37-
<div className="containerNarrow">{this.welcomeItems().toArray()}</div>
38-
</div>
29+
<div className="container">{this.viewItems().toArray()}</div>
3930
</header>
4031
);
4132
}
4233

34+
viewItems(): ItemList<Mithril.Children> {
35+
const items = new ItemList<Mithril.Children>();
36+
37+
const slideUp = () => {
38+
this.$().slideUp(this.hide.bind(this));
39+
};
40+
41+
items.add(
42+
'dismiss-button',
43+
<Button
44+
icon="fas fa-times"
45+
onclick={slideUp}
46+
className="Hero-close Button Button--icon Button--link"
47+
aria-label={app.translator.trans('core.forum.welcome_hero.hide')}
48+
/>,
49+
100
50+
);
51+
52+
items.add('content', <div className="containerNarrow">{this.contentItems().toArray()}</div>, 80);
53+
54+
return items;
55+
}
56+
57+
contentItems(): ItemList<Mithril.Children> {
58+
const items = new ItemList<Mithril.Children>();
59+
60+
items.add('title', <h1 className="Hero-title">{app.forum.attribute('welcomeTitle')}</h1>, 100);
61+
items.add('subtitle', <div className="Hero-subtitle">{m.trust(app.forum.attribute('welcomeMessage'))}</div>);
62+
63+
return items;
64+
}
65+
4366
/**
4467
* Hide the welcome hero.
4568
*/
@@ -58,13 +81,4 @@ export default class WelcomeHero extends Component<IWelcomeHeroAttrs> {
5881

5982
return false;
6083
}
61-
62-
welcomeItems(): ItemList<Mithril.Children> {
63-
const items = new ItemList<Mithril.Children>();
64-
65-
items.add('hero-title', <h1 className="Hero-title">{app.forum.attribute('welcomeTitle')}</h1>, 20);
66-
items.add('hero-subtitle', <div className="Hero-subtitle">{m.trust(app.forum.attribute('welcomeMessage'))}</div>, 10);
67-
68-
return items;
69-
}
7084
}

0 commit comments

Comments
 (0)