Skip to content

Commit

Permalink
[Maps] Highlight selected layer in TOC (#61510) (#62158)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Apr 1, 2020
1 parent a540bb1 commit d8f381a
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
pointer-events: none !important;
}

.mapTocEntry-isSelected {
background-color: tintOrShade($euiColorLightShade, 60%, 20%);
}


.mapTocEntry-visible,
.mapTocEntry-notVisible {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export class TOCEntry extends React.Component {
const classes = classNames('mapTocEntry', {
'mapTocEntry-isDragging': this.props.isDragging,
'mapTocEntry-isDraggingOver': this.props.isDraggingOver,
'mapTocEntry-isSelected':
this.props.selectedLayer && this.props.selectedLayer.getId() === this.props.layer.getId(),
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const mockLayer = {
getId: () => {
return LAYER_ID;
},
hasLegendDetails: async () => {
return true;
},
renderLegendDetails: () => {
return <div>TOC details mock</div>;
},
Expand Down Expand Up @@ -83,5 +80,33 @@ describe('TOCEntry', () => {

expect(component).toMatchSnapshot();
});

test('Should shade background when selected layer', async () => {
const component = shallowWithIntl(<TOCEntry {...defaultProps} selectedLayer={mockLayer} />);

// Ensure all promises resolve
await new Promise(resolve => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();

expect(component).toMatchSnapshot();
});

test('Should shade background when not selected layer', async () => {
const differentLayer = Object.create(mockLayer);
differentLayer.getId = () => {
return 'foobar';
};
const component = shallowWithIntl(
<TOCEntry {...defaultProps} selectedLayer={differentLayer} />
);

// Ensure all promises resolve
await new Promise(resolve => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();

expect(component).toMatchSnapshot();
});
});
});

0 comments on commit d8f381a

Please sign in to comment.