1
- import {
2
- WebCellProps ,
3
- component ,
4
- mixin ,
5
- attribute ,
6
- watch ,
7
- createCell
8
- } from 'web-cell' ;
9
-
10
- import { Status } from '../../utility/constant' ;
11
- import style from './index.less' ;
1
+ import { computed , observable } from 'mobx' ;
2
+ import { WebCell , attribute , component , observer } from 'web-cell' ;
3
+
4
+ import { Status } from './type' ;
12
5
13
6
interface TimeUnit {
14
7
scale : number ;
@@ -22,24 +15,24 @@ interface TimeSection {
22
15
23
16
const colors = Object . keys ( Status ) . slice ( 0 , 4 ) ;
24
17
25
- export interface CountDownProps extends WebCellProps {
18
+ export interface CountDownProps {
26
19
endTime ?: string | Date | number ;
27
20
}
28
21
29
- @ component ( {
30
- tagName : 'count-down' ,
31
- renderTarget : 'children'
32
- } )
33
- export class CountDown extends mixin < CountDownProps > ( ) {
22
+ export interface CountDown extends WebCell < CountDownProps > { }
23
+
24
+ @ component ( { tagName : 'count-down' } )
25
+ @ observer
26
+ export class CountDown extends HTMLElement implements WebCell < CountDownProps > {
34
27
@attribute
35
- @watch
36
- endTime : CountDownProps [ 'endTime' ] = Date . now ( ) ;
28
+ @observable
29
+ accessor endTime : CountDownProps [ 'endTime' ] = Date . now ( ) ;
37
30
38
- @watch
39
- rest = 0 ;
31
+ @observable
32
+ accessor rest = 0 ;
40
33
41
- @watch
42
- units : TimeUnit [ ] = [
34
+ @observable
35
+ accessor units : TimeUnit [ ] = [
43
36
{
44
37
scale : 24 ,
45
38
label : 'D'
@@ -58,6 +51,7 @@ export class CountDown extends mixin<CountDownProps>() {
58
51
}
59
52
] ;
60
53
54
+ @computed
61
55
get timeSections ( ) {
62
56
var { rest } = this ;
63
57
@@ -105,7 +99,9 @@ export class CountDown extends mixin<CountDownProps>() {
105
99
< ol className = "list-inline text-white" >
106
100
{ this . timeSections . map ( ( { value, label } , index ) => (
107
101
< li
108
- className = { `list-inline-item display-4 bg-${ colors [ index ] } ${ style . section } ` }
102
+ key = { value }
103
+ className = { `list-inline-item display-4 bg-${ colors [ index ] } d-inline-flex align-items-center justify-content-center rounded-5` }
104
+ style = { { width : '5.5rem' , height : '5.5rem' } }
109
105
>
110
106
< small >
111
107
{ ( value + '' ) . padStart ( 2 , '0' ) }
0 commit comments