Skip to content

Commit 555688d

Browse files
authored
release: 8.0.0 (#42)
2 parents c51998a + 8845a99 commit 555688d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+768
-1421
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ indent_size = 2
99
end_of_line = lf
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10.9.0

.prettierrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
2-
"printWidth": 80,
2+
"printWidth": 120,
33
"singleQuote": true,
4-
"trailingComma": "all"
4+
"semi": true,
5+
"trailingComma": "all",
6+
"overrides": [
7+
{
8+
"files": ".prettierrc",
9+
"options": {
10+
"parser": "json"
11+
}
12+
}
13+
]
514
}

.travis.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
sudo: required
2+
dist: trusty
23
language: node_js
3-
node_js:
4-
- '8.11'
5-
6-
addons:
7-
apt:
8-
sources:
9-
- google-chrome
10-
packages:
11-
- google-chrome-stable
12-
- google-chrome-beta
134

145
git:
156
depth: 1
@@ -20,9 +11,18 @@ cache:
2011
- ./node_modules
2112

2213
before_install:
23-
- export CHROME_BIN=chromium-browser
14+
- set -e
2415
- export DISPLAY=:99.0
2516
- sh -e /etc/init.d/xvfb start
17+
- sleep 3
18+
- export NG_CLI_ANALYTICS=ci
19+
20+
addons:
21+
apt:
22+
sources:
23+
- google-chrome
24+
packages:
25+
- google-chrome-stable
2626

2727
env:
2828
- TASK=build

.vscode/settings.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.watcherExclude": {
4+
"**/.git/objects/**": true,
5+
"**/.git/subtree-cache/**": true,
6+
"**/node_modules/*/**": true,
7+
"**/dist/*/**": true,
8+
"**/coverage/*/**": true
9+
},
10+
"editor.formatOnSave": true,
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll": true
13+
},
14+
"[markdown]": {
15+
"editor.formatOnSave": false
16+
},
17+
"[javascript]": {
18+
"editor.formatOnSave": false
19+
},
20+
"[json]": {
21+
"editor.formatOnSave": false
22+
},
23+
"[jsonc]": {
24+
"editor.formatOnSave": false
25+
},
26+
"files.associations": {
27+
"*.json": "jsonc",
28+
".prettierrc": "json",
29+
".stylelintrc": "json"
30+
}
31+
}

README.md

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Simple, easy and performance countdown for angular
44

