Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Drop down primary (#819)
Browse files Browse the repository at this point in the history
* added primary in html class

* testing for primary dropdown option

* lint errors fixed

* documentation fixes from john

* documentation changes

* changed isPrimary boolean property to buttonStyle string property

* fixed test errors
  • Loading branch information
Blackbaud-SandhyaRajasabeson authored and Blackbaud-PatrickOFriel committed Jun 21, 2017
1 parent 4d4d26a commit 95dba71
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/app/components/dropdown/dropdown-demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<li>
Select primary style:
<br>
<sky-dropdown isPrimary="true">
<sky-dropdown buttonStyle="primary">
<sky-dropdown-button>
Show dropdown
</sky-dropdown-button>
Expand All @@ -60,7 +60,7 @@
<li>
Context menu with primary style:
<br>
<sky-dropdown buttonType="context-menu" isPrimary="true">
<sky-dropdown buttonType="context-menu" buttonStyle="primary">
<sky-dropdown-menu>
<sky-dropdown-item>
<button type="button">
Expand All @@ -73,7 +73,7 @@
<li>
Icon with primary style:
<br>
<sky-dropdown buttonType="folder-open-o" isPrimary="true">
<sky-dropdown buttonType="folder-open-o" buttonStyle="primary">
<sky-dropdown-menu>
<sky-dropdown-item>
<button type="button">
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/dropdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
Specifies the type of button to render as the dropdown's trigger element. Specify <code>select</code> to display a button with text and a caret or <code>context-menu</code> to display a round button containing an ellipsis. You can also specify a font-awesome icon as the content of the dropdown by passing the class name to the <code>buttonType</code> attribute. For example, setting <code>buttonType</code> to <code>filter</code> would set the <code>fa-filter</code> icon as the content of the dropdown button. If you use the <code>select</code> style you will need to include a <code>sky-dropdown-button</code> element to specify the text for the button.
</sky-demo-page-property>
<sky-demo-page-property
propertyName="isPrimary"
propertyName="buttonStyle"
isOptional="true"
defaultValue="false"
defaultValue="default"
>
Indicates whether the button invokes primary action for a page or form. When set to <code>true</code>, the background color is <code>sky-color-blue</code>. By default, the button's background color is <code>sky-color-white</code>.
Specifies the background color of the dropdown's trigger element. if unspecified it is set to <code>default</code> for background color <code>sky-color-white</code>. Specify <code>primary</code> to change color to <code>sky-color-blue</code>.
</sky-demo-page-property>
<sky-demo-page-property
propertyName="label"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/dropdown/dropdown.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="sky-btn sky-dropdown-button"
[ngClass]="[
'sky-dropdown-button-type-' + buttonType,
isPrimary ? 'sky-btn-primary' : 'sky-btn-default'
'sky-btn-' + buttonStyle
]"
(document:click)="windowClick()"
[attr.aria-label]="label"
Expand Down
6 changes: 3 additions & 3 deletions src/modules/dropdown/dropdown.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('Dropdown component', () => {
expect(getDropdownBtnEl(el)).toHaveCssClass('sky-dropdown-button-type-context-menu');
});

it('should have a default button background of "sky-btn-default" aka isPrimary is false', () => {
it('should have a default button background of "sky-btn-default"', () => {
let fixture = TestBed.createComponent(DropdownTestComponent);
let el: Element = fixture.nativeElement;

Expand All @@ -342,12 +342,12 @@ describe('Dropdown component', () => {
expect(getDropdownBtnEl(el)).toHaveCssClass('sky-btn-default');
});

it('should set the CSS class to primary when isPrimary is true', () => {
it('should set the CSS class based on buttonStyle changes', () => {
let fixture = TestBed.createComponent(DropdownTestComponent);
let cmp = fixture.componentInstance;
let el: Element = fixture.nativeElement;

cmp.isPrimary = true;
cmp.buttonStyle = 'primary';

fixture.detectChanges();

Expand Down
10 changes: 5 additions & 5 deletions src/modules/dropdown/dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export class SkyDropdownComponent implements OnDestroy {
public alignment: string = 'left';

@Input()
public get isPrimary(): boolean {
return this._isPrimary;
public get buttonStyle(): string{
return this._buttonStyle || 'default';
}

public set isPrimary(flag: boolean) {
this._isPrimary = flag;
public set buttonStyle(value: string) {
this._buttonStyle = value;
}

private open = false;
Expand All @@ -61,7 +61,7 @@ export class SkyDropdownComponent implements OnDestroy {

private _buttonType: string;

private _isPrimary: boolean;
private _buttonStyle: string;

private _trigger: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export class DropdownParentTestComponent {
public trigger: String;
public buttonType: String;
public myTitle: string;
public isPrimary: boolean;
public buttonStyle: String;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[trigger]="trigger"
[title]="myTitle"
[alignment]="alignment"
[isPrimary]="isPrimary">
[buttonStyle]="buttonStyle">
<sky-dropdown-button>
Show dropdown
</sky-dropdown-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export class DropdownTestComponent {
public buttonType: String;
public myTitle: string;
public alignment: string = 'left';
public isPrimary: boolean;
public buttonStyle: string;
}

0 comments on commit 95dba71

Please sign in to comment.