~sirn/fanboi2

ref: 5b482cfc1bfb0bb1e89715cb57c7bac864391768 fanboi2/assets/app/javascripts/views/board_view.ts -rw-r--r-- 1.0 KiB
5b482cfcKridsada Thanabulpong 0.30.0 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {VNode, h} from 'virtual-dom';
import {Board} from '../models/board';


export class BoardView {
    boardNode: VNode;

    constructor(board: Board) {
        this.boardNode = BoardView.renderBoard(board);
    }

    render(): VNode {
        return this.boardNode;
    }

    private static renderBoard(board: Board): VNode {
        return h('div', {className: 'js-board'}, [
            h('div', {className: 'cascade'}, [
                h('div', {className: 'container'}, [
                    BoardView.renderTitle(board),
                    BoardView.renderDescription(board),
                ])
            ])
        ]);
    }

    private static renderTitle(board: Board): VNode {
        return h('div', {className: 'cascade-header'}, [
            h('a', {
                className: 'cascade-header-link',
                href: `/${board.slug}/`
            }, [board.title])
        ]);
    }

    private static renderDescription(board: Board): VNode {
        return h('div', {className: 'cascade-body'}, [board.description]);
    }
}