forked from hyoo-ru/realworld.hyoo.ru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrealworld.view.ts
52 lines (41 loc) · 1.28 KB
/
realworld.view.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace $.$$ {
export class $hyoo_realworld extends $.$hyoo_realworld {
article() {
const slug = this.$.$mol_state_arg.value( 'article' )
if( !slug ) return null
return this.$.$hyoo_realworld_article.item( slug )
}
@ $mol_mem
edit() {
return this.$.$mol_state_arg.value( 'edit' ) !== null
}
@ $mol_mem
sign() {
return this.$.$mol_state_arg.value( 'sign' )
}
@ $mol_mem
tag() {
return this.$.$mol_state_arg.value( 'tag' )
}
signed() {
return this.$.$hyoo_realworld_sign.signed()
}
section( name : string ) {
return this.$.$mol_state_arg.value( 'section' ) === name
}
pages() {
return [
this.Menu() ,
... this.section( 'profile' ) ? [ this.Profile() ] : [ ] ,
... this.section( 'articles' ) ? [ this.Feed( '' ) ] : [ ] ,
... this.section( 'tags' ) ? [ this.Tags() ] : [ ] ,
... this.tag() ? [ this.Feed( this.tag() ) ] : [ ] ,
... this.section( 'signin' ) ? [ this.Sign_in() ] : [ ] ,
... this.section( 'signup' ) ? [ this.Sign_up() ] : [ ] ,
... this.article() ? [ this.Article( this.article()?.slug() ) ] : [] ,
... ( this.edit() && this.signed() ) ? [ this.Article_edit( this.article()?.slug() ) ] : [] ,
... ( this.edit() && !this.signed() ) ? [ this.Sign_in() ] : [] ,
]
}
}
}