Skip to content

Commit

Permalink
feat: Side Navigation styles markup adaptation (#2490)
Browse files Browse the repository at this point in the history
* feat: Side Navigation styles markup adaptation

* Add tests

* Fix comments

* Update package-lock.json

* Add comments, fix rtl on side nav condensed popover

* remove focused tests

* Add PR comments

* remove focus outline overrides

* add PR comments

* Add transparent button

* Remove non-direct imports, add tests for aggregated directives

* Remove public accessors, remove unused imports, move properties

* fix tests

* update styles

* Remove unused parameter on host listener

* Fix focus on children elements for parent item

* dd selection on click, remove arrowright/left handling

* remove focused test

* Fix lint

* fix tests for side nav keyboard support

* Fix programatically changed example

* fix selected state in object generated examples

Co-authored-by: Mike O'Donnell <mikerodonnell89@users.noreply.github.com>
  • Loading branch information
JKMarkowski and mikerodonnell89 committed Jun 2, 2020
1 parent 1853117 commit ecd6c25
Show file tree
Hide file tree
Showing 40 changed files with 1,200 additions and 378 deletions.
Expand Up @@ -15,10 +15,13 @@
</li>
<li fd-nested-list-item>
<fd-nested-list-popover>
<a fd-nested-list-link>
<span fd-nested-list-icon [glyph]="'settings'"></span>
<span fd-nested-list-title>Link 3</span>
</a>
<div fd-nested-list-content [selected]="true">
<a fd-nested-list-link>
<span fd-nested-list-icon [glyph]="'settings'"></span>
<span fd-nested-list-title>Link 3</span>
</a>
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list>
<li fd-nested-list-item>
<a fd-nested-list-link>
Expand Down
Expand Up @@ -14,10 +14,13 @@
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-icon [glyph]="'settings'"></span>
<span fd-nested-list-title>Link 3</span>
</a>
<div fd-nested-list-content>
<a fd-nested-list-link>
<span fd-nested-list-icon [glyph]="'settings'"></span>
<span fd-nested-list-title>Link 3</span>
</a>
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list [textOnly]="true">
<li fd-nested-list-item>
<a fd-nested-list-link>
Expand Down
Expand Up @@ -12,9 +12,12 @@
</a>
</li>
<li fd-nested-list-item [expanded]="true">
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
<div fd-nested-list-content>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 1</span>
</a>
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list>
<li fd-nested-list-item>
<a fd-nested-list-link>
Expand Down
@@ -0,0 +1,41 @@
<fd-side-nav [selectable]="false">
<div fd-side-nav-main>
<ul fd-nested-list [textOnly]="true">
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 1</span>
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link [selected]="true">
<span fd-nested-list-title>Link 2</span>
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 4</span>
</a>
</li>
</ul>
</div>

<div fd-side-nav-utility>
<ul fd-nested-list [textOnly]="true">
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 1</span>
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 2</span>
</a>
</li>
</ul>
</div>
</fd-side-nav>
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'fd-side-navigation-non-selectable-example',
templateUrl: './side-navigation-non-selectable-example.component.html'
})
export class SideNavigationNonSelectableExampleComponent {
}
@@ -1,4 +1,4 @@
<fd-side-nav>
<fd-side-nav [selectable]="false">
<div fd-side-nav-main>
<ul fd-nested-list [textOnly]="true">
<li fd-nested-list-item>
Expand All @@ -12,9 +12,12 @@
</a>
</li>
<li fd-nested-list-item [(expanded)]="open">
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
<div fd-nested-list-content [selected]="selected">
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list>
<li fd-nested-list-item>
<a fd-nested-list-link [selected]="selected">
Expand Down
Expand Up @@ -12,13 +12,16 @@
</a>
</li>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
<div fd-nested-list-content>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 3</span>
</a>
<button fd-nested-list-expand-icon></button>
</div>
<ul fd-nested-list>
<li fd-nested-list-item>
<a fd-nested-list-link>
<span fd-nested-list-title>Link 1</span>
<span fd-nested-list-title>Link 2</span>
</a>
</li>
<li fd-nested-list-item>
Expand Down
Expand Up @@ -33,6 +33,20 @@

<separator></separator>

<fd-docs-section-title [id]="'withCompact'" [componentName]="'sideNavigation'">
Side Navigation with Disabled Selection
</fd-docs-section-title>
<description>
Add <code>[selectable]="false"</code> to main side navigation component,
to prevent from changing selected state on items on click
</description>
<component-example>
<fd-side-navigation-non-selectable-example></fd-side-navigation-non-selectable-example>
</component-example>
<code-example [exampleFiles]="nonSelectableSideNav"></code-example>

<separator></separator>

<fd-docs-section-title [id]="'withMultipleTitles'" [componentName]="'sideNavigation'">
Side Navigation with Multiple Levels
</fd-docs-section-title>
Expand Down
Expand Up @@ -6,6 +6,7 @@ import * as sideNavigationIconsSrc from '!raw-loader!./examples/side-navigation-
import * as sideNavigationTitlesSrc from '!raw-loader!./examples/side-navigation-titles-example.component.html';
import * as sideNavigationCompactSrc from '!raw-loader!./examples/side-navigation-compact-example.component.html';
import * as sideNavigationMultiLevelSrc from '!raw-loader!./examples/side-navigation-three-levels-example/side-navigation-three-levels-example.component.html';
import * as sideNavigationNonSelectSrc from '!raw-loader!./examples/side-navigation-non-selectable-example/side-navigation-non-selectable-example.component.html';
import * as sideNavigationMultiLevelSrcTs from '!raw-loader!./examples/side-navigation-three-levels-example/side-navigation-three-levels-example.component.ts';
import * as programmaticallySideNavigationSrc from '!raw-loader!./examples/side-navigation-programmatically-example/side-navigation-programmatically-example.component.html';
import * as programmaticallySideNavigationSrcTs from '!raw-loader!./examples/side-navigation-programmatically-example/side-navigation-programmatically-example.component.ts';
Expand Down Expand Up @@ -94,6 +95,14 @@ export class SideNavigationDocsComponent {
}
];

