Skip to content

Commit

Permalink
docs: exp has been changed fix (SAP#2646)
Browse files Browse the repository at this point in the history
  • Loading branch information
rengare authored Jun 10, 2020
1 parent 8b5c523 commit 8372853
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 264 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<button (click)="skipNavClicked()" aria-label="skip navigation" class="skip-navigation">Skip Navigation</button>
<fd-docs-toolbar (btnClicked)="handleMenuCollapseClick()"></fd-docs-toolbar>
<div class="fd-flex-row fd-sidebar-container">
<sections-toolbar [sections]="sections" [(sideCollapsed)]="sideCollapsed"></sections-toolbar>
<sections-toolbar [sections]="sections" [sideCollapsed]="sideCollapsed"></sections-toolbar>
<div tabindex="0" class="content" #content id="page-content">
<div class="content-margin">
<router-outlet (activate)="onActivate()"></router-outlet>
Expand All @@ -11,7 +11,7 @@

<div
class="collapsed-overlay"
[ngClass]="{ 'overlay-init': !isSideBarCollapsed() }"
[ngClass]="{ 'overlay-init': !(sideCollapsed | async) }"
*ngIf="this.smallScreen"
(click)="closeSideBar()"
></div>
242 changes: 93 additions & 149 deletions apps/docs/src/app/core/documentation/core-documentation.component.ts
Original file line number Diff line number Diff line change
@@ -1,158 +1,102 @@
import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core';
import { SectionInterface } from '../../documentation/core-helpers/sections-toolbar/section.interface';
import { SectionsToolbarComponent } from '../../documentation/core-helpers/sections-toolbar/sections-toolbar.component';
import { Component } from '@angular/core';
import { DocumentationBaseComponent } from '../../documentation/documentation-base.component';

@Component({
selector: 'core-documentation',
styleUrls: ['./core-documentation.component.scss'],
templateUrl: './core-documentation.component.html'
})
export class CoreDocumentationComponent implements OnInit {
@ViewChild('content') contentElRef: ElementRef;

@ViewChild(SectionsToolbarComponent, { read: SectionsToolbarComponent })
sectionsToolbar: SectionsToolbarComponent;

sideCollapsed: boolean = window.innerWidth < 576;

guides = [
{ url: 'core/home', name: 'Home' },
{ url: 'core/new-component', name: 'New Component' }
];

components = [
{ url: 'core/action-bar', name: 'Action Bar' },
{ url: 'core/alert', name: 'Alert' },
{ url: 'core/badgeLabel', name: 'Status Indicator' },
{ url: 'core/bar', name: 'Bar' },
{ url: 'core/breadcrumb', name: 'Breadcrumb' },
{ url: 'core/busyIndicator', name: 'Busy Indicator' },
{ url: 'core/button', name: 'Button' },
{ url: 'core/segmentedButton', name: 'Segmented Button' },
{ url: 'core/checkbox', name: 'Checkbox' },
{ url: 'core/splitButton', name: 'Split Button' },
{ url: 'core/calendar', name: 'Calendar' },
{ url: 'core/combobox', name: 'Combobox' },
{ url: 'core/datePicker', name: 'Date Picker' },
{ url: 'core/datetime-picker', name: 'Datetime Picker' },
{ url: 'core/dialog', name: 'Dialog' },
{ url: 'core/dropdown', name: 'Dropdown' },
{ url: 'core/icon', name: 'Icon' },
{ url: 'core/identifier', name: 'Identifier' },
{ url: 'core/image', name: 'Image' },
{ url: 'core/info-label', name: 'Info Label' },
{ url: 'core/inlineHelp', name: 'Inline Help' },
{ url: 'core/input', name: 'Input' },
{ url: 'core/inputGroup', name: 'Input Group' },
{ url: 'core/link', name: 'Link' },
{ url: 'core/list', name: 'List' },
{ url: 'core/loadingSpinner', name: 'Loading Spinner' },
{ url: 'core/localizationEditor', name: 'Localization Editor' },
{ url: 'core/mega-menu', name: 'Mega Menu' },
{ url: 'core/menu', name: 'Menu' },
{ url: 'core/message-strip', name: 'Message Strip' },
{ url: 'core/multi-input', name: 'Multi Input' },
{ url: 'core/notification', name: 'Notification' },
{ url: 'core/object-status', name: 'Object Status' },
{ url: 'core/pagination', name: 'Pagination' },
{ url: 'core/popover', name: 'Popover' },
{ url: 'core/product-switch', name: 'Product Switch' },
{ url: 'core/radio', name: 'Radio Button' },
{ url: 'core/select-native', name: 'Select Native' },
{ url: 'core/select', name: 'Select' },
{ url: 'core/shellbar', name: 'Shellbar' },
{ url: 'core/sideNavigation', name: 'Side Navigation' },
{ url: 'core/table', name: 'Table' },
{ url: 'core/tabs', name: 'Tabs' },
{ url: 'core/textarea', name: 'Textarea' },
{ url: 'core/tile', name: 'Tile' },
{ url: 'core/time', name: 'Time' },
{ url: 'core/timePicker', name: 'Time Picker' },
{ url: 'core/switch', name: 'Switch' },
{ url: 'core/token', name: 'Token' }
// { url: 'core/tree', name: 'Tree' }
];

layouts = [
{ url: 'core/panel', name: 'Panel' },
{ url: 'core/layoutGrid', name: 'Layout Grid' }
];

utilities = [
{ url: 'core/file-input', name: 'File Input' },
{ url: 'core/infiniteScroll', name: 'Infinite Scroll' },
{ url: 'core/popover-directive', name: 'Popover Helper' },
{ url: 'core/scroll-spy', name: 'Scroll Spy' }
];

sections: SectionInterface[] = [
{
header: 'Guides',
content: this.guides
},
{
header: 'Components',
content: this.components
},
{
header: 'layouts',
content: this.layouts
},
{
header: 'Utilities',
content: this.utilities
}
];

smallScreen: boolean = window.innerWidth < 992;

ngOnInit() {
this.components.sort((el1, el2) => {
if (el1.name < el2.name) {
return -1;
}

if (el1.name > el2.name) {
return 1;
export class CoreDocumentationComponent extends DocumentationBaseComponent {
constructor() {
super();

this.guides = [
{ url: 'core/home', name: 'Home' },
{ url: 'core/new-component', name: 'New Component' }
];

this.components = [
{ url: 'core/action-bar', name: 'Action Bar' },
{ url: 'core/alert', name: 'Alert' },
{ url: 'core/badgeLabel', name: 'Status Indicator' },
{ url: 'core/bar', name: 'Bar' },
{ url: 'core/breadcrumb', name: 'Breadcrumb' },
{ url: 'core/busyIndicator', name: 'Busy Indicator' },
{ url: 'core/button', name: 'Button' },
{ url: 'core/segmentedButton', name: 'Segmented Button' },
{ url: 'core/checkbox', name: 'Checkbox' },
{ url: 'core/splitButton', name: 'Split Button' },
{ url: 'core/calendar', name: 'Calendar' },
{ url: 'core/combobox', name: 'Combobox' },
{ url: 'core/datePicker', name: 'Date Picker' },
{ url: 'core/datetime-picker', name: 'Datetime Picker' },
{ url: 'core/dialog', name: 'Dialog' },
{ url: 'core/dropdown', name: 'Dropdown' },
{ url: 'core/icon', name: 'Icon' },
{ url: 'core/identifier', name: 'Identifier' },
{ url: 'core/image', name: 'Image' },
{ url: 'core/info-label', name: 'Info Label' },
{ url: 'core/inlineHelp', name: 'Inline Help' },
{ url: 'core/input', name: 'Input' },
{ url: 'core/inputGroup', name: 'Input Group' },
{ url: 'core/link', name: 'Link' },
{ url: 'core/list', name: 'List' },
{ url: 'core/loadingSpinner', name: 'Loading Spinner' },
{ url: 'core/localizationEditor', name: 'Localization Editor' },
{ url: 'core/mega-menu', name: 'Mega Menu' },
{ url: 'core/menu', name: 'Menu' },
{ url: 'core/message-strip', name: 'Message Strip' },
{ url: 'core/multi-input', name: 'Multi Input' },
{ url: 'core/notification', name: 'Notification' },
{ url: 'core/object-status', name: 'Object Status' },
{ url: 'core/pagination', name: 'Pagination' },
{ url: 'core/popover', name: 'Popover' },
{ url: 'core/product-switch', name: 'Product Switch' },
{ url: 'core/radio', name: 'Radio Button' },
{ url: 'core/select-native', name: 'Select Native' },
{ url: 'core/select', name: 'Select' },
{ url: 'core/shellbar', name: 'Shellbar' },
{ url: 'core/sideNavigation', name: 'Side Navigation' },
{ url: 'core/table', name: 'Table' },
{ url: 'core/tabs', name: 'Tabs' },
{ url: 'core/textarea', name: 'Textarea' },
{ url: 'core/tile', name: 'Tile' },
{ url: 'core/time', name: 'Time' },
{ url: 'core/timePicker', name: 'Time Picker' },
{ url: 'core/switch', name: 'Switch' },
{ url: 'core/token', name: 'Token' }
// { url: 'core/tree', name: 'Tree' }
];

this.layouts = [
{ url: 'core/panel', name: 'Panel' },
{ url: 'core/layoutGrid', name: 'Layout Grid' }
];

this.utilities = [
{ url: 'core/file-input', name: 'File Input' },
{ url: 'core/infiniteScroll', name: 'Infinite Scroll' },
{ url: 'core/popover-directive', name: 'Popover Helper' },
{ url: 'core/scroll-spy', name: 'Scroll Spy' }
];

this.sections = [
{
header: 'Guides',
content: this.guides
},
{
header: 'Components',
content: this.components
},
{
header: 'layouts',
content: this.layouts
},
{
header: 'Utilities',
content: this.utilities
}
return 0;
});
}

skipNavClicked() {
if (this.contentElRef) {
this.contentElRef.nativeElement.focus();
}
}

handleMenuCollapseClick(): void {
this.sideCollapsed = !this.sideCollapsed;
}

closeSideBar(): void {
this.sideCollapsed = true;
}

isSideBarCollapsed(): boolean {
return this.sideCollapsed;
}

onActivate() {
if (this.contentElRef) {
this.contentElRef.nativeElement.scrollTop = 0;
}
this.skipNavClicked();
if (this.sectionsToolbar) {
this.sectionsToolbar.onActivate();
}
}

windowSize() {
this.smallScreen = window.innerWidth < 992;
}

@HostListener('window:resize', ['$event'])
onResize() {
this.windowSize();
];
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="sidebar" [ngClass]="{ 'sidebar-collapsed': sideCollapsed }">
<div class="sidebar" [ngClass]="{ 'sidebar-collapsed': sideCollapsed | async }">
<div class="fd-docs-search">
<fd-input-group
[disabled]="false"
Expand All @@ -21,6 +21,7 @@
<a
class="nav-item"
[routerLink]="'/' + item.url"
(click)="onItemClick()"
(keypress)="onKeypressHandler($event)"
tabindex="0"
role="button"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output, ViewChild } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { SectionInterface } from './section.interface';
import { BehaviorSubject } from 'rxjs';

const SMALL_SCREEN_BREAKPOINT = 992;
@Component({
selector: 'sections-toolbar',
styleUrls: ['./sections-toolbar.component.scss'],
Expand All @@ -9,15 +11,19 @@ import { SectionInterface } from './section.interface';
export class SectionsToolbarComponent implements OnInit {
@Input() sections: SectionInterface[];

search: string = '';

smallScreen: boolean = window.innerWidth < 992;
@Output()
readonly sideCollapsedChange: EventEmitter<boolean> = new EventEmitter<boolean>();

@Input()
sideCollapsed: boolean = window.innerWidth < 576;
sideCollapsed: BehaviorSubject<boolean>;

@Output()
readonly sideCollapsedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
search: string = '';

private get _smallScreen(): boolean {
return window.innerWidth < SMALL_SCREEN_BREAKPOINT;
}

constructor() {}

ngOnInit(): void {
this.onActivate();
Expand All @@ -31,27 +37,28 @@ export class SectionsToolbarComponent implements OnInit {
}
}

onItemClick() {
this.sideCollapsed.next(false);
}

onActivate() {
if (this.smallScreen && !this.sideCollapsed) {
this.sideCollapsed = true;
this.sideCollapsedChange.emit(this.sideCollapsed);
if (this._smallScreen && !this.sideCollapsed.value) {
this._setCollapseState(true);
}
}

windowSize() {
if (window.innerWidth < 992) {
this.smallScreen = true;
this.onActivate();
} else {
this.smallScreen = false;
this.sideCollapsed = false;
if (!this._smallScreen) {
this._setCollapseState(false);
return;
}
this.sideCollapsedChange.emit(this.sideCollapsed);
}

@HostListener('window:resize', ['$event'])
onResize() {
this.windowSize();
this.onActivate();
this.sideCollapsedChange.emit(this.sideCollapsed.value);
}

private _setCollapseState(state: boolean) {
this.sideCollapsed?.next(state);
this.sideCollapsedChange.emit(state);
}
}
Loading

0 comments on commit 8372853

Please sign in to comment.