-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme): add Accordion component
- Loading branch information
Showing
32 changed files
with
1,029 additions
and
7 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,103 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { browser, element, by } from 'protractor'; | ||
|
||
import { hasClass } from './e2e-helper'; | ||
|
||
describe('accordion', () => { | ||
beforeEach(done => { | ||
browser.get('#/accordion/accordion-test.component').then(() => done()); | ||
}); | ||
|
||
it('should display the 4 accordion items', () => { | ||
expect(element.all(by.css('nb-accordion > nb-accordion-item')).count()).toEqual(4); | ||
|
||
expect( | ||
element( | ||
by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header'), | ||
).getText(), | ||
).toEqual('Accordion #1', 'fist item title'); | ||
|
||
expect( | ||
element( | ||
by.css('nb-accordion > nb-accordion-item:nth-child(2) > nb-accordion-item-header'), | ||
).getText(), | ||
).toEqual('Accordion #2', 'second item title'); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(2)')), 'collapsed'), | ||
).toBeTruthy('second is collapsed'); | ||
|
||
expect( | ||
element( | ||
by.css('nb-accordion > nb-accordion-item:nth-child(3) > nb-accordion-item-header'), | ||
).getText(), | ||
).toEqual('Accordion #3', 'third item title'); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'expanded'), | ||
).toBeTruthy('second is expanded'); | ||
}); | ||
|
||
it('should expand a first accordion-item', () => { | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(1)')).click(); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(1)')), 'expanded'), | ||
).toBeTruthy(); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'collapsed'), | ||
).toBeTruthy(); | ||
|
||
expect( | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header')).getAttribute( | ||
'aria-expanded', | ||
), | ||
).toEqual('true'); | ||
}); | ||
|
||
it('should display the tabbable accordion items', () => { | ||
expect( | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header')).getAttribute( | ||
'tabindex', | ||
), | ||
).toEqual('0'); | ||
|
||
expect( | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(2) > nb-accordion-item-header')).getAttribute( | ||
'tabindex', | ||
), | ||
).toEqual('0'); | ||
|
||
expect( | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(4) > nb-accordion-item-header')).getAttribute( | ||
'tabindex', | ||
), | ||
).toEqual('-1'); | ||
}); | ||
|
||
it('should display a disabled accordion item', () => { | ||
expect( | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(4) > nb-accordion-item-header')).getAttribute( | ||
'aria-disabled', | ||
), | ||
).toEqual('true'); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')), 'disabled'), | ||
).toBeTruthy(); | ||
}); | ||
|
||
it('should display a disabled accordion with collapsed state after click', () => { | ||
element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')).click(); | ||
|
||
expect( | ||
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')), 'collapsed'), | ||
).toBeTruthy(); | ||
}); | ||
}); |
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 @@ | ||
.framework-options-bar { | ||
display: flex; | ||
} |
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
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
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 |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
display: block; | ||
padding: 0.5em; | ||
|
||
input { | ||
margin-right: 0.25rem; | ||
} | ||
|
||
label { | ||
margin: 0; | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
src/app/layout-theme-toggle/layout-theme-toggle.component.scss
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,13 @@ | ||
:host { | ||
display: block; | ||
padding: 0.5em; | ||
|
||
button { | ||
margin-right: 0.25rem; | ||
} | ||
|
||
label { | ||
margin: 0; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/app/layout-theme-toggle/layout-theme-toggle.component.ts
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,21 @@ | ||
import { Component } from '@angular/core'; | ||
import { NbThemeService } from '@nebular/theme'; | ||
|
||
@Component({ | ||
selector: 'nb-layout-theme-toggle', | ||
styleUrls: ['./layout-theme-toggle.component.scss'], | ||
template: ` | ||
<label dir="ltr"> | ||
<button (click)="enable('cosmic')">Cosmic</button> | ||
<button (click)="enable('default')">Default</button> | ||
<button (click)="enable('corporate')">Corporate</button> | ||
</label> | ||
`, | ||
}) | ||
export class NbLayoutThemeToggleComponent { | ||
constructor(private themeService: NbThemeService) {} | ||
|
||
enable(theme: string) { | ||
this.themeService.changeTheme(theme); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/framework/theme/components/accordion/_accordion.component.theme.scss
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,58 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
@mixin nb-accordion-item-header() { | ||
padding: nb-theme(accordion-padding); | ||
border-bottom-width: nb-theme(accordion-header-border-width); | ||
border-bottom-style: nb-theme(accordion-header-border-type); | ||
border-bottom-color: nb-theme(accordion-header-border-color); | ||
border-top-left-radius: nb-theme(accordion-border-radius); | ||
border-top-right-radius: nb-theme(accordion-border-radius); | ||
color: nb-theme(accordion-header-fg-heading); | ||
|
||
font-family: nb-theme(accordion-header-font-family); | ||
font-size: nb-theme(accordion-header-font-size); | ||
font-weight: nb-theme(accordion-header-font-weight); | ||
|
||
@include nb-headings(); | ||
} | ||
|
||
@mixin nb-accordion-theme() { | ||
|
||
nb-accordion { | ||
nb-accordion-item-header { | ||
position: relative; | ||
@include nb-accordion-item-header(); | ||
|
||
i { | ||
position: absolute; | ||
@include nb-ltr(right, 1rem); | ||
@include nb-rtl(left, 1rem); | ||
} | ||
} | ||
|
||
nb-accordion-item { | ||
font-family: nb-theme(accordion-item-font-family); | ||
font-weight: nb-theme(accordion-item-font-weight); | ||
background: nb-theme(accordion-item-bg); | ||
color: nb-theme(accordion-item-fg-text); | ||
box-shadow: nb-theme(accordion-item-shadow); | ||
|
||
&.disabled nb-accordion-item-header { | ||
color: nb-theme(accordion-header-disabled-fg); | ||
cursor: default; | ||
} | ||
} | ||
|
||
nb-accordion-item-body .item-body { | ||
flex: 1; | ||
-ms-flex: 1 1 auto; | ||
overflow: auto; | ||
padding: nb-theme(card-padding); | ||
position: relative; | ||
} | ||
} | ||
} |
Oops, something went wrong.