nonSelectableSideNav: ExampleFile[] = [
{
language: 'html',
code: sideNavigationNonSelectSrc,
fileName: 'side-navigation-non-selectable-example'
}
];

condensedSideNav: ExampleFile[] = [
{
language: 'html',
Expand Down
Expand Up @@ -18,6 +18,7 @@ import { SideNavigationMultipleSelectedExampleComponent } from './examples/side-
import { SideNavigationCondensedObjectExampleComponent } from './examples/side-navigation-condensed-object-example/side-navigation-condensed-object-example.component';
import { SideNavigationCondensedExampleComponent } from './examples/side-navigation-condensed-example/side-navigation-condensed-example.component';
import { SideNavigationModule } from '@fundamental-ngx/core';
import { SideNavigationNonSelectableExampleComponent} from './examples/side-navigation-non-selectable-example/side-navigation-non-selectable-example.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -45,7 +46,9 @@ const routes: Routes = [
SideNavigationThreeLevelsExampleComponent,
SideNavigationCondensedObjectExampleComponent,
SideNavigationProgrammaticallyExampleComponent,
SideNavigationMultipleSelectedExampleComponent
SideNavigationMultipleSelectedExampleComponent,
SideNavigationNonSelectableExampleComponent
]
})
export class SideNavigationDocsModule {}
export class SideNavigationDocsModule {
}
@@ -1,15 +1,15 @@
<header>Side Navigation</header>
<description
>The left navigation can always display or expand/collapse using the menu icon within the global navigation.<br /><br />
>The left navigation can always display or expand/collapse using the menu icon within the global navigation.<br/><br/>
Side navigation anchors are keyboard navigated, it can be achieved by <code>ArrowDown</code>, <code>ArrowUp</code>,
<code>ArrowRight</code>, <code>ArrowLeft</code> and basic <code>Tab</code>. Sub-levels of tiered side navigation can
be opened with the space bar, enter key or right arrow.<br /><br />
and basic <code>Tab</code>. Sub-levels of tiered side navigation can be opened with the space bar, enter key or
right arrow.<br/><br/>
Expanded state: Only the selected item itself, be it a first-level or second-level item, shows the selection
indication.<br /><br />
indication.<br/><br/>
Collapsed state: The first-level item shows a selection indication either when itself or one of its
second-level/children items is selected.<br /><br />
second-level/children items is selected.<br/><br/>
Collapsed with Popover: When a Popover is shown, both the first-level item in the Side Navigation, as well as the
selected second-level item in the Popover, both show the selection indication.
selected second-level item in the Popover, both show the selection indication. <br/><br/>
</description>
<import module="SideNavigationModule"></import>

Expand Down
18 changes: 1 addition & 17 deletions libs/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,69 @@
import { NestedListContentDirective } from './nested-list-content.directive';
import { Component, ViewChild } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NestedListModule } from '../nested-list.module';
import { NestedListStateService } from '../nested-list-state.service';
import { NestedListExpandIconDirective } from '../nested-list-directives';
import { NestedItemService } from '../nested-item/nested-item.service';

@Component({
template: `
<div fd-nested-list-content>
<a fd-nested-list-link>
<span fd-nested-list-icon [glyph]="'settings'"></span>
<span fd-nested-list-title>Link 1</span>
</a>
<a fd-nested-list-expand-icon></a>
</div>
`
})
class TestNestedContainerComponent {
@ViewChild(NestedListContentDirective)
directiveElement: NestedListContentDirective;

@ViewChild(NestedListExpandIconDirective)
iconElement: NestedListExpandIconDirective;
}

describe('NestedContentDirective', () => {
let component: TestNestedContainerComponent;
let directiveElement: NestedListContentDirective;
let iconElement: NestedListExpandIconDirective;
let fixture: ComponentFixture<TestNestedContainerComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NestedListModule],
declarations: [TestNestedContainerComponent],
providers: [NestedListStateService, NestedItemService]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TestNestedContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
directiveElement = component.directiveElement;
iconElement = component.iconElement;
fixture.detectChanges();
});

it('Should have good classes', () => {
const classList = (directiveElement as any)._elementRef.nativeElement.classList;
expect(classList.contains('has-child')).toBeFalsy();
expect(classList.contains('is-selected')).toBeFalsy();

directiveElement.selected = true;

fixture.detectChanges();

expect(classList.contains('is-selected')).toBeTruthy();
});

it('Should propagate expanded state to icon', () => {
expect(iconElement.expanded).toBeFalsy();
directiveElement.changeExpandedState(true);
fixture.detectChanges();
expect(iconElement.expanded).toBeTruthy();
});
});

0 comments on commit ecd6c25

Please sign in to comment.