This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(panel): Panel grouping #9538
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,46 @@ | ||
<div ng-controller="PanelGroupsCtrl as ctrl" ng-cloak> | ||
|
||
<md-toolbar class="md-accent"> | ||
<div class="md-toolbar-tools"> | ||
<md-button | ||
class="md-icon-button" | ||
aria-label="Settings" | ||
ng-click="ctrl.showToolbarMenu($event, ctrl.settings)"> | ||
<md-icon md-svg-icon="img/icons/menu.svg"></md-icon> | ||
</md-button> | ||
<h2>Toolbar with grouped panels (Maximum open: 2)</h2> | ||
<span flex></span> | ||
<md-button | ||
class="md-icon-button" | ||
aria-label="Favorite" | ||
ng-click="ctrl.showToolbarMenu($event, ctrl.favorite)"> | ||
<md-icon md-svg-icon="img/icons/favorite.svg"></md-icon> | ||
</md-button> | ||
<md-button | ||
class="md-icon-button" | ||
aria-label="More" | ||
ng-click="ctrl.showToolbarMenu($event, ctrl.more)"> | ||
<md-icon md-svg-icon="img/icons/more_vert.svg"></md-icon> | ||
</md-button> | ||
</div> | ||
</md-toolbar> | ||
|
||
<md-content layout-padding> | ||
<p> | ||
Panels can be added to a group. Groups are used to configure specific | ||
behaviors on multiple panels. To add a panel to a group, use the | ||
<code>$mdPanel.newPanelGroup</code> method, or simply add a group name | ||
to the configuration object passed into the <code>$mdPanel.create</code> | ||
method. | ||
</p> | ||
<p> | ||
Grouping allows for methods to be applied to several panels at once, i.e. | ||
closing all panels within the toolbar group, or destroying all panels | ||
within a dialog group. With the <code>maxOpen</code> property, you can | ||
also limit the number of panels allowed open within a specific group. This | ||
can be useful in limiting the number of menu panels allowed open at a | ||
time, etc. | ||
</p> | ||
</md-content> | ||
|
||
</div> |
This file contains hidden or 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,88 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular | ||
.module('panelGroupsDemo', ['ngMaterial']) | ||
.controller('PanelGroupsCtrl', PanelGroupsCtrl) | ||
.controller('PanelMenuCtrl', PanelMenuCtrl); | ||
|
||
function PanelGroupsCtrl($mdPanel) { | ||
this.settings = { | ||
name: 'settings', | ||
items: [ | ||
'Home', | ||
'About', | ||
'Contact' | ||
] | ||
}; | ||
this.favorite = { | ||
name: 'favorite', | ||
items: [ | ||
'Add to Favorites' | ||
] | ||
}; | ||
this.more = { | ||
name: 'more', | ||
items: [ | ||
'Account', | ||
'Sign Out' | ||
] | ||
}; | ||
|
||
this.showToolbarMenu = function($event, menu) { | ||
var template = '' + | ||
'<div class="menu-panel" md-whiteframe="4">' + | ||
' <div class="menu-content">' + | ||
' <div class="menu-item" ng-repeat="item in ctrl.items">' + | ||
' <button class="md-button">' + | ||
' <span>{{item}}</span>' + | ||
' </button>' + | ||
' </div>' + | ||
' <md-divider></md-divider>' + | ||
' <div class="menu-item">' + | ||
' <button class="md-button" ng-click="ctrl.closeMenu()">' + | ||
' <span>Close Menu</span>' + | ||
' </button>' + | ||
' </div>' + | ||
' </div>' + | ||
'</div>'; | ||
|
||
var position = $mdPanel.newPanelPosition() | ||
.relativeTo($event.srcElement) | ||
.addPanelPosition( | ||
$mdPanel.xPosition.ALIGN_START, | ||
$mdPanel.yPosition.BELOW | ||
); | ||
|
||
$mdPanel.newPanelGroup('toolbar', { | ||
maxOpen: 2 | ||
}); | ||
|
||
var config = { | ||
id: 'toolbar_' + menu.name, | ||
attachTo: angular.element(document.body), | ||
controller: PanelMenuCtrl, | ||
controllerAs: 'ctrl', | ||
template: template, | ||
position: position, | ||
panelClass: 'menu-panel-container', | ||
locals: { | ||
items: menu.items | ||
}, | ||
openFrom: $event, | ||
focusOnOpen: false, | ||
zIndex: 100, | ||
propagateContainerEvents: true, | ||
groupName: 'toolbar' | ||
}; | ||
|
||
$mdPanel.open(config); | ||
} | ||
} | ||
|
||
function PanelMenuCtrl(mdPanelRef) { | ||
this.closeMenu = function() { | ||
mdPanelRef && mdPanelRef.close(); | ||
} | ||
} | ||
})(); |
This file contains hidden or 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,77 @@ | ||
.menu-panel-container { | ||
pointer-events: auto; | ||
} | ||
|
||
.menu-panel { | ||
width: 256px; | ||
background-color: #fff; | ||
border-radius: 4px; | ||
} | ||
|
||
.menu-panel .menu-divider { | ||
width: 100%; | ||
height: 1px; | ||
min-height: 1px; | ||
max-height: 1px; | ||
margin-top: 4px; | ||
margin-bottom: 4px; | ||
background-color: rgba(0, 0, 0, 0.11); | ||
} | ||
|
||
.menu-panel .menu-content { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 8px 0; | ||
max-height: 305px; | ||
overflow-y: auto; | ||
min-width: 256px; | ||
} | ||
|
||
.menu-panel .menu-item { | ||
display: flex; | ||
flex-direction: row; | ||
min-height: 48px; | ||
height: 48px; | ||
align-content: center; | ||
justify-content: flex-start; | ||
} | ||
.menu-panel .menu-item > * { | ||
width: 100%; | ||
margin: auto 0; | ||
padding-left: 16px; | ||
padding-right: 16px; | ||
} | ||
.menu-panel .menu-item > a.md-button { | ||
padding-top: 5px; | ||
} | ||
.menu-panel .menu-item > .md-button { | ||
display: inline-block; | ||
border-radius: 0; | ||
margin: auto 0; | ||
font-size: 15px; | ||
text-transform: none; | ||
font-weight: 400; | ||
height: 100%; | ||
padding-left: 16px; | ||
padding-right: 16px; | ||
width: 100%; | ||
text-align: left; | ||
} | ||
.menu-panel .menu-item > .md-button::-moz-focus-inner { | ||
padding: 0; | ||
border: 0; | ||
} | ||
.menu-panel .menu-item > .md-button md-icon { | ||
margin: auto 16px auto 0; | ||
} | ||
.menu-panel .menu-item > .md-button p { | ||
display: inline-block; | ||
margin: auto; | ||
} | ||
.menu-panel .menu-item > .md-button span { | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
} | ||
.menu-panel .menu-item > .md-button .md-ripple-container { | ||
border-radius: inherit; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destroy as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ErinCoughlan I do not think so. Destroying a panel makes it unable to be re-opened, and in this demo, I am applying an ID to each opened panel, which means it can be closed and re-opened from the click event.