49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
|
|
/**
|
||
|
|
* @fileoverview Home Page Component for Rantii
|
||
|
|
* @author retoor <retoor@molodetz.nl>
|
||
|
|
* @description Main feed page displaying latest rants
|
||
|
|
* @keywords home, page, feed, main, landing
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { BaseComponent } from '../components/base-component.js';
|
||
|
|
|
||
|
|
class HomePage extends BaseComponent {
|
||
|
|
static get observedAttributes() {
|
||
|
|
return ['sort'];
|
||
|
|
}
|
||
|
|
|
||
|
|
init() {
|
||
|
|
this.render();
|
||
|
|
}
|
||
|
|
|
||
|
|
render() {
|
||
|
|
const sort = this.getAttr('sort') || 'recent';
|
||
|
|
|
||
|
|
this.addClass('page', 'home-page');
|
||
|
|
|
||
|
|
this.setHtml(`
|
||
|
|
<rant-feed sort="${sort}" feed-type="rants"></rant-feed>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
onAttributeChanged(name, oldValue, newValue) {
|
||
|
|
if (name === 'sort') {
|
||
|
|
const feed = this.$('rant-feed');
|
||
|
|
if (feed) {
|
||
|
|
feed.setSort(newValue);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
refresh() {
|
||
|
|
const feed = this.$('rant-feed');
|
||
|
|
if (feed) {
|
||
|
|
feed.refresh();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
customElements.define('home-page', HomePage);
|
||
|
|
|
||
|
|
export { HomePage };
|