Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(dropdown): update documentation for dropdown #1438

Merged
merged 1 commit into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="btn-group" dropdown>
<button id="single-button" type="button" class="btn btn-primary" dropdownToggle>
This dropdown's menu is right-aligned <span class="caret"></span>
</button>
<ul dropdownMenu role="menu" aria-labelledby="single-button" class="dropdown-menu-right">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-dropdown-alignment',
templateUrl: './menu-alignment.html'
})
export class DemoDropdownAlignmentComponent {
}
27 changes: 11 additions & 16 deletions demo/src/app/components/dropdown/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<div (click)="$event.preventDefault()">
<div class="btn-group" dropdown [isOpen]="status.isopen">
<button id="single-button" type="button" class="btn btn-primary" dropdownToggle [disabled]="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul dropdownMenu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
<button type="button" class="btn btn-primary" (click)="toggleDropdown($event)">Toggle button dropdown
</button>
<button type="button" class="btn btn-warning" (click)="disabled = !disabled">Enable/Disable</button>
<div class="btn-group" dropdown>
<button id="single-button" type="button" class="btn btn-primary" dropdownToggle>
Button dropdown <span class="caret"></span>
</button>
<ul dropdownMenu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
8 changes: 0 additions & 8 deletions demo/src/app/components/dropdown/demos/basic/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@ import { Component } from '@angular/core';
templateUrl: './basic.html'
})
export class DemoDropdownBasicComponent {
public disabled: boolean = false;
public status: {isopen: boolean} = {isopen: false};

public toggleDropdown($event:MouseEvent):void {
$event.preventDefault();
$event.stopPropagation();
this.status.isopen = !this.status.isopen;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="btn-group" dropdown>
<button id="single-button" type="button" class="btn btn-primary" dropdownToggle [disabled]="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul dropdownMenu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
<button type="button" class="btn btn-warning" (click)="disabled = !disabled">Enable/Disable</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-dropdown-disabled',
templateUrl: './disabled-menu.html'
})
export class DemoDropdownDisabledComponent {
public disabled: boolean = false;
}
18 changes: 17 additions & 1 deletion demo/src/app/components/dropdown/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import { DemoDropdownBasicLinkComponent } from './basic/basic-link';
import { DemoDropdownKeyboardComponent } from './keyboard/keyboard';
import { DemoDropdownConfigComponent } from './config/config';
import { DemoDropupComponent } from './dropup/dropup';
import { DemoDropdownTriggersManualComponent } from './triggers-manual/triggers-manual';
import { DemoDropdownDisabledComponent } from './disabled-menu/disabled-menu';
import { DemoDropdownAlignmentComponent } from './alignment/menu-alignment';

export const DEMO_COMPONENTS = [
DropdownDemoComponent, DemoDropdownBasicComponent, DemoDropdownBasicLinkComponent, DemoDropdownSplitComponent,
DemoDropdownContainerComponent, DemoDropdownKeyboardComponent, DemoDropdownConfigComponent, DemoDropupComponent
DemoDropdownContainerComponent, DemoDropdownKeyboardComponent, DemoDropdownConfigComponent, DemoDropupComponent,
DemoDropdownTriggersManualComponent, DemoDropdownDisabledComponent, DemoDropdownAlignmentComponent
];

