-
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.
fix: split button title take 2 (#3239)
* split button title take 2 * docs improvements, add fixedWidth input * button behavior fixed + examples * revert long text for first example * fix bug where new menu items would not be subscribed if added after content init * fix tests * put back ngOnChanges * use object for main action * titleTemplate should reset after option is picked * fix weird bug with button resizing if dev uses titleTemplate * better solution for width issue * keepMainAction should go in MainAction interface * fix bug * pr comments * use forEach * pr comments * remove init * first unsubscribes automatically * move menu item selection logic to separate function
- Loading branch information
1 parent
c80556f
commit 16e480f
Showing
17 changed files
with
423 additions
and
52 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...p/core/component-docs/split-button/examples/split-button-behaviors-example.component.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,71 @@ | ||
Default behavior: | ||
<fd-split-button (primaryButtonClicked)="alert('primary button clicked')"> | ||
<fd-menu> | ||
<li fd-menu-item (click)="alert('option1 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 1</span> | ||
</div> | ||
</li> | ||
<li fd-menu-item (click)="alert('option2 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 2</span> | ||
</div> | ||
</li> | ||
</fd-menu> | ||
</fd-split-button> | ||
|
||
<br/><br/> | ||
|
||
Main Action: | ||
<fd-split-button (primaryButtonClicked)="alert('primary button clicked')" [mainAction]="mainActionObject"> | ||
<fd-menu> | ||
<li fd-menu-item (click)="alert('option1 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 1</span> | ||
</div> | ||
</li> | ||
<li fd-menu-item (click)="alert('option2 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 2 with long text</span> | ||
</div> | ||
</li> | ||
</fd-menu> | ||
</fd-split-button> | ||
|
||
<br/><br/> | ||
|
||
Keep Main Action: | ||
<fd-split-button (primaryButtonClicked)="alert('primary button clicked')" [mainAction]="{mainActionTitle: 'Primary Button', keepMainAction: true}"> | ||
<fd-menu> | ||
<li fd-menu-item (click)="alert('option1 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 1</span> | ||
</div> | ||
</li> | ||
<li fd-menu-item (click)="alert('option2 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 2 with long text</span> | ||
</div> | ||
</li> | ||
</fd-menu> | ||
</fd-split-button> | ||
|
||
<br/><br/> | ||
|
||
fixedWidth = false: | ||
<fd-split-button (primaryButtonClicked)="alert('primary button clicked')" [fixedWidth]="false"> | ||
<fd-menu> | ||
<li fd-menu-item (click)="alert('option1 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 1</span> | ||
</div> | ||
</li> | ||
<li fd-menu-item (click)="alert('option2 clicked')"> | ||
<div fd-menu-interactive> | ||
<span fd-menu-title>Option 2 with long text</span> | ||
</div> | ||
</li> | ||
</fd-menu> | ||
</fd-split-button> | ||
|
||
<br/><br/> |
25 changes: 25 additions & 0 deletions
25
...app/core/component-docs/split-button/examples/split-button-behaviors-example.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,25 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-split-button-behaviors-example', | ||
templateUrl: './split-button-behaviors-example.component.html', | ||
styles: [ | ||
` | ||
fd-split-button { | ||
margin-right: 12px; | ||
} | ||
` | ||
] | ||
}) | ||
export class ButtonSplitBehaviorsComponent { | ||
|
||
mainActionObject = { | ||
mainActionTitle: 'Main Action', | ||
callback: () => {window.alert('main action clicked')} | ||
}; | ||
|
||
alert(message: string): void { | ||
window.alert(message); | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...pp/core/component-docs/split-button/examples/split-button-template-example.component.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
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
Oops, something went wrong.