Skip to content

Commit 7560e32

Browse files
authored
Merge pull request #45 from edcarroll/develop
v0.5.0 into master
2 parents 7de1e8f + 041aa70 commit 7560e32

File tree

156 files changed

+3559
-2021
lines changed

Some content is hidden

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

156 files changed

+3559
-2021
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
/dist
55
/tmp
66

7+
## ngc logs
8+
9+
*.ngfactory.ts
10+
*.ngsummary.json
11+
712
# dependencies
813
/node_modules
914
/bower_components
@@ -14,6 +19,7 @@
1419
.classpath
1520
*.launch
1621
.settings/
22+
.vscode
1723

1824
# misc
1925
/.sass-cache
@@ -24,15 +30,18 @@ npm-debug.log
2430
testem.log
2531
/typings
2632

27-
# e2e
28-
/e2e/*.js
29-
/e2e/*.map
30-
31-
#System Files
33+
# System Files
3234
.DS_Store
3335
Thumbs.db
3436

35-
# TypeScript
36-
*.js
37-
*.map
37+
# Non TS files
3838
*.d.ts
39+
*.metadata.json
40+
*.js
41+
*.js.map
42+
43+
# Config Files
44+
!*.config.js
45+
46+
# Output Files
47+
demo/dist

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ Desktop.ini
2121
# Mac
2222
.DS_Store
2323
**/.DS_Store
24+
25+
# TS Files
26+
*.ts
27+
!*.d.ts

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Semantic UI Angular 2 Integrations, written in pure AngularJS - **no JQuery requ
44

55
## Demo & Usage
66

