diff --git a/package.json b/package.json index 2c1d834a..189216c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "boot-cell", - "version": "2.0.0-beta.11", + "version": "2.0.0-beta.12", "license": "LGPL-3.0", "author": "shiy2008@gmail.com", "description": "Web Components UI library based on WebCell v3, BootStrap v5, BootStrap Icon v1 & FontAwesome v6", diff --git a/v1/Calendar/CountDown/index.tsx b/source/CountDown.tsx similarity index 73% rename from v1/Calendar/CountDown/index.tsx rename to source/CountDown.tsx index 9823c431..982cf732 100644 --- a/v1/Calendar/CountDown/index.tsx +++ b/source/CountDown.tsx @@ -1,14 +1,7 @@ -import { - WebCellProps, - component, - mixin, - attribute, - watch, - createCell -} from 'web-cell'; - -import { Status } from '../../utility/constant'; -import style from './index.less'; +import { computed, observable } from 'mobx'; +import { WebCell, attribute, component, observer } from 'web-cell'; + +import { Status } from './type'; interface TimeUnit { scale: number; @@ -22,24 +15,24 @@ interface TimeSection { const colors = Object.keys(Status).slice(0, 4); -export interface CountDownProps extends WebCellProps { +export interface CountDownProps { endTime?: string | Date | number; } -@component({ - tagName: 'count-down', - renderTarget: 'children' -}) -export class CountDown extends mixin() { +export interface CountDown extends WebCell {} + +@component({ tagName: 'count-down' }) +@observer +export class CountDown extends HTMLElement implements WebCell { @attribute - @watch - endTime: CountDownProps['endTime'] = Date.now(); + @observable + accessor endTime: CountDownProps['endTime'] = Date.now(); - @watch - rest = 0; + @observable + accessor rest = 0; - @watch - units: TimeUnit[] = [ + @observable + accessor units: TimeUnit[] = [ { scale: 24, label: 'D' @@ -58,6 +51,7 @@ export class CountDown extends mixin() { } ]; + @computed get timeSections() { var { rest } = this; @@ -105,7 +99,9 @@ export class CountDown extends mixin() {
    {this.timeSections.map(({ value, label }, index) => (
  1. {(value + '').padStart(2, '0')} diff --git a/source/index.ts b/source/index.ts index 2ac23f46..7f9a9c68 100644 --- a/source/index.ts +++ b/source/index.ts @@ -19,4 +19,5 @@ export * from './Carousel'; export * from './Nav'; export * from './Navbar'; export * from './Offcanvas'; +export * from './CountDown'; export * from './MonthCalendar'; diff --git a/v1/Calendar/CountDown/index.less b/v1/Calendar/CountDown/index.less deleted file mode 100644 index ec596de2..00000000 --- a/v1/Calendar/CountDown/index.less +++ /dev/null @@ -1,8 +0,0 @@ -.section { - display: inline-flex; - align-items: center; - justify-content: center; - width: 5.5rem; - height: 5.5rem; - border-radius: 10px; -}