55
[![NPM version](https://img.shields.io/npm/v/ngx-countdown.svg)](https://www.npmjs.com/package/ngx-countdown)
66
[![Build Status](https://travis-ci.org/cipchk/ngx-countdown.svg?branch=master)](https://travis-ci.org/cipchk/ngx-countdown)
7-
[![codecov](https://codecov.io/gh/cipchk/ngx-countdown/branch/master/graph/badge.svg)](https://codecov.io/gh/cipchk/ngx-countdown)
87

98
## Demo
109

@@ -25,80 +24,83 @@ import `CountdownModule`。
2524
import { CountdownModule } from 'ngx-countdown';
2625

2726
@NgModule({
28-
imports: [ BrowserModule, CountdownModule ],
29-
declarations: [AppComponent],
30-
bootstrap: [AppComponent]
27+
imports: [ BrowserModule, CountdownModule ],
28+
declarations: [AppComponent],
29+
bootstrap: [AppComponent]
3130
})
3231
export class AppModule { }
3332
```
3433

3534
### 2、Template
3635

3736
```html
38-
<countdown [config]="config"
39-
(start)="onStart()"
40-
(finished)="onFinished()"
41-
(notify)="onNotify($event)"></countdown>
37+
<countdown #cd [config]="config" (event)="handleEvent($event)"></countdown>
4238
```
4339

44-
| Name | Type | Default | Summary |
45-
| ------- | ------------- | ----- | ----- |
46-
| `config` | Config | - | see Config |
47-
| `begin()` | - | - | Triggers when `{demand: false}` |
48-
| `restart()` | - | - | - |
49-
| `stop()` | - | - | - |
50-
| `pause()` | - | - | - |
51-
| `resume()` | - | - | - |
52-
| `start` | `EventEmitter` | - | Triggers when start |
53-
| `finished` | `EventEmitter` | - | Triggers when finished |
54-
| `notify` | `EventEmitter(time: number)` | - | Triggers when notify, need setting `config.notify` values |
55-
| `event` | `EventEmitter<{ action: string, left: number }>` | - | Catch all event |
40+
**Method**
41+
42+
| Name | Description |
43+
|-------------|------------------------------------------------------------------------------------------------|
44+
| `begin()` | Start countdown, you must manually call when `demand: false` |
45+
| `restart()` | Restart countdown |
46+
| `stop()` | Stop countdown, must call `restart` when stopped, it's different from pause, unable to recover |
47+
| `pause()` | Pause countdown, you can use `resume` to recover again |
48+
| `resume()` | Resume countdown |
5649

5750
**How call component methods**
5851

59-
```typescript
60-
@ViewChild(CountdownComponent) counter: CountdownComponent;
61-
resetTimer(){
62-
this.counter.restart();
63-
this.counter.stop();
64-
this.counter.pause();
65-
this.counter.resume();
66-
}
52+
```ts
53+
@ViewChild('cd', { static: false }) private countdown: CountdownComponent;
54+
this.countdown.begin();
6755
```
6856

69-
## Config
57+
## API
58+
59+
### countdown
60+
61+
| Name | Type | Default | Summary |
62+
|----------|--------------------------------|---------|---------|
63+
| `config` | `CountdownConfig` | - | Config |
64+
| `event` | `EventEmitter<CountdownEvent>` | - | Events |
65+
66+
### CountdownConfig
7067

7168
| Name | Type | Default | Summary |
7269
| ------- | ------------- | ----- | ----- |
73-
| demand | boolean | `false` | start the counter on demand, must call `begin()` to starting |
74-
| template | string | `$!h!时$!m!分$!s!秒` | Custom render template, if is empty use the `<ng-content>` content, and `$!s-ext!` it's `0.1s` accuracy |
75-
| leftTime | number | 0 | Calculate the remaining time based on the server, e.g: `10`,`5.5`(May be dropped frames) (Unit: seconds) |
76-
| stopTime | number | 0 | 结束时间:指的是根据本地时间至结束时间进行倒计时。(单位:UNIX时间戳 ms) |
77-
| varRegular | RegExp | `/\$\{([\-\w]+)\}/g` | 模板解析正则表达式,有时候由于模板结构比较特殊,无法根据默认的表达式进行解析,那就需要修改它。 |
78-
| clock | Array | | 时钟控制数组,特殊需求时可以修改,里面是三元组:指针名、进制、位数,可参考大于99小时demo |
79-
| notify | number[] | | 第xx秒时调用 notify 函数,值必须是**正整数** |
80-
| repaint | Function | | Custom repaintes |
70+
| demand | `boolean` | `false` | Start the counter on demand, must call `begin()` to starting |
71+
| leftTime | `number` | `0` | Calculate the remaining time based on the server, e.g: `10`,`5.5`, (Unit: seconds) |
72+
| stopTime | `number` | - | Refers to counting down from local time to end time (Unit: Milliseconds second UNIX timestamp) |
73+
| format | `string` | `HH:mm:ss` | Formats a date value, pls refer to [Accepted patterns](https://angular.io/api/common/DatePipe#usage-notes) |
74+
| prettyText | `(text: string) => string` | - | Beautify text, generally used to convert formatted time text into HTML |
75+
| notify | `number[] | number` | - | Should be trigger type `notify` event on the x second. When values is `0` will be trigger every time |
76+
| formatDate | `CountdownFormatFn` | - | Default based on the implementation of `formatDate` in `@angular/common`, You can changed to other libs, e.g: [date-fns](https://date-fns.org/v2.0.1/docs/format) |
77+
| timezone | `string` | `+0000` | A timezone offset (such as '+0430'), or a standard UTC/GMT. When not supplied, uses the end-user's local system timezone |
78+
79+
### CountdownEvent
80+
81+
| Name | Type | Summary |
82+
|----------|-----------------------------------------------|----------------------------------|
83+
| `action` | `start,stop,restart,pause,resume,notify,done` | Action of the event |
84+
| `status` | `CountdownStatus` | Status of the countdown |
85+
| `left` | `number` | Number of remaining milliseconds |
86+
| `text` | `string` | Format the text |
8187

8288
**Global Config**
8389

8490
```ts
85-
function countdownConfigFactory(): Config {
86-
return { template: `$!h!:$!m!:$!s!` };
91+
function countdownConfigFactory(): CountdownGlobalConfig {
92+
return { format: `mm:ss` };
8793
}
8894

8995
@NgModule({
9096
imports: [ CountdownModule ],
9197
providers: [
92-
{ provide: CountdownConfig, useFactory: countdownConfigFactory }
98+
{ provide: CountdownGlobalConfig, useFactory: countdownConfigFactory }
9399
],
94100
})
95101
export class AppDemoModule {}
96102
```
97103

98-
## About repaints
99-
100-
The timer will call repaint function every time, if it's `0.1s` accuracy, it will be more frequent. so you can make same special effects, like [Flip](https://cipchk.github.io/ngx-countdown/#/tpl/flip).
101-
102104
## Troubleshooting
103105

104106
Please follow this guidelines when reporting bugs and feature requests:

angular.json

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"polyfills": "src/polyfills.ts",
1919
"assets": ["src/assets"],
2020
"styles": [
21-
"node_modules/bootstrap/dist/css/bootstrap.css",
22-
"node_modules/ngx-toastr/toastr.css"
21+
"node_modules/bootstrap/dist/css/bootstrap.css"
2322
],
2423
"scripts": []
2524
},
@@ -54,12 +53,6 @@
5453
}
5554
}
5655
},
57-
"extract-i18n": {
58-
"builder": "@angular-devkit/build-angular:extract-i18n",
59-
"options": {
60-
"browserTarget": "ngx-countdown:build"
61-
}
62-
},
6356
"test": {
6457
"builder": "@angular-devkit/build-angular:karma",
6558
"options": {
@@ -80,27 +73,6 @@
8073
}
8174
}
8275
}
83-
},
84-
"ngx-countdown-e2e": {
85-
"root": "",
86-
"sourceRoot": "",
87-
"projectType": "application",
88-
"architect": {
89-
"e2e": {
90-
"builder": "@angular-devkit/build-angular:protractor",
91-
"options": {
92-
"protractorConfig": "protractor.conf.js",
93-
"devServerTarget": "ngx-countdown:serve"
94-
}
95-
},
96-
"lint": {
97-
"builder": "@angular-devkit/build-angular:tslint",
98-
"options": {
99-
"tsConfig": [],
100-
"exclude": ["**/node_modules/**"]
101-
}
102-
}
103-
}
10476
}
10577
},
10678
"defaultProject": "ngx-countdown",

lib/index.ts

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

lib/karma.conf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function (config) {
1717
},
1818
coverageIstanbulReporter: {
1919
dir: require('path').join(__dirname, '../coverage'),
20-
dir: require('path').join(__dirname, 'coverage'), reports: ['html', 'lcovonly'],
20+
reports: ['html', 'lcovonly', 'text-summary'],
2121
fixWebpackSourcePaths: true
2222
},
2323
reporters: ['progress', 'kjhtml'],
@@ -26,6 +26,7 @@ module.exports = function (config) {
2626
logLevel: config.LOG_INFO,
2727
autoWatch: true,
2828
browsers: ['Chrome'],
29-
singleRun: false
29+
singleRun: false,
30+
restartOnFileChange: true
3031
});
3132
};

0 commit comments

Comments
 (0)