Skip to content

Commit

Permalink
[migrate] upgrade Count Down component
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Feb 6, 2024
1 parent 64b062e commit dbddaa0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "boot-cell",
"version": "2.0.0-beta.11",
"version": "2.0.0-beta.12",
"license": "LGPL-3.0",
"author": "[email protected]",
"description": "Web Components UI library based on WebCell v3, BootStrap v5, BootStrap Icon v1 & FontAwesome v6",
Expand Down
44 changes: 20 additions & 24 deletions v1/Calendar/CountDown/index.tsx → source/CountDown.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<CountDownProps>() {
export interface CountDown extends WebCell<CountDownProps> {}

@component({ tagName: 'count-down' })
@observer
export class CountDown extends HTMLElement implements WebCell<CountDownProps> {
@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'
Expand All @@ -58,6 +51,7 @@ export class CountDown extends mixin<CountDownProps>() {
}
];

@computed
get timeSections() {
var { rest } = this;

Expand Down Expand Up @@ -105,7 +99,9 @@ export class CountDown extends mixin<CountDownProps>() {
<ol className="list-inline text-white">
{this.timeSections.map(({ value, label }, index) => (
<li
className={`list-inline-item display-4 bg-${colors[index]} ${style.section}`}
key={value}
className={`list-inline-item display-4 bg-${colors[index]} d-inline-flex align-items-center justify-content-center rounded-5`}
style={{ width: '5.5rem', height: '5.5rem' }}
>
<small>
{(value + '').padStart(2, '0')}
Expand Down
1 change: 1 addition & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export * from './Carousel';
export * from './Nav';
export * from './Navbar';
export * from './Offcanvas';
export * from './CountDown';
export * from './MonthCalendar';
8 changes: 0 additions & 8 deletions v1/Calendar/CountDown/index.less

This file was deleted.

0 comments on commit dbddaa0

Please sign in to comment.