Skip to content

Commit ff159b1

Browse files
committed
improve examples
1 parent 65619b3 commit ff159b1

9 files changed

Lines changed: 47 additions & 22 deletions

File tree

inst/examples/CustomComponentShinyInputStyled.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SliderCustom <- function(inputId, ..., value = defaultValue) {
3232
module = "CustomComponents",
3333
name = "SliderCustom",
3434
props = shiny.react::asProps(inputId = inputId, ..., value = value),
35-
deps = muiMaterial:::muiMaterialDependency()
35+
deps = muiMaterial::muiMaterialDependency()
3636
)
3737
}
3838

inst/examples/Fab.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ FloatingActionButtons <- Box(
66
sx = list('& > :not(style)' = list(m = 1)),
77
Fab(
88
color = "primary",
9-
'aria-label' = "add",
10-
shiny::icon("add")
9+
'aria-label' = "plus",
10+
shiny::icon("plus")
1111
),
1212
Fab(
1313
color = "secondary",
14-
'aria-label' = "edit",
15-
shiny::icon("edit")
14+
'aria-label' = "pen",
15+
shiny::icon("pen")
1616
),
1717
Fab(
1818
variant = "extended",

inst/examples/Grid.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
library(muiMaterial)
22

3-
muiMaterialPage(
3+
ui_Grid <- muiMaterialPage(
44
CssBaseline(),
55
Grid(
66
container = TRUE,
@@ -23,3 +23,9 @@ muiMaterialPage(
2323
)
2424
)
2525
)
26+
27+
server_Grid <- function(input, output, session) {}
28+
29+
if (interactive()) {
30+
shinyApp(ui = ui_Grid, server = server_Grid)
31+
}

inst/examples/Rating.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ HalfRating <- Stack(
2424
)
2525

2626
ui_Rating <- muiMaterialPage(
27-
CssBaseline(
28-
HalfRating
29-
)
27+
CssBaseline(),
28+
HalfRating
3029
)
3130

3231
server_Rating <- function(input, output, session) {

inst/examples/Slider.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ DiscreteSliderLabel <- Box(
88
inputId = "DiscreteSliderLabel",
99
value = 80,
1010
step = 10,
11-
marks = data.frame(value = c(0, 20, 37, 100), label = c("0°C", "20°C", "37°C", "100°C")),
11+
marks = list(
12+
list(value = 0, label = "0°C"),
13+
list(value = 20, label = "20°C"),
14+
list(value = 37, label = "37°C"),
15+
list(value = 100, label = "100°C")
16+
),
1217
valueLabelDisplay = "on",
1318
'aria-label' = "Always visible"
1419
),

inst/examples/Switch.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ library(muiMaterial)
22
library(shiny)
33

44
# https://mui.com/material-ui/react-switch/#label
5-
ui_Switch <- Box(
5+
ui_Switch <- muiMaterialPage(
6+
CssBaseline(),
67
FormControlLabel(
78
control = Switch.shinyInput(
89
inputId = "Switch1",
910
value = TRUE
10-
),
11+
),
1112
label = "Label"
1213
),
1314
verbatimTextOutput("SwitchValue1")

inst/examples/TextField.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ ui_TextField <- muiMaterialPage(
1414
value = "Hello World",
1515
id = "outlined-basic",
1616
label = "Outlined",
17-
variant="outlined"
17+
variant = "outlined"
1818
),
1919
TextField.shinyInput(
2020
inputId = "BasicTextFields2",
2121
id = "filled-basic",
2222
label = "Filled",
23-
variant="filled"
23+
variant = "filled"
2424
),
2525
TextField.shinyInput(
2626
inputId = "BasicTextFields3",

inst/examples/Timeline.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ ui_Timeline <- muiMaterialPage(
8484

8585
server_Timeline <- function(input, output, session) {}
8686

87-
shinyApp(ui_Timeline, server_Timeline)
87+
if (interactive()) {
88+
shinyApp(ui = ui_Timeline, server = server_Timeline)
89+
}

inst/examples/ToggleButtonGroup.R

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library(muiMaterial)
22
library(shiny)
33

44
# https://mui.com/material-ui/react-toggle-button/#exclusive-selection
5-
ToggleButtonGroup <- ToggleButtonGroup.shinyInput(
5+
toggleButtonGroupWidget <- ToggleButtonGroup.shinyInput(
66
inputId = "ToggleButtonGroup1",
77
value = 1,
88
ToggleButton.shinyInput(inputId = "ToggleButton1", value = 1, "One"),
@@ -13,19 +13,31 @@ ToggleButtonGroup <- ToggleButtonGroup.shinyInput(
1313
ui_ToggleButtonGroup <- CssBaseline(
1414
Box(
1515
sx = list(flexDirection = 'row', p = 1, gap = "500px"),
16-
ToggleButtonGroup
16+
toggleButtonGroupWidget
1717
)
1818
)
1919

2020
server_ToggleButtonGroup <- function(input, output, session) {
2121
rv <- reactiveValues(value = 1)
2222

23-
observeEvent(input$ToggleButton1, { rv$value <- 1 })
24-
observeEvent(input$ToggleButton2, { rv$value <- 2 })
25-
observeEvent(input$ToggleButton3, { rv$value <- 3 })
26-
observeEvent(c(input$ToggleButton1, input$ToggleButton2, input$ToggleButton3), {
27-
updateToggleButtonGroup.shinyInput(inputId = "ToggleButtonGroup1", value = rv$value)
23+
observeEvent(input$ToggleButton1, {
24+
rv$value <- 1
2825
})
26+
observeEvent(input$ToggleButton2, {
27+
rv$value <- 2
28+
})
29+
observeEvent(input$ToggleButton3, {
30+
rv$value <- 3
31+
})
32+
observeEvent(
33+
c(input$ToggleButton1, input$ToggleButton2, input$ToggleButton3),
34+
{
35+
updateToggleButtonGroup.shinyInput(
36+
inputId = "ToggleButtonGroup1",
37+
value = rv$value
38+
)
39+
}
40+
)
2941
}
3042

3143
if (interactive()) {

0 commit comments

Comments
 (0)