Skip to content

Commit 6da24e4

Browse files
committed
update default button style:
- default style has fill with Color.lightLine - active and hovered over buttons are shown in a darker grey (#d3d3d3)
1 parent 6c3a9d7 commit 6da24e4

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

src/components/rangeselector/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = {
7777

7878
bgcolor: {
7979
valType: 'color',
80-
dflt: colorAttrs.background,
80+
dflt: colorAttrs.lightLine,
8181
role: 'style',
8282
description: 'Sets the background color of the range selector buttons.'
8383
},

src/components/rangeselector/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ module.exports = {
1919

2020
// buttons rect radii
2121
rx: 3,
22-
ry: 3
22+
ry: 3,
23+
24+
// color given to active and hovered buttons
25+
activeColor: '#d3d3d3'
2326
};

src/components/rangeselector/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function rangeSelectorDefaults(containerIn, containerOut, layou
3838

3939
Lib.coerceFont(coerce, 'font', layout.font);
4040

41-
coerce('bgcolor', layout.paper_bgcolor);
41+
coerce('bgcolor');
4242
coerce('bordercolor');
4343
coerce('borderwidth');
4444
};

src/components/rangeselector/draw.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,15 @@ function drawButtonRect(button, selectorLayout, d) {
142142

143143
function getFillColor(selectorLayout, d) {
144144
return (d.isActive || d.isHovered) ?
145-
Color.lightLine :
145+
constants.activeColor :
146146
selectorLayout.bgcolor;
147147
}
148148

149149
function drawButtonText(button, selectorLayout, d) {
150150
function textLayout(s) {
151-
svgTextUtils.convertToTspans(s, function() {
152-
// TODO do we need this???
153-
// if(gd.firstRender) repositionLegend(gd, traces);
154-
});
151+
svgTextUtils.convertToTspans(s);
152+
153+
// TODO do we need anything else here?
155154
}
156155

157156
var text = button.selectAll('text')
247 Bytes
Loading
1.21 KB
Loading

test/jasmine/tests/range_selector_test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
var RangeSelector = require('@src/components/rangeselector');
22
var getUpdateObject = require('@src/components/rangeselector/get_update_object');
3+
var constants = require('@src/components/rangeselector/constants');
34

45
var d3 = require('d3');
56
var Plotly = require('@lib');
67
var Lib = require('@src/lib');
8+
var Color = require('@src/components/color');
79
var createGraphDiv = require('../assets/create_graph_div');
810
var destroyGraphDiv = require('../assets/destroy_graph_div');
911
var getRectCenter = require('../assets/get_rect_center');
@@ -440,13 +442,16 @@ describe('[range selector suite]', function() {
440442
var button = d3.select('.button').select('rect');
441443
var pos = getRectCenter(button.node());
442444

443-
expect(button.style('fill')).toEqual('rgb(255, 255, 255)');
445+
var fillColor = Color.rgb(gd._fullLayout.xaxis.rangeselector.bgcolor);
446+
var activeColor = Color.rgb(constants.activeColor);
447+
448+
expect(button.style('fill')).toEqual(fillColor);
444449

445450
mouseEvent('mouseover', pos[0], pos[1]);
446-
expect(button.style('fill')).toEqual('rgb(238, 238, 238)');
451+
expect(button.style('fill')).toEqual(activeColor);
447452

448453
mouseEvent('mouseout', pos[0], pos[1]);
449-
expect(button.style('fill')).toEqual('rgb(255, 255, 255)');
454+
expect(button.style('fill')).toEqual(fillColor);
450455
});
451456

452457
it('should update is active relayout calls', function(done) {

0 commit comments

Comments
 (0)