4.0.0 • Published 2 years ago

ng-sidebar-accordion v4.0.0

Weekly downloads
30
License
MIT
Repository
github
Last release
2 years ago

ng-sidebar-accordion

NPM

An Angular sidebar accordion component.

Demo

Installation

npm install ng-sidebar-accordion

Changelog

See the releases page on GitHub.

Usage

Add SidebarAccordionModule to your app module

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {SidebarAccordionModule} from 'ng-sidebar-accordion';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    SidebarAccordionModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

In your app component, simply use add a <ng-sidebar-accordion> wrapper, then place your <ng-sidebar>(s) and content within it. Your page content should be in container <ng-sidebar-accordion-content>.

@Component({
  selector: 'app',
  template: `
    <!-- Container for sidebar(s) + page content -->
    <ng-sidebar-accordion #accordion>
      <!-- A sidebar -->
      <ng-sidebar position="right" [opened]="true">
        <ng-sidebar-header>
          <div>
            <div>right-pane0-header-row1</div>
            <div>right-pane0-header-row2</div>
          </div>
        </ng-sidebar-header>
        
        <ng-sidebar-content>
          right-pane0-content
        </ng-sidebar-content>
      </ng-sidebar>

      <!-- Page content -->
      <ng-sidebar-accordion-content>
        <button
          (click)="accordion.open('right')">
          open
        </button>
        <button
          (click)="accordion.close('right')">
          close
        </button>
      </ng-sidebar-accordion-content>
    </ng-sidebar-accordion>
  `
})
class AppComponent {  
}

Functions

The SidebarAccordion has a few public functions:

FunctionDescription
open(position, index)Opens sidebars. positions - ('all', 'left', 'top', 'right', 'bottom'); index - position the side panel
close(position)Closes sidebars. positions - ('all', 'left', 'top', 'right', 'bottom');
getSidebarIndex(sidebar)returns the index of the sidebar in an array of a specific position.

The Sidebar has a few public functions:

FunctionDescription
open()Opens this sidebar.
close()Closes this sidebar.

Styling

Various class names are attached to the sidebar and container for easier styling.

SidebarAccordion

Class nameDescription
ng-sidebar-accordionAlways present on the container element.
ng-sidebar-accordion__left-paneAlways present on the element where panels are placed on the left edge.
ng-sidebar-accordion__top-paneAlways present on the element where panels are placed at the top edge.
ng-sidebar-accordion__right-paneAlways present on the element where panels are placed on the right edge.
ng-sidebar-accordion__bottom-paneAlways present on the element where panels are placed along the bottom edge.
ng-sidebar-accordion__left-pane_resizableAppears when resizing the panel is allowed. Left pane.
ng-sidebar-accordion__top-pane_resizableAppears when resizing the panel is allowed. Top pane.
ng-sidebar-accordion__right-pane_resizableAppears when resizing the panel is allowed. Right pane.
ng-sidebar-accordion__bottom-pane_resizableAppears when resizing the panel is allowed. Bottom pane.
ng-sidebar-accordion__left-pane_overAppears when panel mode is set to`over'. Left pane.
ng-sidebar-accordion__top-pane_overAppears when panel mode is set to`over'. Top pane.
ng-sidebar-accordion__right-pane_overAppears when panel mode is set to`over'. Right side.
ng-sidebar-accordion__bottom-pane_overAppears when panel mode is set to`over'. Bottom pane.
ng-sidebar-accordion-contentAlways present on the element where the main content is placed.
ng-sidebar-accordion__gutter-horizontalAppears when resizing the panel is allowed.
ng-sidebar-accordion__gutter-verticalAppears when resizing the panel is allowed.

Sidebar

Class nameDescription
ng-sidebarSidebar element.
ng-sidebar-headerThe title of the sidebar.
ng-sidebar-header__contentContent of the sidebar header.
ng-sidebar-contentContents of the sidebar.
ng-sidebar_openedAppears when the sidebar is open.

All the above classes are always present on the element.

Options

<ng-sidebar-accordion>

Inputs

Property nameTypeDefaultDescription
widthstringWidth of the component.
heightstringHeight of the component.
classNamestringCss class.
sidebarResizablebooleanfalseA flag that specifies whether or not the sidebar can be resized.

Outputs

Property nameCallback argumentsDescription
sidebarResizableBeginpositionEmitted when the sidebar size change starts.
sidebarResizableEndpositionEmitted when the sidebar size change ends.
sidebarOpenedChangeSidebarComponentEmitted when sidebar state changes.

position: 'left', 'right', 'top', 'bottom'

<ng-sidebar>

Inputs

Property nameTypeDefaultDescription
position'left', 'right', 'top', 'bottom'The position where to place the sidebar.
classNamestringCss class.
openedbooleanfalseState sidebar.
pinnedbooleanfalsePin the sidebar

Outputs

Property nameCallback argumentsDescription
openedChange{ sender: SidebarComponent, opened: boolean }Emitted when the sidebar state changes.
headerClickedSidebarComponentEmitted when the sidebar header clicked.
headerTouchMovedSidebarMouseTouchEventArgsEmitted when the sidebar header touch moved
headerTouchEndedSidebarMouseTouchEventArgsEmitted when the sidebar header touch ended

<ng-sidebar-settings>

Used to configure sidebar mode

Inputs

Property nameTypeDefaultDescription
position'left', 'right', 'top', 'bottom'The sidebar position for which settings are applied.
mode'push', 'over'Sidebars mode.

Outputs

Property nameCallback argumentsDescription
modeChangeSidebarSettingsComponentEmitted when the mode is change.
positionChangeSidebarSettingsComponentEmitted when the position is change.
4.0.0

2 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

9.2.0

4 years ago