2.0.0 • Published 3 years ago

@terminus/ui-drawer v2.0.0

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

CI/CD Status Codecov MIT License
NPM version Library size

The drawer component is designed to add side content to a section of the DOM.

Table of Contents

Installation

Packages that need to be installed

  • @angular/cdk
  • @angular/common
  • @angular/core
  • @angular/flex-layout
  • @angular/forms
  • @angular/platform-browser
  • @terminus/design-tokens
  • @terminus/fe-utilities
  • @terminus/ui-utilities
  • @terminus/ui-expansion-panel
  • date-fns
  • tslib

Use the ng add command to quickly install all the needed dependencies:

ng add @terminus/ui-drawer

Modules that need to be in NgModule

  • BrowserAnimationsModule
  • TsDrawerModule

CSS imports

In your top level stylesheet, add these imports:

@import '~@terminus/design-tokens/css/library-design-tokens.css';
@import '~@terminus/ui-styles/terminus-ui.css';

CSS resources

Load the needed font families by adding this link to the <head> of your application:

<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">

Usage

Define a container, a drawer, and the page content:

<ts-drawer-container>
  <ts-drawer mode="push" posistion="start">
    <div>Inside drawer</div>
  </ts-drawer>
  
  <ts-drawer-content>
    <div>Main content</div>
  </ts-drawer-content>
</ts-drawer-container>

Backdrop

If hasBackdrop is set to true, users can close the drawer by clicking outside (default is false):

<ts-drawer-container hasBackdrop="true">
  <ts-drawer>...</ts-drawer>
</ts-drawer-container>

Mode

The mode defines how the page content reacts to the drawer. A drawer can open over the page content (overlay) or push (push) the content to make room for the drawer (default is overlay):

<ts-drawer [mode]="push">...</ts-drawer>

Position

Consumers can specify which side of the container the drawer opens from. The default is start which opens from the left side of the page. If set to end, it would expand the drawer from right of the page.

<ts-drawer [position]="end">...</ts-drawer>

NOTE: An error will be thrown if more than one drawer in a given container has the same position AND push mode set.

Collapsed and expanded sizes

The size of a drawer when it's collapsed and expanded can be customized:

<ts-drawer
  [collapsedSize]="2rem"
  [expandedSize]="12rem"
>...</ts-drawer>

NOTE: collapsedSize defaults to 3.75rem and expandedSize to 12.5rem.

Expand on load

The drawer can be forced to expand on load:

<ts-drawer [isExpanded]="true">...</ts-drawer>

Hide shadow when collapsed

When a drawer is expanded, there is box shadow around the drawer. When a drawer is collapsed, if input hideShadowWhenCollapsed set to false and collapseSize greater than 0, there is box shadow shown; otherwise, no box shadow.

<ts-drawer [hideShadowWhenCollapsed]="true">...</ts-drawer>

Fixed header and footer

The drawer supports both a header and footer:

<ts-drawer-header>
  My header content...
</ts-drawer-header>
<ts-drawer-footer>
  My footer content...
</ts-drawer-footer>

Events

Container events

EventDescriptionPayload
backdropClickFired when backdrop is clickedvoid

Drawer events

EventDescriptionPayload
expandedStartFired when the drawer expansion startsvoid
collapsedStartFired when the drawer collapse startsvoid
expandedChangeFired when state change ends (animation ends)boolean
2.0.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago