-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6268d08
Showing
31 changed files
with
1,948 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Node | ||
node_modules/* | ||
npm-debug.log | ||
|
||
# TypeScript | ||
src/*.js | ||
src/*.map | ||
src/*.d.ts | ||
|
||
# JetBrains | ||
.idea | ||
.project | ||
.settings | ||
.idea/* | ||
*.iml | ||
|
||
# VS Code | ||
.vscode/* | ||
|
||
# Windows | ||
Thumbs.db | ||
Desktop.ini | ||
|
||
# Mac | ||
.DS_Store | ||
**/.DS_Store | ||
|
||
# Ngc generated files | ||
**/*.ngfactory.ts | ||
|
||
# Build files | ||
dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Node | ||
node_modules/* | ||
npm-debug.log | ||
docs/* | ||
# DO NOT IGNORE TYPESCRIPT FILES FOR NPM | ||
# TypeScript | ||
# *.js | ||
# *.map | ||
# *.d.ts | ||
|
||
# JetBrains | ||
.idea | ||
.project | ||
.settings | ||
.idea/* | ||
*.iml | ||
|
||
# VS Code | ||
.vscode/* | ||
|
||
# Windows | ||
Thumbs.db | ||
Desktop.ini | ||
|
||
# Mac | ||
.DS_Store | ||
**/.DS_Store | ||
|
||
# Ngc generated files | ||
**/*.ngfactory.ts | ||
|
||
# Library files | ||
src/* | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- 'node' # use latest stable nodejs version | ||
script: | ||
- npm run coverage # jest test with coverage flag does coverage too | ||
after_script: | ||
- 'cat coverage/lcov.info | ./node_modules/.bin/coveralls' # sends the coverage report to coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"generator-angular2-library": { | ||
"promptValues": { | ||
"gitRepositoryUrl": "https://github.com/yc-ionic/image.git" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[![Build Status](https://travis-ci.org/yc-ionic/image.svg?branch=master)](https://travis-ci.org/yc-ionic/image.svg?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/github/yc-ionic/image/badge.svg?branch=master)](https://coveralls.io/github/yc-ionic/image?branch=master) | ||
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) | ||
|
||
# @yci/image | ||
|
||
## Installation | ||
|
||
1. Install the Ionic plugin | ||
``` | ||
npm i -S @yci/image | ||
``` | ||
|
||
2. Add it to your app’s NgModule. | ||
|
||
```typescript | ||
// Import your library | ||
import { ImageModule } from '@yci/image'; | ||
|
||
@NgModule({ | ||
|
||
... | ||
|
||
imports: [ | ||
|
||
... | ||
|
||
// Specify your library as an import | ||
ImageModule.forRoot() | ||
], | ||
|
||
... | ||
|
||
}) | ||
export class AppModule { } | ||
``` | ||
|
||
## Usage | ||
Once your library is imported, you can use its component in your Angular application: | ||
|
||
```xml | ||
<yci-image src="xxx.png"></yci-image> | ||
``` | ||
|
||
## Inputs | ||
```ts | ||
@Input() src: string; | ||
@Input() ratio: number = 1; // height = width * ratio | ||
@Input() width: string = '100%'; | ||
@Input('oss-style') style: string; // aliyun oss style | ||
``` | ||
|
||
## Development | ||
|
||
To generate all `*.js`, `*.d.ts` and `*.metadata.json` files: | ||
|
||
```bash | ||
$ npm run build | ||
``` | ||
|
||
## License | ||
|
||
MIT © [Yu Chen](mailto:yu.chen@live.ie) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DebugElement, SimpleChange } from '@angular/core'; | ||
|
||
import { ImageModule, Image } from '../src/'; | ||
|
||
describe('SampleComponent', () => { | ||
let fixture: ComponentFixture<Image>; | ||
let comp: Image; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
ImageModule.forRoot() | ||
] | ||
}); | ||
|
||
fixture = TestBed.createComponent(Image); | ||
comp = fixture.componentInstance; | ||
}); | ||
|
||
it('Should display flex', () => { | ||
expect(fixture.nativeElement.style.display).toBe('flex'); | ||
}); | ||
|
||
it('Should have changed', fakeAsync(() => { | ||
comp.src = 'abc'; | ||
comp.image.nativeElement.getBoundingClientRect = () => { | ||
return { | ||
width: 100 | ||
} | ||
} | ||
comp.ngOnChanges({ | ||
src: new SimpleChange(undefined, 'abc', false) | ||
}); | ||
fixture.detectChanges(); | ||
expect(comp.image.nativeElement.style.height).toBe('100px'); | ||
})); | ||
|
||
it('Should have oss style', fakeAsync(() => { | ||
comp.src = 'abc'; | ||
comp.style = 'wap'; | ||
comp.ngOnChanges({ | ||
src: new SimpleChange(undefined, 'abc', false), | ||
style: new SimpleChange(undefined, 'wap', false) | ||
}); | ||
fixture.detectChanges(); | ||
const src = 'url(abc?x-oss-process=style/wap)'; | ||
expect(comp.image.nativeElement.style.backgroundImage).toBe(src); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1503848891656" clover="3.2.0"> | ||
<project timestamp="1503848891656" name="All files"> | ||
<metrics statements="21" coveredstatements="21" conditionals="2" coveredconditionals="2" methods="3" coveredmethods="3" elements="26" coveredelements="26" complexity="0" loc="21" ncloc="21" packages="1" files="2" classes="2"> | ||
<file name="component.ts" path="/Users/yuchen/Projects/yci/image/src/component.ts"> | ||
<metrics statements="16" coveredstatements="16" conditionals="2" coveredconditionals="2" methods="2" coveredmethods="2"/> | ||
<line num="1" count="1" type="stmt"/> | ||
<line num="7" count="1" type="stmt"/> | ||
<line num="8" count="1" type="stmt"/> | ||
<line num="9" count="3" type="stmt"/> | ||
<line num="10" count="3" type="stmt"/> | ||
<line num="11" count="1" type="stmt"/> | ||
<line num="12" count="1" type="stmt"/> | ||
<line num="15" count="3" type="stmt"/> | ||
<line num="19" count="2" type="stmt"/> | ||
<line num="20" count="2" type="stmt"/> | ||
<line num="21" count="2" type="stmt"/> | ||
<line num="22" count="2" type="stmt"/> | ||
<line num="23" count="2" type="cond" truecount="2" falsecount="0"/> | ||
<line num="24" count="2" type="stmt"/> | ||
<line num="25" count="2" type="stmt"/> | ||
<line num="26" count="2" type="stmt"/> | ||
</file> | ||
<file name="index.ts" path="/Users/yuchen/Projects/yci/image/src/index.ts"> | ||
<metrics statements="5" coveredstatements="5" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="1"/> | ||
<line num="1" count="1" type="stmt"/> | ||
<line num="2" count="1" type="stmt"/> | ||
<line num="3" count="1" type="stmt"/> | ||
<line num="5" count="1" type="stmt"/> | ||
<line num="18" count="1" type="stmt"/> | ||
</file> | ||
</metrics> | ||
</project> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"/Users/yuchen/Projects/yci/image/src/component.ts": {"path":"/Users/yuchen/Projects/yci/image/src/component.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":82}},"1":{"start":{"line":9,"column":11},"end":{"line":9,"column":27}},"2":{"start":{"line":10,"column":11},"end":{"line":10,"column":27}},"3":{"start":{"line":15,"column":4},"end":{"line":15,"column":37}},"4":{"start":{"line":19,"column":4},"end":{"line":19,"column":48}},"5":{"start":{"line":20,"column":8},"end":{"line":20,"column":24}},"6":{"start":{"line":21,"column":4},"end":{"line":21,"column":65}},"7":{"start":{"line":22,"column":8},"end":{"line":22,"column":13}},"8":{"start":{"line":23,"column":4},"end":{"line":23,"column":19}},"9":{"start":{"line":23,"column":19},"end":{"line":23,"column":49}},"10":{"start":{"line":24,"column":4},"end":{"line":24,"column":66}},"11":{"start":{"line":25,"column":4},"end":{"line":25,"column":54}},"12":{"start":{"line":26,"column":4},"end":{"line":26,"column":52}},"13":{"start":{"line":8,"column":11},"end":{"line":8,"column":23}},"14":{"start":{"line":9,"column":11},"end":{"line":9,"column":29}},"15":{"start":{"line":10,"column":11},"end":{"line":10,"column":34}},"16":{"start":{"line":11,"column":22},"end":{"line":11,"column":36}},"17":{"start":{"line":12,"column":22},"end":{"line":12,"column":40}},"18":{"start":{"line":7,"column":13},"end":{"line":null,"column":-1}},"19":{"start":{"line":7,"column":13},"end":{"line":7,"column":18}}},"fnMap":{"0":{"name":"(anonymous_2)","decl":{"start":{"line":14,"column":2},"end":{"line":14,"column":13}},"loc":{"start":{"line":14,"column":14},"end":{"line":16,"column":3}}},"1":{"name":"(anonymous_3)","decl":{"start":{"line":18,"column":2},"end":{"line":18,"column":13}},"loc":{"start":{"line":18,"column":14},"end":{"line":27,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":4},"end":{"line":23,"column":19}},"type":"if","locations":[{"start":{"line":23,"column":4},"end":{"line":23,"column":19}},{"start":{"line":23,"column":4},"end":{"line":23,"column":19}}]}},"s":{"0":1,"1":3,"2":3,"3":3,"4":2,"5":2,"6":2,"7":2,"8":2,"9":1,"10":2,"11":2,"12":2,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"f":{"0":3,"1":2},"b":{"0":[1,1]}} | ||
,"/Users/yuchen/Projects/yci/image/src/index.ts": {"path":"/Users/yuchen/Projects/yci/image/src/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":61}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":46}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":35}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":28}},"4":{"start":{"line":18,"column":13},"end":{"line":null,"column":-1}},"5":{"start":{"line":18,"column":13},"end":{"line":18,"column":24}}},"fnMap":{"0":{"name":"(anonymous_2)","decl":{"start":{"line":19,"column":2},"end":{"line":19,"column":8}},"loc":{"start":{"line":19,"column":9},"end":{"line":24,"column":3}}}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":3},"b":{}} | ||
} |
Oops, something went wrong.