Skip to content

ThemeProvider fails to apply theme for components with .shinyInput wrappers #240

@clementtcy

Description

@clementtcy

Code example

library(shiny)
library(shiny.fluent)

theme <- list(
  palette = list(
    themePrimary= '#00f7b5',
    themeLighterAlt= '#000a07',
    themeLighter= '#00281d',
    themeLight= '#004a36',
    themeTertiary= '#00946d',
    themeSecondary= '#00daa0',
    themeDarkAlt= '#19f8bd',
    themeDark= '#3cf9c7',
    themeDarker= '#6efbd5',
    neutralLighterAlt= '#545353',
    neutralLighter= '#5b5a59',
    neutralLight= '#666565',
    neutralQuaternaryAlt= '#6d6c6c',
    neutralQuaternary= '#737271',
    neutralTertiaryAlt= '#8b8989',
    neutralTertiary= '#fdfdfd',
    neutralSecondary= '#fefefe',
    neutralPrimaryAlt= '#fefefe',
    neutralPrimary= '#fcfcfc',
    neutralDark= '#fefefe',
    black= '#ffffff',
    white= '#4d4b4b'
  )
)

ui <- function(id) {
  ns <- NS(id)
  ThemeProvider(
    theme = theme,
    Stack(
      #Fails to apply the theme
      PrimaryButton.shinyInput(
        ns("button1"),
        text = "Primary Button",
      ),
      DefaultButton.shinyInput(
        ns("button2"),
        text = "Default Button"
      ),

      #Applies the theme correctly
      PrimaryButton(text = "Primary Button"),
      DefaultButton(text = "Default Button")
    )
  )
}

server <- function(id) {
  moduleServer(id, function(input, output, session) {})
}

if (interactive()) {
  shinyApp(ui("app"), function(input, output) server("app"))
}

Bug description

ThemeProvider seemingly only applies the specified theme to bare components without any wrapper, and fails to apply to components with .shinyInput wrappers. Running the code above, you will see that the specified theme failed to apply for both 'PrimaryButton.shinyInput()' and 'DefaultButton.shinyInput()' yet successfully applied for both 'PrimaryButton()' and 'DefaultButton()'.

Expected behavior

ThemeProvider should apply the specified theme to all of its child components regardless of whether or not they are wrapped in .shinyInput.

Comments

I'm new to shiny.fluent and looking for a way to avoid manually specifying the theme for each of the components in my app. Since they are all wrapped in .shinyInput, I’m hoping there's a workaround/fix for this. If anyone has any suggestions, I'd greatly appreciate it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions