Skip to content

Commit 3883e6e

Browse files
committed
Add a color box to show which color it is as hexcode is not really that readable in documentation
1 parent e58bb75 commit 3883e6e

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ format:
672672

673673
filters:
674674
- filters/tools-tabset.lua
675+
- filters/color-box.lua
675676

676677
freeze: true
677678

docs/presentations/revealjs/themes.qmd

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,14 @@ Here's a list of all Sass variables (and their default values) used by Reveal th
193193
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
194194
| `$callout-color-<type>` | The colors for the various types of callouts. Defaults: |
195195
| | |
196-
| | | type | default | |
197-
| | |-------------|-----------| |
198-
| | | `note` | `#0d6efd` | |
199-
| | | `tip` | `#198754` | |
200-
| | | `caution` | `#dc3545` | |
201-
| | | `warning` | `#fd7e14` | |
202-
| | | `important` | `#ffc107` | |
196+
| | | type | default | |
197+
| | |-------------|-------------------------| |
198+
| | | `note` | [`#0d6efd`]{.color-box} | |
199+
| | | `tip` | [`#198754`]{.color-box} | |
200+
| | | `caution` | [`#dc3545`]{.color-box} | |
201+
| | | `warning` | [`#fd7e14`]{.color-box} | |
202+
| | | `important` | [`#ffc107`]{.color-box} | |
203+
| | |
203204
| | Note that style for callout is to have left border using type color, and header background to use a variation of this color. |
204205
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
205206

filters/color-box.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Span = function(s)
2+
if not quarto.format.isHtmlOutput() then
3+
return nil
4+
end
5+
if s.classes:includes('color-box') then
6+
local color
7+
if s.attributes['color'] then
8+
quarto.log.output("HERE")
9+
color = s.attributes['color']
10+
s.attributes.color = nil
11+
elseif #s.content == 1 and s.content[1] and s.content[1].t == "Code" and s.content[1].text and s.content[1].text:sub(1, 1) == '#' then
12+
color = s.content[1].text
13+
end
14+
if color then
15+
s.content:insert(1, pandoc.Span('', pandoc.Attr('', { 'color-box' }, { style ="background-color:" .. color .. ";"})))
16+
return pandoc.Span( s.content , { "", { "color-box-container" } })
17+
end
18+
end
19+
end

styles.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,16 @@ iframe.reveal-demo {
337337
.illustration {
338338
border: 1px solid #dee2e6;
339339
}
340+
341+
span.color-box-container {
342+
display: inline-flex;
343+
align-items: center; /* Align vertically */
344+
}
345+
346+
span.color-box {
347+
display: inline-block;
348+
width: 1em; /* Width of the color box */
349+
height: 1em; /* Height of the color box */
350+
margin-right: 0.2em; /* Space between box and text */
351+
border: 1px solid #000; /* Border color */
352+
}

0 commit comments

Comments
 (0)