Skip to content
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

DRAFT: add shiny colors, update widget appearance #212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
167 changes: 167 additions & 0 deletions 081-widgets-gallery/theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*-- scss:defaults --*/
$blue: #007BC2 !default;
$indigo: #4B00C1 !default;
$purple: #74149C !default;
$pink: #BF007F !default;
$red: #C10000 !default;
$orange: #f45100 !default;
$yellow: #F9B928 !default;
$green: #00891A !default;
$teal: #00BF7F !default;
$cyan: #03C7E8 !default;
$white: #ffffff !default;
$gray: #606060 !default;
$gray-dark: #303030 !default;
$gray-100: #f8f8f8 !default;
$gray-200: #e9ecef !default;
$gray-300: #dee2e6 !default;
$gray-400: #cdd4da !default;
$gray-500: #8D959E !default;
$gray-600: #707782 !default;
$gray-700: #48505F !default;
$gray-800: #343A46 !default;
$gray-900: #1D1F21 !default;
$default: #dee2e6 !default;
$primary: #007BC2 !default;
$secondary: #404040 !default;
$success: #00891A !default;
$info: #03C7E8 !default;
$warning: #F9B928 !default;
$danger: #C10000 !default;
$light: #f8f8f8 !default;
$dark: #202020 !default;
$default-rgb: 222, 226, 230 !default;
$primary-rgb: 0, 123, 194 !default;
$secondary-rgb: 64, 64, 64 !default;
$success-rgb: 0, 137, 26 !default;
$info-rgb: 3, 199, 232 !default;
$warning-rgb: 249, 185, 40 !default;
$danger-rgb: 193, 0, 0 !default;
$light-rgb: 248, 248, 248 !default;
$dark-rgb: 32, 32, 32 !default;
$white-rgb: 255, 255, 255 !default;
$black-rgb: 0, 0, 0 !default;
$body-color-rgb: 52, 58, 70 !default;
$body-bg-rgb: 255, 255, 255 !default;
$gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0)) !default;
$root-font-size: 18px !default;
$body-font-size: 1rem !default;
$body-font-weight: 400 !default;
$body-color: $gray-900 !default;
$body-bg: #ffffff !default;
$hr-margin-y: 2rem !default;
$input-btn-font-size: 15px !default;
$btn-font-weight: 500 !default;
$btn-padding-y: .75em !default;
$btn-padding-x: 2em !default;
$h1-font-size: 2.1rem !default;
$form-check-input-width: 1.2em !default;
$form-check-input-border-radius: 2px !default;
$form-check-margin-bottom: .25rem !default;
$input-border-color: $gray-500 !default;
$form-text-color: $red !default;
$border-radius: 3px !default;

/*-- scss:rules --*/

