You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> If you ever move or rename your Quarto document, you'll need to update this block with the new location and filename!
30
+
:::{.callout-warning}
31
+
This magic block must be the **first** thing in your document---straight after the frontmatter!
32
+
33
+
If you ever move or rename your Quarto document, you'll need to update this block with the new location and filename.
34
+
:::
31
35
32
36
### 2. Import the component
33
37
34
-
Import your Svelte file in an OJS block. Here we call the result `Circles`:
38
+
Import your Svelte file in an OJS block using the `import_svelte` function. Here we call the result `Circles`:
35
39
36
40
```{ojs}
37
41
Circles = import_svelte("Circles.svelte")
@@ -43,16 +47,21 @@ We need to create an instance of our imported component, but---unlike a typical
43
47
44
48
Create an empty div in your document and give it an #id with the hashtag. This will be the "target" in the next step, when we bring the component to life, or _instantiate_ it:
45
49
46
-
````markdown
50
+
```markdown
47
51
:::{#mycircles}
48
52
:::
49
-
````
53
+
```
50
54
51
55
:::{#mycircles}
52
56
:::
53
57
54
-
> **Tip:** this block can go anywhere in your document! In fact, order doesn't matter for any of these steps, other than the frontmatter.
58
+
:::{.callout-tip}
59
+
This block can go anywhere in your document! Feel free to put it well after the following steps, where you actually want your visualisation to appear.
60
+
:::
55
61
62
+
:::{.callout-tip}
63
+
If you know how how to use CSS, you can target `#mycircles` to position or size your visualisation as you'd like.
64
+
:::
56
65
57
66
### 4. Instantiate your component
58
67
@@ -72,11 +81,13 @@ myCircles = new Circles.default({
72
81
});
73
82
```
74
83
75
-
> **Important:** if you're creating a visual that will react in response to changing OJS (for example, some data that you've calculated in your document, or the value of an Observable Input), _do not put that data here._
76
-
>
77
-
> If you put changing data here, the Svelte component will rebuild from scratch every time the data changes, and it will not animate.
78
-
>
79
-
> Instead, we're going to take advantage of Svelte's own reactivity in the next step.
84
+
::: {.callout-important}
85
+
If you're creating a visual that will react in response to changing OJS (for example, some data that you've calculated in your document, or the value of an Observable Input), **do not put that data here.**
86
+
87
+
If you put changing data here, the Svelte component will rebuild from scratch every time the data changes, and it will not animate.
88
+
89
+
Instead, we're going to take advantage of Svelte's own reactivity in the next step.
You can't see anything here, but if we scroll back up to where we added the empty `#mycircles` block, you can see it transition whenever we select a new dataset!
108
119
109
-
> **Tip:** you can put `#mycircles` wherever you want in the document - it doesn't have to be in order!
120
+
:::{.callout-tip}
121
+
You can put `#mycircles` wherever you want in the document - it doesn't have to be in order!
122
+
:::
110
123
111
124
### 6. Render the project
112
125
113
126
Render your Quarto project as you normally would, with commands like `quarto run` and `quarto preview`.
114
127
115
-
> **Note:** you'll probably get the warning "OJS block count mismatch. Line number reporting is likely to be wrong" when rendering.
116
-
>
117
-
> That's because of what we're doing under the hood to bring the Svelte files in. It won't stop your project from working, but be aware of it if you are referring to line numbers in code blocks!
128
+
:::{.callout-note}
129
+
You'll probably get the warning `OJS block count mismatch. Line number reporting is likely to be wrong` when rendering.
130
+
131
+
That's because of what we're doing under the hood to bring the Svelte files in. It won't stop your project from working, but be aware of it if you are referring to line numbers in code blocks!
0 commit comments