Skip to content

Commit dc9c6ae

Browse files
authored
Better color constrasting in sliderInput() (#3366)
* Better color constrasting in sliderInput() Closes rstudio/bslib#228 * Update build script; recompile * bslib tabsets now include data-bs-toggle
1 parent 2cdafed commit dc9c6ae

File tree

8 files changed

+101
-97
lines changed

8 files changed

+101
-97
lines changed

R/input-slider.R

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,26 +228,10 @@ ionRangeSliderDependencyCSS <- function(theme) {
228228
))
229229
}
230230

231-
# Remap some variable names for ionRangeSlider's scss
232-
sass_input <- list(
233-
list(
234-
# The bootswatch materia theme sets $input-bg: transparent;
235-
# which is an issue for the slider's handle(s) (#3130)
236-
bg = "if(alpha($input-bg)==0, $body-bg, $input-bg)",
237-
fg = sprintf(
238-
"if(alpha($input-color)==0, $%s, $input-color)",
239-
if ("3" %in% bslib::theme_version(theme)) "text-color" else "body-color"
240-
),
241-
accent = "$component-active-bg",
242-
`font-family` = "$font-family-base"
243-
),
244-
sass::sass_file(
245-
system.file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
246-
)
247-
)
248-
249231
bslib::bs_dependency(
250-
input = sass_input,
232+
input = sass::sass_file(
233+
system.file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
234+
),
251235
theme = theme,
252236
name = "ionRangeSlider",
253237
version = version_ion_range_slider,

inst/www/shared/ionrangeslider/css/ion.rangeSlider.css

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
-moz-user-select: none;
1414
-ms-user-select: none;
1515
user-select: none;
16-
font-size: 12px;
17-
font-family: Arial, sans-serif;
1816
}
1917

2018
.irs-line {
@@ -92,7 +90,6 @@
9290
left: 0;
9391
width: 1px;
9492
height: 8px;
95-
background: #000;
9693
}
9794

9895
.irs-grid-pol.small {
@@ -108,7 +105,6 @@
108105
font-size: 9px;
109106
line-height: 9px;
110107
padding: 0 3px;
111-
color: #000;
112108
}
113109

114110
.irs-disable-mask {
@@ -153,7 +149,7 @@
153149
}
154150

155151
.irs {
156-
font-family: Arial, sans-serif;
152+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
157153
}
158154

159155
.irs--shiny {
@@ -167,7 +163,7 @@
167163
.irs--shiny .irs-line {
168164
top: 25px;
169165
height: 8px;
170-
background: linear-gradient(to bottom, #dedede -50%, white 150%);
166+
background: linear-gradient(to bottom, #dedede -50%, #fff 150%);
171167
background-color: #ededed;
172168
border: 1px solid #cccccc;
173169
border-radius: 8px;
@@ -176,9 +172,9 @@
176172
.irs--shiny .irs-bar {
177173
top: 25px;
178174
height: 8px;
179-
border-top: 1px solid #428bca;
180-
border-bottom: 1px solid #428bca;
181-
background: #428bca;
175+
border-top: 1px solid #337ab7;
176+
border-bottom: 1px solid #337ab7;
177+
background: #337ab7;
182178
}
183179

184180
.irs--shiny .irs-bar--single {
@@ -207,14 +203,13 @@
207203
}
208204

209205
.irs--shiny .irs-handle.state_hover, .irs--shiny .irs-handle:hover {
210-
background: white;
206+
background: #fff;
211207
}
212208

213209
.irs--shiny .irs-min,
214210
.irs--shiny .irs-max {
215211
top: 0;
216212
padding: 1px 3px;
217-
color: #333333;
218213
text-shadow: none;
219214
background-color: rgba(0, 0, 0, 0.1);
220215
border-radius: 3px;
@@ -233,7 +228,7 @@
233228
color: #fff;
234229
text-shadow: none;
235230
padding: 1px 3px;
236-
background-color: #428bca;
231+
background-color: #337ab7;
237232
border-radius: 3px;
238233
font-size: 11px;
239234
line-height: 1.333;
@@ -250,12 +245,11 @@
250245
}
251246

252247
.irs--shiny .irs-grid-pol {
253-
background-color: black;
248+
background-color: #000;
254249
}
255250

256251
.irs--shiny .irs-grid-text {
257252
bottom: 5px;
258-
color: #1a1a1a;
259253
}
260254

261255
.irs--shiny .irs-grid-pol.small {

inst/www/shared/ionrangeslider/scss/_base.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
@include pos-r();
55
-webkit-touch-callout: none;
66
@include no-click();
7-
font-size: 12px;
8-
font-family: Arial, sans-serif;
97

108
&-line {
119
@include pos-r();
@@ -83,7 +81,6 @@
8381
left: 0;
8482
width: 1px;
8583
height: 8px;
86-
background: #000;
8784

8885
&.small {
8986
height: 4px;
@@ -99,7 +96,6 @@
9996
font-size: 9px;
10097
line-height: 9px;
10198
padding: 0 3px;
102-
color: #000;
10399
}
104100
}
105101

inst/www/shared/ionrangeslider/scss/shiny.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
////////////////////////////////////////////////////////////////////////////
2121

22-
// Re-define font-family on .irs to make it configurable
23-
$font-family: Arial, sans-serif !default;
22+
$font-family: $font-family-base !default;
2423
.irs {
2524
font-family: $font-family;
2625
}
@@ -36,9 +35,9 @@ $font-family: Arial, sans-serif !default;
3635
$custom_radius: 3px !default;
3736

3837
// "High-level" coloring
39-
$bg: white !default;
40-
$fg: black !default;
41-
$accent: #428bca !default;
38+
$bg: $body-bg !default;
39+
$fg: color-contrast($body-bg) !default;
40+
$accent: $component-active-bg !default;
4241

4342
// "Low-level" coloring, borders, and fonts
4443
$line_bg: linear-gradient(to bottom, mix($bg, $fg, 87%) -50%, $bg 150%) !default;
@@ -52,7 +51,7 @@ $font-family: Arial, sans-serif !default;
5251
$handle_border: 1px solid mix($bg, $fg, 67%) !default;
5352
$handle_box_shadow: 1px 1px 3px rgba($bg, 0.3) !default;
5453

55-
$minmax_text_color: mix($bg, $fg, 20%) !default;
54+
$minmax_text_color: null !default;
5655
$minmax_bg_color: rgba($fg, 0.1) !default;
5756
$minmax_font_size: 10px !default;
5857
$minmax_line_height: 1.333 !default;
@@ -64,7 +63,7 @@ $font-family: Arial, sans-serif !default;
6463

6564
$grid_major_color: $fg !default;
6665
$grid_minor_color: mix($bg, $fg, 60%) !default;
67-
$grid_text_color: mix($bg, $fg, 10%) !default;
66+
$grid_text_color: null !default;
6867

6968

7069
height: 40px;

0 commit comments

Comments
 (0)