Skip to content

Commit 7a0131d

Browse files
authored
Merge pull request #10700 from quarto-dev/revealjs/kbd-style
2 parents 4f41328 + 9e9a051 commit 7a0131d

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

news/changelog-1.6.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ All changes included in 1.6:
1212
- ([#10328](https://github.com/quarto-dev/quarto-cli/issues/10328)): Interpret subcells as subfloats when subcap count matches subcell count.
1313
- ([#10624](https://github.com/quarto-dev/quarto-cli/issues/10624)): Don't crash when proof environments are empty in `pdf`.
1414

15+
## `html` Format
16+
17+
- Fix `kbd` element styling on dark themes.
18+
1519
## `revealjs` Format
1620

1721
- Update to Reveal JS 5.1.0.
1822
- Prevent empty SASS built css file to be included in header.
1923
- Remove wrong `sourceMappingUrl` entry in SASS built css.
2024
- ([#7715](https://github.com/quarto-dev/quarto-cli/issues/7715)): Revealjs don't support anymore special Pandoc syntax making BulletList in Blockquotes become incremental list. This was confusing and unexpected behavior. Supported syntax for incremental list is documented at <https://quarto.org/docs/presentations/revealjs/#incremental-lists>.
2125
- ([#9742](https://github.com/quarto-dev/quarto-cli/issues/9742)): Links to cross-referenced images correctly works.
26+
- ([#6012](https://github.com/quarto-dev/quarto-cli/issues/6012)): Add styling for `kbd` element in Revealjs slides.
2227

2328
## `typst` Format
2429

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,11 @@ $indent: 1.2em;
12941294
kbd,
12951295
.kbd {
12961296
color: $body-color;
1297-
background-color: $gray-100;
1297+
@if (quarto-color.blackness($body-bg) > $code-block-theme-dark-threshhold) {
1298+
background-color: shift-color($gray-100, 70%);
1299+
} @else {
1300+
background-color: $gray-100;
1301+
}
12981302
border: 1px solid;
12991303
border-radius: 5px;
13001304
border-color: $table-border-color;

src/resources/formats/revealjs/quarto.scss

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ $body-bg: #fff !default;
1818
$body-color: #222 !default;
1919
$text-muted: lighten($body-color, 30%) !default;
2020

21+
// grey colors (like in bootstrap)
22+
$gray-200: #e9ecef !default;
23+
$gray-100: #f8f9fa !default;
24+
$gray-900: #212529 !default;
25+
2126
// link colors
2227
$primary: #2a76dd !default;
2328
$link-color: $primary !default;
@@ -156,15 +161,48 @@ $overlayElementFgColor: 0, 0, 0 !default;
156161

157162
// -- END setting.scss --
158163

164+
// KBD variables
165+
$kbd-padding-y: 0.4rem !default;
166+
$kbd-padding-x: 0.4rem !default;
167+
$kbd-font-size: $presentation-font-size-root !default;
168+
$kbd-color: $body-color !default;
169+
$kbd-bg: $gray-100 !default; // like in bootstrap style
170+
159171
/*-- scss:functions --*/
160172

161173
@function colorToRGB($color) {
162174
@return "rgb(" + red($color) + ", " + green($color) + ", " + blue($color) +
163175
")";
164176
}
165177

178+
@function tint-color($color, $weight) {
179+
@return mix(white, $color, $weight);
180+
}
181+
182+
@function shade-color($color, $weight) {
183+
@return mix(black, $color, $weight);
184+
}
185+
186+
@function shift-color($color, $weight) {
187+
@return if(
188+
$weight > 0,
189+
shade-color($color, $weight),
190+
tint-color($color, -$weight)
191+
);
192+
}
193+
166194
/*-- scss:mixins --*/
167195

196+
@mixin shift_to_dark($property, $color) {
197+
@if (
198+
sass-color.blackness($backgroundColor) > $code-block-theme-dark-threshhold
199+
) {
200+
#{$property}: shift-color($color, 70%);
201+
} @else {
202+
#{$property}: $color;
203+
}
204+
}
205+
168206
// -- START setting.scss --
169207

170208
// Generates the presentation background, can be overridden
@@ -738,3 +776,16 @@ div.cell-output-display div.pagedtable-wrapper table.table {
738776
.reveal .scrollable ol li:first-child:nth-last-child(n + 10) ~ li {
739777
margin-left: 1em;
740778
}
779+
780+
/* kbd rules */
781+
782+
kbd {
783+
font-family: $font-family-monospace;
784+
font-size: $kbd-font-size;
785+
color: $kbd-color;
786+
@include shift_to_dark("background-color", $kbd-bg);
787+
border: 1px solid;
788+
border-color: $code-block-border-color;
789+
border-radius: 5px;
790+
padding: $kbd-padding-y $kbd-padding-x;
791+
}

0 commit comments

Comments
 (0)