Skip to content

fix(ui-grid-header-cell): Improved styles with grid menu. #6548

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

Merged
merged 1 commit into from
Jan 20, 2018
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
8 changes: 5 additions & 3 deletions src/js/core/directives/ui-grid-header-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@
contents.addClass(classAdded);

$scope.$applyAsync(function() {
var rightMostContainer = $scope.grid.renderContainers['right'] ? $scope.grid.renderContainers['right'] : $scope.grid.renderContainers['body'];
$scope.isLastCol = ( $scope.col === rightMostContainer.visibleColumnCache[ rightMostContainer.visibleColumnCache.length - 1 ] );
var rightMostContainer = $scope.grid.renderContainers['right'] && $scope.grid.renderContainers['right'].visibleColumnCache.length ?
$scope.grid.renderContainers['right'] : $scope.grid.renderContainers['body'];
$scope.isLastCol = uiGridCtrl.grid.options && uiGridCtrl.grid.options.enableGridMenu &&
$scope.col === rightMostContainer.visibleColumnCache[ rightMostContainer.visibleColumnCache.length - 1 ];
});

// Figure out whether this column is sortable or not
Expand Down Expand Up @@ -371,7 +373,7 @@
event.preventDefault();
$scope.toggleMenu(event);
}
};
};

$scope.toggleMenu = function(event) {

Expand Down
4 changes: 2 additions & 2 deletions src/less/footer.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}

input[type="text"].ui-grid-filter-input {
padding: 0;
padding: 0 18px 0 0;
margin: 0;
border: 0;
width: 100%;
Expand All @@ -82,4 +82,4 @@ input[type="text"].ui-grid-filter-input {
&:hover {
border: @gridBorderWidth solid @borderColor;
}
}
}
22 changes: 19 additions & 3 deletions src/less/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,24 @@
}
}

