-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added button group docs (#782)
* added button group docs * fixed tests
- Loading branch information
Showing
3 changed files
with
86 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, HostBinding } from '@angular/core'; | ||
|
||
/** | ||
* Container for grouped buttons. | ||
* | ||
* ```html | ||
* <fd-button-group> | ||
* <button fd-button-grouped>Button</button> | ||
* </fd-button-group> | ||
* ``` | ||
*/ | ||
@Component({ | ||
selector: 'fd-button-group', | ||
templateUrl: './button-group.component.html', | ||
host: { | ||
'role': 'group', | ||
'aria-label': 'Group label', | ||
class: 'fd-button-group' | ||
'role': 'group' | ||
} | ||
}) | ||
export class ButtonGroupComponent {} | ||
export class ButtonGroupComponent { | ||
|
||
/** @hidden */ | ||
@HostBinding('class.fd-button-group') | ||
fdButtonGroupClass: boolean = true; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
import { Directive, ElementRef, Inject, Input } from '@angular/core'; | ||
import { Directive, ElementRef, HostBinding, Input } from '@angular/core'; | ||
import { AbstractFdNgxClass } from '../utils/abstract-fd-ngx-class'; | ||
|
||
/** | ||
* Directive to be applied to buttons that are members of a button group. | ||
* | ||
* ```html | ||
* <button fd-button-grouped>Button</button> | ||
* ``` | ||
*/ | ||
@Directive({ | ||
// TODO to be discussed | ||
// tslint:disable-next-line:directive-selector | ||
selector: '[fd-button-grouped]' | ||
}) | ||
export class ButtonGroupedDirective extends AbstractFdNgxClass { | ||
@Input() id: string; | ||
|
||
@Input() size: string; | ||
/** Size of the button. Can be `xs`, `s`, or left blank for large size. */ | ||
@Input() | ||
size: string; | ||
|
||
@Input() glyph: string; | ||
/** Glyph (icon) of the button. */ | ||
@Input() | ||
glyph: string; | ||
|
||
@Input() state: string; | ||
/** State of the button. Can be `selected` or `disabled`. */ | ||
@Input() | ||
state: string; | ||
|
||
@Input() compact: boolean = false; | ||
/** Whether the button should be in compact form. */ | ||
@Input() | ||
@HostBinding('class.fd-button--compact') | ||
compact: boolean = false; | ||
|
||
/** @hidden */ | ||
@HostBinding('class.fd-button--grouped') | ||
fdButtonGroupedClass: boolean = true; | ||
|
||
/** @hidden */ | ||
constructor(private elementRef: ElementRef) { | ||
super(elementRef); | ||
} | ||
|
||
/** @hidden */ | ||
_setProperties() { | ||
this._addClassToElement('fd-button--grouped'); | ||
if (this.size) { | ||
this._addClassToElement('fd-button--' + this.size); | ||
} | ||
if (this.glyph) { | ||
this._addClassToElement('sap-icon--' + this.glyph); | ||
} | ||
if (this.compact) { | ||
this._addClassToElement('fd-button--compact'); | ||
} | ||
if (this.state) { | ||
this._addClassToElement('is-' + this.state); | ||
} | ||
} | ||
|
||
constructor(@Inject(ElementRef) elementRef: ElementRef) { | ||
super(elementRef); | ||
} | ||
} |