7-
[ng2-semantic-ui](http://edcarroll.github.io/ng2-semantic-ui/)
7+
[ng2-semantic-ui](https://edcarroll.github.io/ng2-semantic-ui/)
88

99
## Installation
1010

@@ -20,12 +20,12 @@ Next include the Semantic UI CSS file in your `index.html` (you can include a ma
2020

2121
Once installed you need to import the main module:
2222
```ts
23-
import {SuiModule} from 'ng2-semantic-ui/ng2-semantic-ui';
23+
import {SuiModule} from 'ng2-semantic-ui';
2424
```
2525

2626
Finally import the main module into your application module:
2727
```ts
28-
import {SuiModule} from 'ng2-semantic-ui/ng2-semantic-ui';
28+
import {SuiModule} from 'ng2-semantic-ui';
2929

3030
@NgModule({
3131
declarations: [AppComponent, ...],
@@ -37,32 +37,33 @@ export class AppModule {}
3737

3838
N.B. you can import individual component modules:
3939
```ts
40-
import {SuiCheckboxModule, SuiRatingModule} from 'ng2-semantic-ui/ng2-semantic-ui';
40+
import {SuiCheckboxModule, SuiRatingModule} from 'ng2-semantic-ui';
4141
```
4242

4343
Now you're good to go!
4444

4545
## Dependencies
4646

47-
* [Angular 2](https://angular.io) (^2.0.0 final)
47+
* [Angular 2](https://angular.io) (>=2.0.0)
4848
* [Semantic UI CSS](http://semantic-ui.com/) (jQuery is **not** required)
4949

5050
## Components
5151

5252
The current list of available components with links to their docs is below:
5353

54-
* [Accordion](http://edcarroll.github.io/ng2-semantic-ui/#/components/accordion)
55-
* [Checkbox](http://edcarroll.github.io/ng2-semantic-ui/#/components/checkbox)
56-
* [Collapse](http://edcarroll.github.io/ng2-semantic-ui/#/components/collapse)
57-
* [Dimmer](http://edcarroll.github.io/ng2-semantic-ui/#/components/dimmer)
58-
* [Dropdown](http://edcarroll.github.io/ng2-semantic-ui/#/components/dropdown)
59-
* [Message](http://edcarroll.github.io/ng2-semantic-ui/#/components/message)
60-
* [Progress](http://edcarroll.github.io/ng2-semantic-ui/#/components/progress)
61-
* [Rating](http://edcarroll.github.io/ng2-semantic-ui/#/components/rating)
62-
* [Search](http://edcarroll.github.io/ng2-semantic-ui/#/components/search)
63-
* [Select](http://edcarroll.github.io/ng2-semantic-ui/#/components/select)
64-
* [Tabs](http://edcarroll.github.io/ng2-semantic-ui/#/components/tabs)
65-
* [Transition](http://edcarroll.github.io/ng2-semantic-ui/#/components/transition)
54+
* [Accordion](https://edcarroll.github.io/ng2-semantic-ui/#/components/accordion)
55+
* [Checkbox](https://edcarroll.github.io/ng2-semantic-ui/#/components/checkbox)
56+
* [Collapse](https://edcarroll.github.io/ng2-semantic-ui/#/components/collapse)
57+
* [Dimmer](https://edcarroll.github.io/ng2-semantic-ui/#/components/dimmer)
58+
* [Dropdown](https://edcarroll.github.io/ng2-semantic-ui/#/components/dropdown)
59+
* [Message](https://edcarroll.github.io/ng2-semantic-ui/#/components/message)
60+
* [Popup](https://edcarroll.github.io/ng2-semantic-ui/#/components/popup)
61+
* [Progress](https://edcarroll.github.io/ng2-semantic-ui/#/components/progress)
62+
* [Rating](https://edcarroll.github.io/ng2-semantic-ui/#/components/rating)
63+
* [Search](https://edcarroll.github.io/ng2-semantic-ui/#/components/search)
64+
* [Select](https://edcarroll.github.io/ng2-semantic-ui/#/components/select)
65+
* [Tabs](https://edcarroll.github.io/ng2-semantic-ui/#/components/tabs)
66+
* [Transition](https://edcarroll.github.io/ng2-semantic-ui/#/components/transition)
6667

6768
## Development
6869

angular-cli.json

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
{
22
"project": {
3-
"version": "1.0.0-beta.11-webpack.8",
3+
"version": "1.0.0-beta.31",
44
"name": "ng2-semantic-ui"
55
},
66
"apps": [
77
{
8-
"root": "demo",
9-
"outDir": "dist",
10-
"assets": "assets",
8+
"root": "demo/src",
9+
"outDir": "demo/dist",
10+
"assets": [
11+
"assets",
12+
"favicon.ico"
13+
],
1114
"index": "index.html",
1215
"main": "main.ts",
13-
"test": "test.ts",
1416
"tsconfig": "tsconfig.json",
15-
"prefix": "app",
17+
"prefix": "demo",
1618
"mobile": false,
17-
"styles": [
18-
"css/style.css",
19-
"css/code.css"
20-
],
19+
"styles": ["styles.css"],
2120
"scripts": [],
21+
"environmentSource": "environments/environment.ts",
2222
"environments": {
23-
"source": "environments/environment.ts",
24-
"prod": "environments/environment.prod.ts",
25-
"dev": "environments/environment.dev.ts"
23+
"dev": "environments/environment.ts",
24+
"prod": "environments/environment.prod.ts"
2625
}
2726
}
2827
],
@@ -41,6 +40,17 @@
4140
"defaults": {
4241
"styleExt": "css",
4342
"prefixInterfaces": false,
44-
"lazyRoutePrefix": "+"
43+
"inline": {
44+
"style": false,
45+
"template": false
46+
},
47+
"spec": {
48+
"class": false,
49+
"component": true,
50+
"directive": true,
51+
"module": false,
52+
"pipe": true,
53+
"service": true
54+
}
4555
}
4656
}

components/accordion/accordion-panel.ts

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,93 @@
11
import {Component, Input, Output, EventEmitter} from '@angular/core';
22
import {SuiAccordionService} from "./accordion.service";
3+
import {TransitionController} from '../transition/transition-controller';
4+
import {Transition, TransitionDirection} from '../transition/transition';
35

46
@Component({
57
selector: 'sui-accordion-panel',
68
exportAs: 'suiAccordionPanel',
79
template: `
8-
<div class="title" [class.active]="isOpen" (click)="toggleOpen($event)">
10+
<!-- Title -->
11+
<div class="title" [class.active]="isOpen" (click)="toggleOpen($event)" >
912
<ng-content select="[title]"></ng-content>
1013
</div>
11-
<div [suiCollapse]="!isOpen">
12-
<div class="content" [class.active]="isOpen">
14+
<!-- Content -->
15+
<div [suiCollapse]="!isOpen" [collapseDuration]="transitionDuration">
16+
<div class="content" [class.active]="isOpen" [suiTransition]="transitionController">
1317
<ng-content select="[content]"></ng-content>
1418
</div>
1519
</div>
1620
`,
1721
styles: [`
22+
/* Manual style as Semantic UI relies on > selector */
1823
.content {
19-
padding: .5em 0 1em
24+
padding: .5em 0 1em;
2025
}
2126
22-
:host:last-child .content {
23-
padding-bottom: 0
27+
/* Another > selector fix */
28+
:host:first-child .title {
29+
border-top: none;
2430
}
2531
`]
2632
})
2733
export class SuiAccordionPanel {
2834
private _service:SuiAccordionService;
35+
36+
public transitionController:TransitionController;
37+
2938
public set service(service:SuiAccordionService) {
3039
this._service = service;
3140
}
3241

33-
@Input() public isDisabled:boolean;
42+
@Input()
43+
public isDisabled:boolean;
44+
45+
private _isOpen:boolean;
3446

3547
@Input()
36-
public get isOpen():boolean {
48+
public get isOpen() {
3749
return this._isOpen;
3850
}
39-
@Output() public isOpenChange:EventEmitter<boolean> = new EventEmitter<boolean>(false);
4051

4152
public set isOpen(value:boolean) {
42-
this._isOpen = value;
43-
if (value && this._service) {
44-
this._service.closeOtherPanels(this);
53+
if (value != this.isOpen) {
54+
// Only update if the value has changed.
55+
this._isOpen = value;
56+
57+
if (value && this._service) {
58+
// If we are opening this panel, we must close the other ones.
59+
this._service.closeOtherPanels(this);
60+
}
61+
this.isOpenChange.emit(this.isOpen);
62+
63+
// Cancel all current animations, and fade the contents. The direction is automatic.
64+
this.transitionController.stopAll();
65+
this.transitionController.animate(new Transition("fade", this.transitionDuration));
66+
}
67+
}
68+
69+
public get transitionDuration() {
70+
if (this._service) {
71+
// Return the service defined transition duration.
72+
return this._service.transitionDuration;
4573
}
46-
this.isOpenChange.emit(this._isOpen);
74+
// Revert to instantaneous if the service is not yet loaded.
75+
return 0;
4776
}
4877

49-
private _isOpen:boolean = false;
78+
@Output()
79+
public isOpenChange:EventEmitter<boolean>;
80+
81+
constructor() {
82+
this.transitionController = new TransitionController(false);
5083

51-
public toggleOpen(event:MouseEvent):any {
84+
this._isOpen = false;
85+
this.isOpenChange = new EventEmitter<boolean>(false);
86+
}
87+
88+
public toggleOpen(event:MouseEvent) {
5289
event.preventDefault();
90+
5391
if (!this.isDisabled) {
5492
this.isOpen = !this.isOpen;
5593
}
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import {NgModule} from '@angular/core';
2-
import {SUI_ACCORDION_DIRECTIVES, SUI_ACCORDION_PROVIDERS} from "./accordion";
32
import {SuiCollapseModule} from "../collapse/collapse.module";
43
import {CommonModule} from "@angular/common";
4+
import {SuiAccordion} from './accordion';
5+
import {SuiAccordionPanel} from './accordion-panel';
6+
import {SuiTransitionModule} from '../transition/transition.module';
57

68
@NgModule({
7-
imports: [CommonModule, SuiCollapseModule],
8-
declarations: SUI_ACCORDION_DIRECTIVES,
9-
exports: SUI_ACCORDION_DIRECTIVES,
10-
providers: SUI_ACCORDION_PROVIDERS
9+
imports: [
10+
CommonModule,
11+
SuiCollapseModule,
12+
SuiTransitionModule
13+
],
14+
declarations: [
15+
SuiAccordion,
16+
SuiAccordionPanel
17+
],
18+
exports: [
19+
SuiAccordion,
20+
SuiAccordionPanel
21+
],
22+
providers: []
1123
})
1224
export class SuiAccordionModule {}

components/accordion/accordion.service.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import {SuiAccordionPanel} from "./accordion-panel";
22

33
export class SuiAccordionService {
4-
// State
5-
public closeOthers:boolean = true;
4+
public closeOthers:boolean;
65

7-
public panels:SuiAccordionPanel[] = [];
6+
public transitionDuration:number;
7+
8+
public panels:SuiAccordionPanel[];
9+
10+
constructor() {
11+
this.closeOthers = true;
12+
this.transitionDuration = 350;
13+
14+
this.panels = [];
15+
}
816

917
public addPanel(panel:SuiAccordionPanel) {
1018
panel.service = this;
@@ -16,7 +24,7 @@ export class SuiAccordionService {
1624
return;
1725
}
1826

19-
this.panels.forEach((p:SuiAccordionPanel) => {
27+
this.panels.forEach(p => {
2028
if (p !== panel) {
2129
p.isOpen = false;
2230
}

0 commit comments

Comments
 (0)