Skip to content

Commit d8330e0

Browse files
gadenbuiecpsievert
andauthored
feat(shiny-preset): Notifications, progress bars, and modals (#754)
Co-authored-by: Carson Sievert <[email protected]>
1 parent 0d08ff5 commit d8330e0

File tree

6 files changed

+86
-5
lines changed

6 files changed

+86
-5
lines changed

inst/builtin/bs5/shiny/_rules.scss

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ $bslib-checkbox-radio-margin-right: 0.35em !default;
123123
}
124124

125125
// By default, non-active .nav links reflect the primary color. This styling
126-
// tweak brings them closer to how they'll appear in a navbar.
126+
// tweak brings them closer to how they'll appear in a navbar.
127127
.nav-underline {
128-
--#{$prefix}link-color: rgba(var(--bs-body-color-rgb), 0.65);
128+
--#{$prefix}link-color: rgba(var(--bs-body-color-rgb), 0.65);
129129
--#{$prefix}link-hover-color: rgba(var(--bs-body-color-rgb), 0.8);
130130
--#{$prefix}nav-link-font-size: 0.875rem;
131131

@@ -189,3 +189,72 @@ $icon-classes: ("bi", "fa", "fas", "far", "fab", "material-icons") !default;
189189
--bslib-color-fg: #008558; // Contrast 4.67
190190
}
191191
}
192+
193+
// Modals
194+
.modal-body, .modal-footer {
195+
padding: 1.5rem;
196+
}
197+
.modal-header .btn-close {
198+
align-self: start;
199+
display: flex;
200+
}
201+
#shiny-modal-wrapper:has( ~ .modal-backdrop) .modal {
202+
// Blur the background when the modal has a backdrop
203+
backdrop-filter: blur(2px);
204+
}
205+
206+
// Progress Bars & Notifications
207+
// FIXME: Use css layers (dynamic themeing issue)
208+
#shiny-notification-panel#shiny-notification-panel {
209+
position: fixed;
210+
bottom: calc(var(--bslib-spacer, 1rem) / 2);
211+
right: calc(var(--bslib-spacer, 1rem) / 2);
212+
width: 450px;
213+
z-index: $zindex-toast;
214+
}
215+
216+
.progress-message {
217+
margin-right: .6rem;
218+
}
219+
220+
// FIXME: Use css layers (dynamic themeing issue)
221+
.shiny-notification.shiny-notification {
222+
position: relative;
223+
opacity: 0.96;
224+
padding: calc(var(--bslib-spacer, 1rem) * 2);
225+
margin: var(--bslib-spacer, 1rem);
226+
border: $border-width solid rgba(var(--#{prefix}emphasis-color-rgb), 0.8);
227+
border-radius: $card-border-radius;
228+
box-shadow: $box-shadow;
229+
230+
.shiny-notification-close {
231+
position: absolute;
232+
font-size: 1.5em;
233+
width: 2rem;
234+
height: 2rem;
235+
top: 0;
236+
right: 0;
237+
bottom: unset;
238+
display: flex;
239+
align-items: center;
240+
justify-content: center;
241+
padding: 0.25rem;
242+
cursor: pointer;
243+
font-weight: 200;
244+
color: currentColor;
245+
246+
&:hover {
247+
font-weight: normal;
248+
}
249+
}
250+
251+
.shiny-notification-content-text :last-child {
252+
margin-bottom: 0;
253+
}
254+
}
255+
256+
@include color-mode(dark) {
257+
.shiny-notification.shiny-notification {
258+
box-shadow: $box-shadow-dark;
259+
}
260+
}

inst/builtin/bs5/shiny/_variables.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,13 @@ $card-border-radius: 8px !default;
116116

117117
// bslib variables
118118
$bslib-enable-shadows: true !default;
119-
$bslib-value-box-enable-shadow: $bslib-enable-shadows !default;
119+
$bslib-value-box-enable-shadow: $bslib-enable-shadows !default;
120+
121+
// Modals
122+
$modal-dialog-margin-y-sm-up: 10% !default;
123+
$modal-header-border-width: none !default;
124+
$modal-header-padding: 1.5rem !default;
125+
$modal-backdrop-bg: #464646 !default;
126+
127+
// Shiny: Base shiny.scss variables
128+
$notification-close-color: currentColor !default;

inst/css-precompiled/5/bootstrap.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/themer-demo/app.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ shinyApp(
330330
style = style,
331331
{
332332
for (i in 1:15) {
333-
incProgress(1/15)
333+
incProgress(
334+
amount = 1/15,
335+
detail = paste("Step", i, "of", 15)
336+
)
334337
Sys.sleep(0.25)
335338
}
336339
})
-18 Bytes
Loading

man/figures/navset-underline.png

-55 Bytes
Loading

0 commit comments

Comments
 (0)