-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(demo): add page for
Sidebar
directive (#125)
- Loading branch information
Showing
13 changed files
with
236 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
projects/demo/src/modules/directives/sidebar/examples/1/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<button | ||
tuiButton | ||
type="button" | ||
(click)="toggle(true)" | ||
(tuiActiveZoneChange)="toggle($event)" | ||
> | ||
Show sidebar | ||
<!-- Nest the directive so it is considered the same active zone --> | ||
<div *tuiSidebar="open; direction: 'right'"> | ||
<tui-accordion [rounded]="false"> | ||
<tui-accordion-item borders="top-bottom"> | ||
Web APIs for Angular | ||
<ng-template tuiAccordionItemContent> | ||
<a | ||
*ngFor="let link of webApis" | ||
tuiLink | ||
class="link" | ||
target="_blank" | ||
href="https://github.com/ng-web-apis/{{link}}" | ||
> | ||
{{link}} | ||
</a> | ||
</ng-template> | ||
</tui-accordion-item> | ||
<tui-accordion-item borders="top-bottom"> | ||
Other libraries | ||
<ng-template tuiAccordionItemContent> | ||
<a | ||
*ngFor="let link of tinkoff" | ||
tuiLink | ||
class="link" | ||
target="_blank" | ||
href="https://github.com/TinkoffCreditSystems/{{link}}" | ||
> | ||
{{link}} | ||
</a> | ||
</ng-template> | ||
</tui-accordion-item> | ||
</tui-accordion> | ||
</div> | ||
</button> |
4 changes: 4 additions & 0 deletions
4
projects/demo/src/modules/directives/sidebar/examples/1/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.link { | ||
display: block; | ||
margin: 12px 0; | ||
} |
34 changes: 34 additions & 0 deletions
34
projects/demo/src/modules/directives/sidebar/examples/1/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '../../../../../change-detection-strategy'; | ||
import {encapsulation} from '../../../../../view-encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-sidebar-example-1', | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiSidebarExample1 { | ||
open = false; | ||
|
||
readonly webApis = [ | ||
'Common', | ||
'Audio', | ||
'Canvas', | ||
'Geolocation', | ||
'MIDI', | ||
'Workers', | ||
]; | ||
|
||
readonly tinkoff = [ | ||
'Taiga-UI', | ||
'ng-event-plugins', | ||
'ng-polymorpheus', | ||
'ng-dompurify', | ||
]; | ||
|
||
toggle(open: boolean) { | ||
this.open = open; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
projects/demo/src/modules/directives/sidebar/examples/import/component.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
open = false; | ||
|
||
toggle(open: boolean) { | ||
this.open = open; | ||
} |
12 changes: 12 additions & 0 deletions
12
projects/demo/src/modules/directives/sidebar/examples/import/import-module.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {TuiSidebarModule} from '@taiga-ui/addon-mobile'; | ||
import {TuiActiveZoneModule} from '@taiga-ui/cdk'; | ||
|
||
... | ||
|
||
@NgModule({ | ||
imports: [ | ||
... | ||
TuiSidebarModule, | ||
TuiActiveZoneModule, | ||
], | ||
... |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/directives/sidebar/examples/import/insert-template.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<button | ||
tuiButton | ||
type="button" | ||
(click)="toggle(true)" | ||
(tuiActiveZoneChange)="toggle($event)" | ||
> | ||
Show sidebar | ||
<div *tuiSidebar="open"> | ||
Content | ||
</div> | ||
</button> |
27 changes: 27 additions & 0 deletions
27
projects/demo/src/modules/directives/sidebar/sidebar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {default as example1Html} from '!!raw-loader!./examples/1/index.html'; | ||
import {default as example1Less} from '!!raw-loader!./examples/1/index.less'; | ||
import {default as example1Ts} from '!!raw-loader!./examples/1/index.ts'; | ||
import {default as exampleComponent} from '!!raw-loader!./examples/import/component.txt'; | ||
import {default as exampleImportModule} from '!!raw-loader!./examples/import/import-module.txt'; | ||
import {default as exampleInsertTemplate} from '!!raw-loader!./examples/import/insert-template.txt'; | ||
|
||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '../../../change-detection-strategy'; | ||
import {FrontEndExample} from '../../interfaces/front-end-example'; | ||
|
||
@Component({ | ||
selector: 'example-tui-sidebar', | ||
templateUrl: './sidebar.template.html', | ||
changeDetection, | ||
}) | ||
export class ExampleTuiSidebarComponent { | ||
readonly example1: FrontEndExample = { | ||
TypeScript: example1Ts, | ||
HTML: example1Html, | ||
LESS: example1Less, | ||
}; | ||
|
||
readonly exampleImportModule = exampleImportModule; | ||
readonly exampleInsertTemplate = exampleInsertTemplate; | ||
readonly exampleComponent = exampleComponent; | ||
} |
26 changes: 26 additions & 0 deletions
26
projects/demo/src/modules/directives/sidebar/sidebar.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule} from '@angular/router'; | ||
import {generateRoutes, TUI_DOC_PAGE_MODULES} from '@taiga-ui/addon-doc'; | ||
import {TuiSidebarModule} from '@taiga-ui/addon-mobile'; | ||
import {TuiActiveZoneModule} from '@taiga-ui/cdk'; | ||
import {TuiButtonModule, TuiLinkModule} from '@taiga-ui/core'; | ||
import {TuiAccordionModule} from '@taiga-ui/kit'; | ||
import {TuiSidebarExample1} from './examples/1'; | ||
import {ExampleTuiSidebarComponent} from './sidebar.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
TuiSidebarModule, | ||
TuiActiveZoneModule, | ||
TuiButtonModule, | ||
TuiAccordionModule, | ||
TuiLinkModule, | ||
...TUI_DOC_PAGE_MODULES, | ||
RouterModule.forChild(generateRoutes(ExampleTuiSidebarComponent)), | ||
], | ||
declarations: [ExampleTuiSidebarComponent, TuiSidebarExample1], | ||
exports: [ExampleTuiSidebarComponent], | ||
}) | ||
export class ExampleTuiSidebarModule {} |
52 changes: 52 additions & 0 deletions
52
projects/demo/src/modules/directives/sidebar/sidebar.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<tui-doc-page i18n-header header="Sidebar" package="ADDON-MOBILE"> | ||
<ng-template pageTab> | ||
<p i18n> | ||
Directive allows to show arbitrary content in a sidebar above all content. | ||
A darkening overlay is shown under the sidebar. | ||
</p> | ||
|
||
<tui-doc-example | ||
id="basic" | ||
i18n-heading | ||
heading="Basic" | ||
[content]="example1" | ||
> | ||
<tui-sidebar-example-1></tui-sidebar-example-1> | ||
</tui-doc-example> | ||
</ng-template> | ||
|
||
<ng-template i18n-pageTab pageTab="Setup"> | ||
<ol class="b-demo-steps"> | ||
<li> | ||
<p i18n> | ||
Import <code>TuiSidevarModule</code> into your component | ||
module. Also add <code>TuiActiveZoneModule</code> if you want | ||
to close sidebar when user clicked outside: | ||
</p> | ||
|
||
<tui-doc-code | ||
filename="myComponent.module.ts" | ||
[code]="exampleImportModule" | ||
></tui-doc-code> | ||
</li> | ||
|
||
<li> | ||
<p i18n>Add to the template:</p> | ||
|
||
<tui-doc-code | ||
filename="myComponent.template.html" | ||
[code]="exampleInsertTemplate" | ||
></tui-doc-code> | ||
</li> | ||
|
||
<li> | ||
<p i18n>Control sidebar in component</p> | ||
|
||
<tui-doc-code | ||
filename="myComponent.component.ts" | ||
[code]="exampleComponent" | ||
></tui-doc-code> | ||
</li> | ||
</ol> | ||
</ng-template> | ||
</tui-doc-page> |