Skip to content

Commit a27c9ca

Browse files
authored
note, tip, warning, caution (#598)
1 parent dfcc016 commit a27c9ca

File tree

8 files changed

+121
-6
lines changed

8 files changed

+121
-6
lines changed

docs/contributing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ yarn test:coverage
4040

4141
## Releasing
4242

43-
(Note: This documentation is for Observable maintainers.) To release a new version of the CLI, first update the [package.json](https://github.com/observablehq/cli/blob/main/package.json) file by following the standard process for committing code changes:
43+
<div class="note">These instructions are intended for Observable staff.</div>
44+
45+
To release a new version of the CLI, first update the [package.json](https://github.com/observablehq/cli/blob/main/package.json) file by following the standard process for committing code changes:
4446

4547
1. Create a new branch.
4648
2. Edit the `version` field in the [package.json](https://github.com/observablehq/cli/blob/main/package.json) file as desired.

docs/layout/note.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Layout: Note
2+
3+
The `note`, `tip`, `warning`, and `caution` classes can be used to insert labeled notes into prose. These are intended to emphasize important information that could otherwise be overlooked.
4+
5+
<div class="note">This is a note.</div>
6+
7+
```html run=false
8+
<div class="note">This is a note.</div>
9+
```
10+
11+
<div class="tip">This is a tip.</div>
12+
13+
```html run=false
14+
<div class="tip">This is a tip.</div>
15+
```
16+
17+
<div class="warning">This is a warning.</div>
18+
19+
```html run=false
20+
<div class="warning">This is a warning.</div>
21+
```
22+
23+
<div class="caution">This is a caution.</div>
24+
25+
```html run=false
26+
<div class="caution">This is a caution.</div>
27+
```
28+
29+
Markdown is not supported within HTML, so if you want rich formatting or links within a note, you must write it as HTML. (In the future, we may add support for notes within Markdown.)
30+
31+
<div class="tip">
32+
<p>This is a <i>styled</i> tip using <small>HTML</small>.</p>
33+
</div>
34+
35+
```html run=false
36+
<div class="tip">
37+
<p>This is a <i>styled</i> tip using <small>HTML</small>.</p>
38+
</div>
39+
```
40+
41+
You can override the note’s label using the `label` attribute.
42+
43+
<div class="warning" label="⚠️ Danger ⚠️">No lifeguard on duty. Swim at your own risk!</div>
44+
45+
```html run=false
46+
<div class="warning" label="⚠️ Danger ⚠️">No lifeguard on duty. Swim at your own risk!</div>
47+
```
48+
49+
You can disable the label entirely with an empty `label` attribute.
50+
51+
<div class="note" label>This note has no label.</div>
52+
53+
```html run=false
54+
<div class="note" label>This note has no label.</div>
55+
```

docs/layout/resize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ html`<div class="grid grid-cols-2" style="grid-auto-rows: 300px;">
5757
</div>
5858
```
5959

60-
Note: If you are using `resize` with both `width` and `height` and see nothing rendered, it may be because your parent container does not have its own height specified.
60+
<div class="tip">If you are using <code>resize</code> with both <code>width</code> and <code>height</code> and see nothing rendered, it may be because your parent container does not have its own height specified.</div>

docs/lib/vega-lite.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ vl.render({
5353
})
5454
```
5555

56-
Note: when loading data from a file as above, use [`FileAttachment`](../javascript/files) so that referenced files are included on [build](../getting-started#build).
56+
<div class="tip">When loading data from a file as above, use <a href="../javascript/files"><code>FileAttachment</code></a> so that referenced files are included on <a href="../getting-started#build">build</a>.</div>
57+

docs/markdown.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Markdown in the Observable CLI follows the [CommonMark spec](https://spec.commonmark.org/) and is powered by [markdown-it](https://github.com/markdown-it/markdown-it). We also feature [live JavaScript](./javascript) as either [fenced code blocks](./javascript#fenced-code-blocks) (<code>```js</code>) or [inline expressions](./javascript#inline-expressions) (<code>$\{…}</code>), and [HTML in Markdown](#html), and [front matter](#front-matter) for page-level configuration. If you don’t already know Markdown, please see [GitHub’s guide to Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for an introduction.
44

5-
_Note: The Observable CLI currently deviates from CommonMark in how blank lines are handled in HTML; see below. This is a limitation of our parser needed for incremental update during preview._
5+
<div class="note">The Observable CLI currently deviates from CommonMark in how blank lines are handled in HTML; see below. This is a limitation of our parser needed for incremental update during preview.</div>
66

77
Here are a few examples of Markdown content to get you started.
88

@@ -23,7 +23,7 @@ toc: false
2323
### A third-level heading
2424
```
2525

26-
Note: a second-level heading (`##`) immediately following a first-level heading (`#`) is styled specially as a subtitle.
26+
<div class="note">A second-level heading (<code>##</code>) immediately following a first-level heading (<code>#</code>) is styled specially as a subtitle.</div>
2727

2828
## Styling
2929

observablehq.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ export default {
2525
name: "Layout",
2626
open: false,
2727
pages: [
28-
{name: "Grid", path: "/layout/grid"},
2928
{name: "Card", path: "/layout/card"},
29+
{name: "Grid", path: "/layout/grid"},
30+
{name: "Note", path: "/layout/note"},
3031
{name: "Resize", path: "/layout/resize"}
3132
]
3233
},

src/style/default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import url("./global.css");
22
@import url("./layout.css");
33
@import url("./grid.css");
4+
@import url("./note.css");
45
@import url("./card.css");
56
@import url("./inspector.css");
67
@import url("./plot.css");

src/style/note.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.note,
2+
.tip,
3+
.warning,
4+
.caution {
5+
border-left: solid 1px var(--theme-foreground-fainter);
6+
padding: 0 2rem;
7+
margin: 1rem 0;
8+
box-sizing: border-box;
9+
max-width: 640px;
10+
}
11+
12+
.note::before,
13+
.tip::before,
14+
.warning::before,
15+
.caution::before {
16+
content: "Note";
17+
display: block;
18+
margin-bottom: 1rem;
19+
font-weight: 700;
20+
color: var(--theme-foreground-muted);
21+
}
22+
23+
.tip {
24+
border-left-color: var(--theme-green);
25+
}
26+
27+
.tip::before {
28+
content: "Tip";
29+
color: var(--theme-green);
30+
}
31+
32+
.warning {
33+
border-left-color: var(--theme-yellow);
34+
}
35+
36+
.warning::before {
37+
content: "Warning";
38+
color: var(--theme-yellow);
39+
}
40+
41+
.caution {
42+
border-left-color: var(--theme-red);
43+
}
44+
45+
.caution::before {
46+
content: "Caution";
47+
color: var(--theme-red);
48+
}
49+
50+
.note[label]::before,
51+
.tip[label]::before,
52+
.warning[label]::before,
53+
.caution[label]::before {
54+
content: attr(label);
55+
}

0 commit comments

Comments
 (0)