Skip to content

Commit dbddaa0

Browse files
committed
[migrate] upgrade Count Down component
1 parent 64b062e commit dbddaa0

File tree

4 files changed

+22
-33
lines changed

4 files changed

+22
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "boot-cell",
3-
"version": "2.0.0-beta.11",
3+
"version": "2.0.0-beta.12",
44
"license": "LGPL-3.0",
55
"author": "shiy2008@gmail.com",
66
"description": "Web Components UI library based on WebCell v3, BootStrap v5, BootStrap Icon v1 & FontAwesome v6",

v1/Calendar/CountDown/index.tsx renamed to source/CountDown.tsx

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
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';
125

136
interface TimeUnit {
147
scale: number;
@@ -22,24 +15,24 @@ interface TimeSection {
2215

2316
const colors = Object.keys(Status).slice(0, 4);
2417

25-
export interface CountDownProps extends WebCellProps {
18+
export interface CountDownProps {
2619
endTime?: string | Date | number;
2720
}
2821

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> {
3427
@attribute
35-
@watch
36-
endTime: CountDownProps['endTime'] = Date.now();
28+
@observable
29+
accessor endTime: CountDownProps['endTime'] = Date.now();
3730

38-
@watch
39-
rest = 0;
31+
@observable
32+
accessor rest = 0;
4033

41-
@watch
42-
units: TimeUnit[] = [
34+
@observable
35+
accessor units: TimeUnit[] = [
4336
{
4437
scale: 24,
4538
label: 'D'
@@ -58,6 +51,7 @@ export class CountDown extends mixin<CountDownProps>() {
5851
}
5952
];
6053

54+
@computed
6155
get timeSections() {
6256
var { rest } = this;
6357

@@ -105,7 +99,9 @@ export class CountDown extends mixin<CountDownProps>() {
10599
<ol className="list-inline text-white">
106100
{this.timeSections.map(({ value, label }, index) => (
107101
<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' }}
109105
>
110106
<small>
111107
{(value + '').padStart(2, '0')}

source/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export * from './Carousel';
1919
export * from './Nav';
2020
export * from './Navbar';
2121
export * from './Offcanvas';
22+
export * from './CountDown';
2223
export * from './MonthCalendar';

v1/Calendar/CountDown/index.less

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)