.ui-grid-column-menu-button-last-col {
margin-right: 25px;
.ui-grid-header-cell-last-col {
.ui-grid-cell-contents,
.ui-grid-filter-container,
.ui-grid-column-menu-button,
& + .ui-grid-column-resizer.right {
margin-right: 13px;
}
}

.ui-grid-render-container-right {
.ui-grid-header-cell-last-col {
.ui-grid-cell-contents,
.ui-grid-filter-container,
.ui-grid-column-menu-button,
& + .ui-grid-column-resizer.right {
margin-right: 28px;
}
}
}

.ui-grid-column-menu {
Expand Down Expand Up @@ -195,7 +211,7 @@
}

input[type="text"].ui-grid-filter-input {
padding: 0;
padding: 0 18px 0 0;
margin: 0;
border: 0;
width: 100%;
Expand Down
28 changes: 18 additions & 10 deletions src/less/menu.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,49 @@
right: 0;
top: 0;
background: @headerBackgroundColor;
border: @gridBorderWidth solid @borderColor;
border: 0;
border-left: @gridBorderWidth solid @borderColor;
border-bottom: @gridBorderWidth solid @borderColor;
cursor: pointer;
height: 31px;
height: 32px;
font-weight: normal;
}

.ui-grid-menu-button .ui-grid-icon-container {
margin-top: 3px;
margin-top: 5px;
margin-left: 2px;
}

.ui-grid-menu-button .ui-grid-menu {
right: 0;
.ui-grid-menu-mid {
overflow: scroll;
border: @gridBorderWidth solid @borderColor;
}
}

.ui-grid-menu {
max-width: 320px;
z-index: 2; // So it shows up over grid canvas
position: absolute;
padding: 0 10px 20px 10px;
cursor: pointer;
box-sizing: border-box;
}

.ui-grid-menu-item {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.ui-grid-menu .ui-grid-menu-inner {
background: @headerBackgroundColor;
background: @menuBackgroundColor;
border: @gridBorderWidth solid @borderColor;
position: relative;
white-space: nowrap;

.rounded(@gridBorderRadius);
.box-shadow(e("0 10px 20px rgba(0, 0, 0, 0.2), inset 0 12px 12px -14px rgba(0, 0, 0, 0.2)"));
}

.ui-grid-menu .ui-grid-menu-inner ul {
Expand All @@ -48,6 +57,7 @@
li {
padding: 0px;
button {
color: @menuTextColor;
min-width: 100%;
padding: 8px;
text-align: left;
Expand All @@ -57,12 +67,10 @@
// Show a shadow when hovering over a menu item
&:hover,
&:focus {
// background-color: negation(@headerBackgroundColor, #fff);
.inner-shadow(@vertical: 0, @blur: 14px, @alpha: 0.2);
background-color: @menuHoverColor;
}
&.ui-grid-menu-item-active {
.inner-shadow(@vertical: 0, @blur: 14px, @alpha: 0.2);
background-color: @selectedColor;
background-color: @menuSelectedColor;
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/less/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
@gridBorderWidth: 1px;
@gridBorderRadius: 0px;
@borderColor: #d4d4d4;

@focusColor: #b3c4c7;
@activeColor: darken(@focusColor, 8%);

/**
* @section Header styles
Expand All @@ -32,7 +33,13 @@
@rowColorEven: #f3f3f3;
@rowColorOdd: #fdfdfd;

// TODO: colors for buttons
/**
* @section Grid Menu colors
*/
@menuBackgroundColor: #fff;
@menuHoverColor: @focusColor;
@menuSelectedColor: @activeColor;
@menuTextColor: #000;

/**
* @section Sort arrow colors
Expand All @@ -42,18 +49,17 @@
@sortArrowBorderColor: #777777;


// TODO: color for menu background
@rowHeaderCell: #F0F0EE;
@rowSelected: #C9DDE1;
@rowSavingForeground: #848484;
@rowErrorForeground: #FF0000;
@rowDirtyForeground: #610B38;

// TODO: color for cell selections
@focusedCell: #b3c4c7;
@focusedCell: @focusColor;

// Color to use for enabled or selected settings/items/cells, etc. Should probably override the one above
@selectedColor: #cecece;
@selectedColor: @activeColor;

/**
* @section Scrollbar styles
Expand Down
3 changes: 1 addition & 2 deletions src/templates/ui-grid/uiGridHeaderCell.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
role="columnheader"
ng-class="{ 'sortable': sortable }"
ng-class="{ 'sortable': sortable, 'ui-grid-header-cell-last-col': isLastCol }"
ui-grid-one-bind-aria-labelledby-grid="col.uid + '-header-text ' + col.uid + '-sortdir-text'"
aria-sort="{{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending' : (!col.sort.direction ? 'none' : 'other'))}}">
<div
Expand Down Expand Up @@ -41,7 +41,6 @@
ng-if="grid.options.enableColumnMenus && !col.isRowHeader && col.colDef.enableColumnMenu !== false"
ng-click="toggleMenu($event)"
ng-keydown="headerCellArrowKeyDown($event)"
ng-class="{'ui-grid-column-menu-button-last-col': isLastCol}"
ui-grid-one-bind-aria-label="i18n.headerCell.aria.columnMenuButtonLabel"
aria-haspopup="true">
<i
Expand Down
11 changes: 10 additions & 1 deletion test/unit/core/directives/ui-grid-header-cell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('uiGridHeaderCell', function() {
$compile(grid)($scope);
$document[0].body.appendChild(grid[0]);

$scope.$digest();
$scope.$apply();
};

recompile();
Expand Down Expand Up @@ -193,6 +193,15 @@ describe('uiGridHeaderCell', function() {
}));
});

describe('isLastCol', function() {
it('should not add a last col class to the last column when the grid menu is disabled', function() {
expect($(grid).find('.ui-grid-header-cell:nth(2) .sortable').hasClass('ui-grid-header-cell-last-col')).toBe(false);
});
it('should not add a last col class to a column that is not the last column', function() {
expect($(grid).find('.ui-grid-header-cell:nth(1) .sortable').hasClass('ui-grid-header-cell-last-col')).toBe(false);
});
});

describe('externalScope', function() {
it('should be present', function() {
var header = $(grid).find('.ui-grid-header-cell:nth(0)');
Expand Down