Skip to content

Commit

Permalink
docs: vignette improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Feb 4, 2025
1 parent 82db6d3 commit 3126adb
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 125 deletions.
4 changes: 2 additions & 2 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setOldClass("teal_modules")
#'
#' # Restricting datasets used by `teal_module`:
#'
#' The `datanames` argument controls which datasets are used by the modules server. These datasets,
#' The `datanames` argument controls which datasets are used by the module's server. These datasets,
#' passed via server's `data` argument, are the only ones shown in the module's tab.
#'
#' When `datanames` is set to `"all"`, all datasets in the data object are treated as relevant.
Expand All @@ -35,7 +35,7 @@ setOldClass("teal_modules")
#' Please see the _"Hidden datasets"_ section in `vignette("including-data-in-teal-applications").
#'
#' # `datanames` with `transformators`
#' When transformators are specified, their `datanames` are added to the modules `datanames`, which
#' When transformators are specified, their `datanames` are added to the module's `datanames`, which
#' changes the behavior as follows:
#' - If `module(datanames)` is `NULL` and the `transformators` have defined `datanames`, the sidebar
#' will appear showing the `transformators`' datasets, instead of being hidden.
Expand Down
4 changes: 2 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ articles:
- title: Using `teal`
navbar: Using `teal`
contents:
- teal-as-a-module
- teal-as-a-shiny-module
- teal-options
- bootstrap-themes-in-teal
- title: 📃 Technical blueprint
desc: >
The purpose of the blueprint is to aid new developers comprehension of the
The purpose of the blueprint is to aid new developer's comprehension of the
fundamental principles of the `teal` framework. We will explore crucial `teal`
concepts such as data flow, actors, and filter panel, among others.
contents:
Expand Down
4 changes: 2 additions & 2 deletions man/teal_modules.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions vignettes/creating-custom-modules.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ vignette: >
## Introduction

The `teal` framework provides a large catalog of plug-in-ready analysis modules that can be incorporated into `teal` applications.
However, it is also possible to create your own modules using the module function, which leverages Shiny modules.
Each custom teal module is built as a Shiny module, combining Shiny's reactive capabilities with modularized UI and server logic to encapsulate functionality.
However, it is also possible to create your own modules using the `module` function, which leverages Shiny modules.
Each custom teal module is built as a [Shiny module](https://shiny.posit.co/r/articles/improve/modules/), combining Shiny's reactive capabilities with modularized UI and server logic to encapsulate functionality.
This design enables a structured and reusable approach to creating interactive components that integrate seamlessly within the teal ecosystem.

In this guide, we will use the simple histogram below as an example, and demonstrate how to convert this histogram function into a robust `teal` module step-by-step:
Expand Down Expand Up @@ -56,11 +56,11 @@ The UI function defines the controls and display area for the histogram.
For this module, we will use:

- **`selectInput` for Dataset**: Enables users to select a dataset from the list of available datasets.
- **`selectInput` for Variable**: Allows users to choose a numeric variable from the chosen dataset, dynamically filtering out any non-numeric columns.
- **`selectInput` for Variable**: Allows users to choose a numeric variable from the chosen dataset, dynamically filtering out any non-numeric variables from the choices.
- **`plotOutput` for Histogram**: Displays the histogram once both dataset and variable inputs are selected.
- **`verbatimTextOutput` for Code**: Automatically displays code that generated the plot based on user input.
- **`verbatimTextOutput` for Code**: Automatically displays code that generated the plot based on the user input.

Heres the code for the `histogram_module_ui` function:
Here's the code for the `histogram_module_ui` function:

```{r module_ui}
library(teal)
Expand Down Expand Up @@ -92,9 +92,9 @@ For our histogram module, the server function will handle user interactions and

### Passing the `data` Argument to the Server Function

To begin, its essential to include the `data` argument in the server function definition.
To begin, it's essential to include the `data` argument in the server function definition.

This `data` argument holds the reactive `teal_data` object, which contains your datasets and any filters applied. By including `data`, we can ensure:
This `data` argument holds the reactive `teal_data` object, which contains your datasets after updergoing any active filtering by the filter panel. By including `data`, we can ensure:

- The server function receives a reactive version of `teal_data`, allowing it to automatically respond to changes.
- The server can access the filtered datasets directly.
Expand Down Expand Up @@ -148,7 +148,7 @@ In this updated server function, we will perform the following:
1. **Create `new_data`** as a modified version of `data()` using `within()`, dynamically injecting `input$dataset` and `input$variable`.
2. **Render the Plot**: `renderPlot()` displays the plot by referencing the plot stored in the updated `teal_data` object, `new_data`.

Heres the code:
Here's the code:

```{r module_server}
# Server function for the custom histogram module with injected variables in within()
Expand Down Expand Up @@ -241,7 +241,7 @@ create_histogram_module <- function(label = "Histogram Module") {
## Integrating the Custom `teal` Module into a `teal` App

With the custom `teal` module set up, it can now be integrated into a `teal` app.
Well use `init()` from `teal` to specify the datasets and modules used in the app, then run the app to test the newly created module.
We'll use `init()` from `teal` to specify the datasets and modules used in the app, then run the app to test the newly created module.

```{r app_init}
# Define datasets in `teal_data`
Expand Down Expand Up @@ -282,12 +282,12 @@ knitr::include_url(url, height = "800px")

## What's next?

Now that youve mastered the essentials of building and integrating modules in `teal`, youre ready to explore more advanced features.
`teal` offers a wide range of capabilities to enhance your modules functionality and user experience.
Now that you've mastered the essentials of building and integrating modules in `teal`, you're ready to explore more advanced features.
`teal` offers a wide range of capabilities to enhance your module's functionality and user experience.

### Adding reporting to a module

Enhance your custom `teal` module with reporting features! Dive into [this vignette](adding-support-for-reporting.html) to see just how simple it is to add powerful reporting capabilities and elevate your modules impact.
Enhance your custom `teal` module with reporting features! Dive into [this vignette](adding-support-for-reporting.html) to see just how simple it is to add powerful reporting capabilities and elevate your module's impact.

### Using standard widgets in your custom module
The [`teal.widgets`](https://insightsengineering.github.io/teal.widgets/latest-tag/) package provides various widgets which can be leveraged to quickly create standard elements in your custom `teal` module.
Loading

0 comments on commit 3126adb

Please sign in to comment.