Skip to content

Commit

Permalink
Better color constrasting in sliderInput() (#3366)
Browse files Browse the repository at this point in the history
* Better color constrasting in sliderInput()

Closes rstudio/bslib#228

* Update build script; recompile

* bslib tabsets now include data-bs-toggle
  • Loading branch information
cpsievert committed Jun 14, 2021
1 parent 2cdafed commit dc9c6ae
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 97 deletions.
22 changes: 3 additions & 19 deletions R/input-slider.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,10 @@ ionRangeSliderDependencyCSS <- function(theme) {
))
}

# Remap some variable names for ionRangeSlider's scss
sass_input <- list(
list(
# The bootswatch materia theme sets $input-bg: transparent;
# which is an issue for the slider's handle(s) (#3130)
bg = "if(alpha($input-bg)==0, $body-bg, $input-bg)",
fg = sprintf(
"if(alpha($input-color)==0, $%s, $input-color)",
if ("3" %in% bslib::theme_version(theme)) "text-color" else "body-color"
),
accent = "$component-active-bg",
`font-family` = "$font-family-base"
),
sass::sass_file(
system.file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
)
)

bslib::bs_dependency(
input = sass_input,
input = sass::sass_file(
system.file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
),
theme = theme,
name = "ionRangeSlider",
version = version_ion_range_slider,
Expand Down
22 changes: 8 additions & 14 deletions inst/www/shared/ionrangeslider/css/ion.rangeSlider.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-size: 12px;
font-family: Arial, sans-serif;
}

.irs-line {
Expand Down Expand Up @@ -92,7 +90,6 @@
left: 0;
width: 1px;
height: 8px;
background: #000;
}

.irs-grid-pol.small {
Expand All @@ -108,7 +105,6 @@
font-size: 9px;
line-height: 9px;
padding: 0 3px;
color: #000;
}

.irs-disable-mask {
Expand Down Expand Up @@ -153,7 +149,7 @@
}

.irs {
font-family: Arial, sans-serif;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.irs--shiny {
Expand All @@ -167,7 +163,7 @@
.irs--shiny .irs-line {
top: 25px;
height: 8px;
background: linear-gradient(to bottom, #dedede -50%, white 150%);
background: linear-gradient(to bottom, #dedede -50%, #fff 150%);
background-color: #ededed;
border: 1px solid #cccccc;
border-radius: 8px;
Expand All @@ -176,9 +172,9 @@
.irs--shiny .irs-bar {
top: 25px;
height: 8px;
border-top: 1px solid #428bca;
border-bottom: 1px solid #428bca;
background: #428bca;
border-top: 1px solid #337ab7;
border-bottom: 1px solid #337ab7;
background: #337ab7;
}

.irs--shiny .irs-bar--single {
Expand Down Expand Up @@ -207,14 +203,13 @@
}

.irs--shiny .irs-handle.state_hover, .irs--shiny .irs-handle:hover {
background: white;
background: #fff;
}

.irs--shiny .irs-min,
.irs--shiny .irs-max {
top: 0;
padding: 1px 3px;
color: #333333;
text-shadow: none;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 3px;
Expand All @@ -233,7 +228,7 @@
color: #fff;
text-shadow: none;
padding: 1px 3px;
background-color: #428bca;
background-color: #337ab7;
border-radius: 3px;
font-size: 11px;
line-height: 1.333;
Expand All @@ -250,12 +245,11 @@
}

.irs--shiny .irs-grid-pol {
background-color: black;
background-color: #000;
}

.irs--shiny .irs-grid-text {
bottom: 5px;
color: #1a1a1a;
}

.irs--shiny .irs-grid-pol.small {
Expand Down
4 changes: 0 additions & 4 deletions inst/www/shared/ionrangeslider/scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
@include pos-r();
-webkit-touch-callout: none;
@include no-click();
font-size: 12px;
font-family: Arial, sans-serif;

&-line {
@include pos-r();
Expand Down Expand Up @@ -83,7 +81,6 @@
left: 0;
width: 1px;
height: 8px;
background: #000;

&.small {
height: 4px;
Expand All @@ -99,7 +96,6 @@
font-size: 9px;
line-height: 9px;
padding: 0 3px;
color: #000;
}
}

Expand Down
13 changes: 6 additions & 7 deletions inst/www/shared/ionrangeslider/scss/shiny.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

////////////////////////////////////////////////////////////////////////////

// Re-define font-family on .irs to make it configurable
$font-family: Arial, sans-serif !default;
$font-family: $font-family-base !default;
.irs {
font-family: $font-family;
}
Expand All @@ -36,9 +35,9 @@ $font-family: Arial, sans-serif !default;
$custom_radius: 3px !default;

// "High-level" coloring
$bg: white !default;
$fg: black !default;
$accent: #428bca !default;
$bg: $body-bg !default;
$fg: color-contrast($body-bg) !default;
$accent: $component-active-bg !default;

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

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

$grid_major_color: $fg !default;
$grid_minor_color: mix($bg, $fg, 60%) !default;
$grid_text_color: mix($bg, $fg, 10%) !default;
$grid_text_color: null !default;


height: 40px;
Expand Down

0 comments on commit dc9c6ae

Please sign in to comment.