export const DEMOS = {
Expand All @@ -30,6 +34,18 @@ export const DEMOS = {
component: require('!!raw?lang=typescript!./container/container.ts'),
html: require('!!raw?lang=markup!./container/container.html')
},
triggersManual: {
component: require('!!raw?lang=typescript!./triggers-manual/triggers-manual.ts'),
html: require('!!raw?lang=markup!./triggers-manual/triggers-manual.html')
},
disabledMenu: {
component: require('!!raw?lang=typescript!./disabled-menu/disabled-menu.ts'),
html: require('!!raw?lang=markup!./disabled-menu/disabled-menu.html')
},
alignment: {
component: require('!!raw?lang=typescript!./alignment/menu-alignment.ts'),
html: require('!!raw?lang=markup!./alignment/menu-alignment.html')
},
keyboard: {
component: require('!!raw?lang=typescript!./keyboard/keyboard.ts'),
html: require('!!raw?lang=markup!./keyboard/keyboard.html')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div (click)="$event.preventDefault()">
<div class="btn-group" dropdown [isOpen]="status.isopen">
<button id="single-button" type="button" class="btn btn-primary" dropdownToggle>
Button dropdown <span class="caret"></span>
</button>
<ul dropdownMenu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
<button type="button" class="btn btn-primary" (click)="toggleDropdown($event)">Toggle button dropdown</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-dropdown-triggers-manual',
templateUrl: './triggers-manual.html'
})
export class DemoDropdownTriggersManualComponent {
public status: {isopen: boolean} = {isopen: false};

public toggleDropdown($event: MouseEvent): void {
$event.preventDefault();
$event.stopPropagation();
this.status.isopen = !this.status.isopen;
}
}
28 changes: 26 additions & 2 deletions demo/src/app/components/dropdown/dropdown-section.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ let titleDoc = require('html!markdown!./docs/title.md');
<ul>
<li><a pageScroll href="#single-button">Single button dropdowns</a></li>
<li><a pageScroll href="#split-button">Split button dropdowns</a></li>
<li><a pageScroll href="#triggers-manual">Manual triggers</a></li>
<li><a pageScroll href="#disabled-menu">Disabled menu</a></li>
<li><a pageScroll href="#alignment">Menu alignment</a></li>
<li><a pageScroll href="#container-body">Append to body</a></li>
<li><a pageScroll href="#keyboard">Single button with keyboard nav</a></li>
<li><a pageScroll href="#dropup">Dropup variation</a></li>
Expand All @@ -39,7 +42,7 @@ let titleDoc = require('html!markdown!./docs/title.md');
<h2 id="examples">Examples</h2>
<p>Wrap the dropdown’s toggle (your button or link) and the dropdown menu within <code>dropdown</code>.
Dropdowns can be triggered from <code> &lt;a&gt;</code> or <code> &lt;button&gt;</code> elements to better fit your potential needs.</p>
<!-- basic -->

<h2 id="single-button">Single button dropdowns</h2>

<p>Any single <code>.btn</code> can be turned into a dropdown toggle with some markup changes.
Expand All @@ -63,6 +66,27 @@ let titleDoc = require('html!markdown!./docs/title.md');
<demo-dropdown-split></demo-dropdown-split>
</ng-sample-box>

<h2 id="triggers-manual">Manual triggers</h2>

<ng-sample-box [ts]="demos.triggersManual.component" [html]="demos.triggersManual.html">
<demo-dropdown-triggers-manual></demo-dropdown-triggers-manual>
</ng-sample-box>

<h2 id="disabled-menu">Disabled menu</h2>

<ng-sample-box [ts]="demos.disabledMenu.component" [html]="demos.disabledMenu.html">
<demo-dropdown-disabled></demo-dropdown-disabled>
</ng-sample-box>

<h2 id="alignment">Menu alignment</h2>

<p>By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent.
Add class <code>.dropdown-menu-right</code> to a <code>dropdownMenu</code> to right align the dropdown menu.</p>

<ng-sample-box [ts]="demos.alignment.component" [html]="demos.alignment.html">
<demo-dropdown-alignment></demo-dropdown-alignment>
</ng-sample-box>

<h2 id="container-body">Append to body</h2>

<ng-sample-box [ts]="demos.container.component" [html]="demos.container.html">
Expand All @@ -81,7 +105,7 @@ let titleDoc = require('html!markdown!./docs/title.md');
</ng-sample-box>

<h2 id="config">Configuring defaults</h2>
<p>It is possible to override default alert config partially or completely.</p>
<p>It is possible to override default dropdown config partially or completely.</p>
<ng-sample-box [ts]="demos.config.component" [html]="demos.config.html">
<demo-dropdown-config></demo-dropdown-config>
</ng-sample-box>
Expand Down