UNPKG

3.91 kBMarkdownView Raw
1## TdLayoutComponent - td-layout
2
3`<td-layout>` is a blank main sidenav component that gets hooked as parent of all the other layouts. (triggered by their menu buttons)
4
5## API Summary
6
7#### Inputs
8
9- mode: 'over' | 'side' | 'push'
10 - The mode or styling of the sidenav. Defaults to 'over'.
11- opened: boolean
12 - Whether or not the sidenav is opened. Use this binding to open/close the sidenav.
13 - Defaults to 'false'.
14- sidenavWidth: string
15 - Sets the 'width' of the sidenav in either 'px' or '%'.
16 - Defaults to '320px'.
17- containerAutosize: boolean
18 - Sets 'autosize' of the sidenav-container.
19 - Defaults to 'false'.
20
21## Usage
22
23`[td-sidenav-content]` is used to include content in the main sidenav.
24
25Example for Main Layout:
26
27```html
28<td-layout [mode]="'side'" [opened]="true" [sidenavWidth]="'257px'">
29 <div td-sidenav-content>.. more sidenav content</div>
30 .. main content
31</td-layout>
32```
33
34To toggle/close/open the main sidenav from child layouts/components, you can use the `[tdLayoutToggle]`, `[tdLayoutClose]` or `[tdLayoutOpen]` directives on any element and its click event will trigger the sidenav action.
35
36Example:
37
38```html
39<button mat-icon-button [tdLayoutToggle]="true">
40 // or tdLayoutOpen / tdLayoutClose
41 <mat-icon>menu</mat-icon>
42</button>
43```
44
45To disable the sidenav action, just set the input to false.
46
47```html
48<button mat-icon-button [tdLayoutToggle]="false">
49 <mat-icon>menu</mat-icon>
50</button>
51```
52
53## Installation
54
55This component can be installed as npm package.
56
57```bash
58npm i -save @covalent/core
59```
60
61## Setup
62
63Import the **[CovalentLayoutModule]** in your NgModule:
64
65```typescript
66import { CovalentLayoutModule } from '@covalent/core/layout';
67@NgModule({
68 imports: [
69 CovalentLayoutModule,
70 ...
71 ],
72 ...
73})
74export class MyModule {}
75```
76
77### Theming
78
79See [theming](https://teradata.github.io/covalent/#/docs/theme) in the covalent docs for more info.
80
81## TdNavigationDrawerComponent - td-navigation-drawer
82
83`<td-navigation-drawer>` is a component that follows the [material design spec](https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specs) is used as an addon component for `td-layout`.
84
85## API Summary
86
87#### Inputs
88
89- sidenavTitle: string
90 - Title set in toolbar.
91- icon: string
92 - Icon name to be displayed before the title.
93- logo: string
94 - Logo icon name to be displayed before the title.
95 - If [icon] is set, then this will not be shown.
96- avatar: string
97 - Avatar url to be displayed before the title.
98 - If [icon] or [logo] are set, then this will not be shown.
99- color: string
100 - Optional sidenav toolbar color.
101- navigationRoute: string
102 - Option to set the combined route for the icon, logo, and sidenavTitle.
103- backgroundUrl: SafeResourceUrl
104 - Image to be displayed as the background of the toolbar.
105 - URL used will be sanitized, but it should be always from a trusted source to avoid XSS.
106- name: string
107 - String to be displayed as part of the navigation drawer sublabel.
108 - If [email] is not set, then [name] will be the toggle menu text.
109- email: string
110 - String to be displayed as part of the navigation drawer sublabel in the [toggle] menu text.
111 - If [email] and [name] are not set, then the toggle menu is not rendered.
112
113## Usage
114
115`[td-sidenav-content]` is used to include content in the main sidenav.
116
117`[td-navigation-drawer-menu]` is used to include content to the `toggle` user menu. if no tag is used, then the toggle button dissapears.
118
119Example for Main Layout / Navigation Drawer Combo:
120
121```html
122<td-layout>
123 <td-navigation-drawer
124 sidenavTitle="title"
125 logo="logo"
126 icon="icon"
127 name="name"
128 password="password"
129 color="color"
130 navigationRoute="/"
131 >
132 .. main drawer content
133 <div tdNavigationDrawerMenu>.. menu drawer content</div>
134 </td-navigation-drawer>
135 <div td-sidenav-content>.. more sidenav content</div>
136 .. main content
137</td-layout>
138```