// move checkbox and radio text slightly to the right
.checkbox input, .radio input {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.checkbox input, .radio input {
.checkbox, .radio {
input {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here comes @cpsievert with the css code streamlining! Love it, thank you.

margin-right: 0.35em;
}

// make selected item more accessible
.selectize-dropdown-content .option.selected.active, .selectize-dropdown-content .option:hover, .selectize-dropdown-content .option:active {
background-color: $blue;
color: $white;
}
// make non-selected items slightly different visually (but still 3:1 contrast)
.selectize-dropdown-content .option.active {
background-color: tint-color($blue, 25%);
color: $white;
}

// fix "to" width in the middle of the date picker
.shiny-date-range-input .input-daterange .input-group-addon {
margin-right: -1px;
}

// Garrick: this is potentially too big of a swing, but... I feel like these components should fill the containter they're in, rather than set a pixel width?

.shiny-input-container:not(.shiny-input-container-inline) {
min-width: 230px;
width: 100%;
}

// SLIDERS SLIDERS SLIDERS

// give numbers above more breathing room
.irs--shiny .irs-min, .irs--shiny .irs-max, .irs--shiny .irs-from, .irs--shiny .irs-to, .irs--shiny .irs-single {
padding: 3px 6px !important;
}

.irs-from, .irs-to, .irs-single, .irs--shiny .irs-min, .irs--shiny .irs-max {
top: -3px !important;
}

.irs {
margin-top: 3px;
}

.irs--shiny .irs-min, .irs--shiny .irs-max {
background-color: $gray-200 !important;
}


.irs--shiny .irs-bar {
top: 31px !important;
height: 3px !important;
background: $blue !important;
border: none !important;
}

.irs--shiny .irs-line {
top: 32px !important;
height: 1px !important;
background: none !important;
background-color: $gray-600 !important;
border: none !important;
// NOTE: not sure we need this border radius
border-radius: 8px !important;
}

// Make handle(s) blue
.irs--shiny .irs-handle {
top: 22px !important;
width: 19px !important;
height: 19px !important;
border: 1px solid $blue !important;
background-color: $blue !important;
box-shadow: none !important;
border-radius: 22px !important;
}

// make handles keyboard accessible
// Garrick: looks like we need some javascript shenanigans to make the handles on the slider keyboard accessible. I think we can do this by assigning it a role and and a tabindex? check out this article: https://www.456bereastreet.com/archive/201302/making_elements_keyboard_focusable_and_clickable/
.irs--shiny .irs-handle:focus-visible, .irs--shiny .irs-handle:active {
color: shade-color($blue, 30%) !important;
background-color: shade-color($blue, 30%) !important;
border-color: shade-color($blue, 30%) !important;
outline: 0 !important;
box-shadow: $btn-focus-box-shadow !important;
}

// make ticks the right color
.irs--shiny .irs-grid-pol {
background-color: $gray-600 !important;
height: 6px !important;
}

// remove small ticks
.irs-grid-pol.small {
display: none !important;
}

.irs-grid-text {
color: $gray-800 !important;
bottom: 8px !important;
}
62 changes: 43 additions & 19 deletions 081-widgets-gallery/ui.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
fluidPage(

tags$head(tags$style(HTML("
.shiny-text-output {
background-color:#fff;
}
"))),
library(bslib)


fluidPage(

theme = bs_bundle(
bslib::bs_theme(
version = 5,
heading_font = "Open Sans",
`headings-font-weight` = 400,
base_font = bslib::font_collection(
bslib::font_google("Open Sans", wght = c(300, 400, 500, 600, 700, 800)),
"var(--bs-font-sans-serif)"
),
code_font = bslib::font_collection(
bslib::font_google("Source Code Pro"),
"SFMono-Regular",
"Menlo",
"Monaco",
"Consolas",
"Liberation Mono",
"Courier New",
"monospace"
)
),
sass::sass_layer_file("theme.scss")
),

h1("Shiny", span("Widgets Gallery", style = "font-weight: 300"),
style = "font-family: 'Source Sans Pro';
Expand All @@ -28,9 +48,11 @@ fluidPage(
fluidRow(

column(4,
wellPanel(
div(class="p-5",
h3("Action button"),
actionButton("action", label = "Action"),
p("GARRICK: please make the Action button Bootstrap 5's .btn-outline-dark button instead. Thank you!"),
a("btn-outline-dark", class = "btn btn-outline-dark btn-md", href="#" ),
hr(),
p("Current Value:", style = "color:#888888;"),
verbatimTextOutput("actionOut"),
Expand All @@ -39,7 +61,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
h3("Single checkbox"),
checkboxInput("checkbox", label = "Choice A",
value = TRUE),
Expand All @@ -51,7 +73,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
checkboxGroupInput("checkGroup",
label = h3("Checkbox group"),
choices = list("Choice 1" = 1, "Choice 2" = 2,
Expand All @@ -68,7 +90,7 @@ fluidPage(
fluidRow(

column(4,
wellPanel(
div(class="p-5",
dateInput("date", label = h3("Date input"), value = "2014-01-01"),
hr(),
p("Current Value:", style = "color:#888888;"),
Expand All @@ -78,7 +100,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
dateRangeInput("dates", label = h3("Date range")),
hr(),
p("Current Values:", style = "color:#888888;"),
Expand All @@ -88,8 +110,10 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
fileInput("file", label = h3("File input")),
p("GARRICK: Can this be changed to bootstrap's file input instead? Asking for a friend."),
a(href="https://getbootstrap.com/docs/5.0/forms/form-control/#file-input", "See bootstrap's file input"),
hr(),
p("Current Value:", style = "color:#888888;"),
verbatimTextOutput("fileOut"),
Expand All @@ -101,7 +125,7 @@ fluidPage(
fluidRow(

column(4,
wellPanel(
div(class="p-5",
numericInput("num", label = h3("Numeric input"), value = 1),
hr(),
p("Current Value:", style = "color:#888888;"),
Expand All @@ -111,7 +135,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3),
selected = 1),
Expand All @@ -123,7 +147,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
selectInput("select", label = h3("Select box"),
choices = list("Choice 1" = 1, "Choice 2" = 2,
"Choice 3" = 3), selected = 1),
Expand All @@ -138,7 +162,7 @@ fluidPage(
fluidRow(

column(4,
wellPanel(
div(class="p-5",
sliderInput("slider1", label = h3("Slider"), min = 0, max = 100,
value = 50),
hr(),
Expand All @@ -149,7 +173,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
sliderInput("slider2", label = h3("Slider range"), min = 0,
max = 100, value = c(25, 75)),
hr(),
Expand All @@ -160,7 +184,7 @@ fluidPage(
)),

column(4,
wellPanel(
div(class="p-5",
textInput("text", label = h3("Text input"),
value = "Enter text..."),
hr(),
Expand Down