@sp-days-framework/docusaurus-plugin-interactive-tasks 1.0.5-rc2 → 1.1.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,308 @@
1
+ ---
2
+ task_section_name: "Interactive Demo 2"
3
+ sidebar_position: 3.2
4
+ sidebar_label: "Advanced Usage"
5
+ sidebar_custom_props:
6
+ section: "Examples"
7
+ section_position: 3
8
+ ---
9
+
10
+ import { useState } from 'react';
11
+
12
+ # Advanced Usage Example
13
+
14
+ Discover how to leverage advanced Docusaurus markdown features within interactive tasks to create rich, engaging learning experiences.
15
+
16
+ <TaskProgression path="." />
17
+
18
+ ---
19
+
20
+ ::::task[Add Syntax Highlighting to Code Blocks]
21
+
22
+ Practice adding syntax-highlighted code blocks to your documentation:
23
+
24
+ 1. Create a code block using triple backticks (```)
25
+ 2. Add the language identifier immediately after the opening backticks
26
+ 3. Write your code inside the block
27
+ 4. Close with triple backticks
28
+
29
+ **Bash example:**
30
+ ```bash
31
+ docker run -d -p 8080:80 nginx
32
+ npm install express
33
+ ```
34
+
35
+ **YAML example:**
36
+ ```yaml
37
+ version: '3.8'
38
+ services:
39
+ web:
40
+ image: nginx:latest
41
+ ports:
42
+ - "8080:80"
43
+ ```
44
+
45
+ **JSON example:**
46
+ ```json
47
+ {
48
+ "name": "my-app",
49
+ "version": "1.0.0",
50
+ "dependencies": {
51
+ "react": "^18.0.0"
52
+ }
53
+ }
54
+ ```
55
+
56
+ :::hint
57
+ Docusaurus supports 30+ languages out of the box. Check the [Prism language list](https://prismjs.com/#supported-languages) for all available options. You can add more languages in `docusaurus.config.ts` - see the [Docusaurus documentation](https://docusaurus.io/docs/markdown-features/code-blocks#supported-languages).
58
+ :::
59
+
60
+ ::::
61
+
62
+ ---
63
+
64
+ ::::task[Add File Names to Code Blocks]
65
+
66
+ Add descriptive file names to your code blocks for better context:
67
+
68
+ 1. After the language identifier, add a space and `title="filename.ext"`
69
+ 2. The filename will appear as a header above the code block
70
+ 3. This helps readers know exactly where code should be placed
71
+
72
+ ```json title="tsconfig.json"
73
+ {
74
+ "compilerOptions": {
75
+ "target": "ES2020",
76
+ "strict": true,
77
+ "strictNullChecks": true,
78
+ "skipLibCheck": true
79
+ }
80
+ }
81
+ ```
82
+
83
+ :::hint
84
+ Use this feature to show exactly where code should be placed in a project structure. It's especially helpful in tutorials with multiple files.
85
+ :::
86
+
87
+ ::::
88
+
89
+ ---
90
+
91
+ ::::task[Highlight Important Code Lines]
92
+
93
+ Learn two methods for highlighting specific lines in code blocks:
94
+
95
+ **Method 1: Inline comments** (best when actively developing)
96
+
97
+ Use `highlight-next-line`, `highlight-start`, and `highlight-end` comments to mark important lines:
98
+
99
+ ```js
100
+ function HighlightSomeText(highlight) {
101
+ if (highlight) {
102
+ // highlight-next-line
103
+ return 'This text is highlighted!';
104
+ }
105
+
106
+ return 'Nothing highlighted';
107
+ }
108
+
109
+ function HighlightMoreText(highlight) {
110
+ // highlight-start
111
+ if (highlight) {
112
+ return 'This range is highlighted!';
113
+ }
114
+ // highlight-end
115
+
116
+ return 'Nothing highlighted';
117
+ }
118
+ ```
119
+
120
+ **Method 2: Meta string** (cleaner for published docs)
121
+
122
+ Add line numbers after the language identifier. Separate multiple lines with commas or use ranges:
123
+
124
+ ```jsx {1,4-6,11}
125
+ import React from 'react';
126
+
127
+ function MyComponent(props) {
128
+ if (props.isBar) {
129
+ return <div>Bar</div>;
130
+ }
131
+
132
+ return <div>Foo</div>;
133
+ }
134
+
135
+ export default MyComponent;
136
+ ```
137
+
138
+ :::hint
139
+
140
+ Supported commenting syntax:
141
+
142
+ | Style | Syntax |
143
+ | ---------- | ------------------------ |
144
+ | C-style | `/* ... */` and `// ...` |
145
+ | JSX-style | `{/* ... */}` |
146
+ | Bash-style | `# ...` |
147
+ | HTML-style | `<!-- ... -->` |
148
+
149
+ Choose inline comments when actively developing, and meta strings for final published documentation.
150
+
151
+ :::
152
+
153
+ ::::
154
+
155
+ ---
156
+
157
+ :::::task[Nest Admonitions in Tasks]
158
+
159
+ Practice nesting admonitions inside tasks by using the correct number of colons:
160
+
161
+ 1. Task containers use 4+ colons: `::::task`
162
+ 2. Hints/solutions use 3+ colons: `:::hint`
163
+ 3. Nested admonitions also use 3+ colons: `:::note`
164
+ 4. For deeper nesting inside hints/solutions, use 4+ colons for the admonition
165
+
166
+ **Rule:** Parent containers always need **more colons** than their children to prevent the parser from prematurely closing containers.
167
+
168
+ :::note
169
+
170
+ This is a note at the task level (3 colons).
171
+
172
+ :::
173
+
174
+ :::warning
175
+
176
+ This is a warning at the task level (3 colons).
177
+
178
+ :::
179
+
180
+ ::::hint
181
+
182
+ This hint contains a nested admonition (4 colons for hint, since it needs to contain a 3-colon admonition):
183
+
184
+ :::note
185
+
186
+ This note is nested inside the hint (3 colons).
187
+
188
+ :::
189
+
190
+ ::::
191
+
192
+ :::::
193
+
194
+ ---
195
+
196
+ ::::task[Use React Components in Tasks]
197
+
198
+ Import and use React components within your task content to create interactive experiences:
199
+
200
+ 1. Import React and any hooks you need at the top of the file: `import { useState } from 'react';`
201
+ 2. Define your component using `export const`
202
+ 3. Use the component anywhere in your MDX content
203
+
204
+ **Example - Interactive Counter:**
205
+
206
+ export const Counter = () => {
207
+ const [count, setCount] = useState(0);
208
+ return (
209
+ <div style={{
210
+ padding: '1rem',
211
+ border: '2px solid var(--ifm-color-primary)',
212
+ borderRadius: '8px',
213
+ textAlign: 'center',
214
+ margin: '1rem 0'
215
+ }}>
216
+ <p style={{ fontSize: '1.5rem', margin: '0.5rem 0' }}>
217
+ Count: <strong>{count}</strong>
218
+ </p>
219
+ <button
220
+ onClick={() => setCount(count + 1)}
221
+ style={{
222
+ marginRight: '0.5rem',
223
+ padding: '0.5rem 1rem',
224
+ fontSize: '1rem',
225
+ cursor: 'pointer'
226
+ }}
227
+ >
228
+ Increment
229
+ </button>
230
+ <button
231
+ onClick={() => setCount(0)}
232
+ style={{
233
+ padding: '0.5rem 1rem',
234
+ fontSize: '1rem',
235
+ cursor: 'pointer'
236
+ }}
237
+ >
238
+ Reset
239
+ </button>
240
+ </div>
241
+ );
242
+ };
243
+
244
+ <Counter />
245
+
246
+ :::hint
247
+
248
+ Tasks support all Docusaurus MDX features, including:
249
+ - React component imports and usage (useState, useEffect, etc.)
250
+ - Tabs, admonitions, and other built-in components
251
+ - Custom CSS and styling with theme-aware variables
252
+ - Interactive JavaScript functionality
253
+
254
+ This makes tasks perfect for interactive tutorials and hands-on learning experiences!
255
+
256
+ :::
257
+
258
+ :::solution
259
+
260
+ Here is the React code running in the task:
261
+
262
+ ```ts
263
+ import { useState } from 'react';
264
+
265
+ export const Counter = () => {
266
+ const [count, setCount] = useState(0);
267
+ return (
268
+ <div style={{
269
+ padding: '1rem',
270
+ border: '2px solid var(--ifm-color-primary)',
271
+ borderRadius: '8px',
272
+ textAlign: 'center',
273
+ margin: '1rem 0'
274
+ }}>
275
+ <p style={{ fontSize: '1.5rem', margin: '0.5rem 0' }}>
276
+ Count: <strong>{count}</strong>
277
+ </p>
278
+ <button
279
+ onClick={() => setCount(count + 1)}
280
+ style={{
281
+ marginRight: '0.5rem',
282
+ padding: '0.5rem 1rem',
283
+ fontSize: '1rem',
284
+ cursor: 'pointer'
285
+ }}
286
+ >
287
+ Increment
288
+ </button>
289
+ <button
290
+ onClick={() => setCount(0)}
291
+ style={{
292
+ padding: '0.5rem 1rem',
293
+ fontSize: '1rem',
294
+ cursor: 'pointer'
295
+ }}
296
+ >
297
+ Reset
298
+ </button>
299
+ </div>
300
+ );
301
+ };
302
+
303
+ <Counter />
304
+ ```
305
+
306
+ :::
307
+
308
+ ::::
@@ -0,0 +1,132 @@
1
+ ---
2
+ task_section_name: "Interactive Demo 1"
3
+ sidebar_position: 3.1
4
+ sidebar_label: "Basic Usage"
5
+ sidebar_custom_props:
6
+ section: "Examples"
7
+ section_position: 3
8
+ ---
9
+
10
+ # Basic Usage Example
11
+
12
+ See interactive tasks in action with real-world examples. This page demonstrates how tasks work in a documentation environment.
13
+
14
+ <TaskProgression path="."/>
15
+
16
+ ---
17
+
18
+ ::::task[Install the Plugin]
19
+
20
+ Follow these steps to add Interactive Tasks to your Docusaurus project:
21
+
22
+ 1. Open your terminal in the project root directory
23
+ 2. Run the installation command for your package manager
24
+ 3. Verify the package appears in your `package.json` dependencies
25
+
26
+
27
+ :::hint
28
+
29
+ If you created your project with `@sp-days-framework/create-sp-days`, this plugin is already installed and you can skip this task.
30
+
31
+ :::
32
+
33
+ ::::
34
+
35
+ ---
36
+
37
+ ::::task[Configure Docusaurus]
38
+
39
+ Add the plugin and remark plugin to your Docusaurus configuration:
40
+
41
+ 1. Open `docusaurus.config.js` in your project root
42
+ 2. Add the plugin to the `plugins` array
43
+ 3. Add the remark plugin to your preset's docs configuration
44
+ 4. Save the file
45
+
46
+ :::solution
47
+
48
+ The plugin needs to be registered in two places: the `plugins` array for the main functionality, and the `remarkPlugins` array to transform task directives in your markdown files.
49
+
50
+ **Verify Configuration:**
51
+
52
+ - The file should have both entries as shown below
53
+ - No syntax errors when running `npm run start`
54
+
55
+ Add to your `docusaurus.config.js`:
56
+
57
+ ```js title="docusaurus.config.js"
58
+ module.exports = {
59
+ plugins: ["@sp-days-framework/docusaurus-plugin-interactive-tasks"],
60
+
61
+ presets: [
62
+ [
63
+ "classic",
64
+ {
65
+ docs: {
66
+ remarkPlugins: [
67
+ require("@sp-days-framework/docusaurus-plugin-interactive-tasks")
68
+ .remarkTaskDirective,
69
+ ],
70
+ },
71
+ },
72
+ ],
73
+ ],
74
+ };
75
+ ```
76
+
77
+ :::
78
+
79
+ ::::
80
+
81
+ ---
82
+
83
+ ::::task[Add Progress Tracking]
84
+
85
+ Display task completion progress on your documentation pages:
86
+
87
+ 1. Import the `TaskProgression` component in your MDX file
88
+ 2. Add the component where you want to show progress
89
+ 3. Provide the path to the document you want to track
90
+
91
+ Add to your MDX file:
92
+
93
+ ```mdx
94
+ import TaskProgression from "@theme/TaskProgression";
95
+
96
+ <TaskProgression path="." />
97
+ ```
98
+
99
+ Reference other pages:
100
+
101
+ ```mdx
102
+ <TaskProgression path="/docs/tutorial/first-task" />
103
+ <TaskProgression path="../module-02/introduction" />
104
+ ```
105
+
106
+ :::hint
107
+
108
+ Use `path="."` to reference the current page, or provide an absolute/relative path to track other pages. The component shows a visual progress bar and completion count.
109
+
110
+ :::
111
+
112
+ ::::
113
+
114
+ ---
115
+
116
+ ::::task[Test Auto-Collapse Feature]
117
+
118
+ Learn how the auto-collapse feature helps you focus on incomplete tasks:
119
+
120
+ 1. Complete at least one task on this page by clicking "Mark as Done"
121
+ 2. Look for the collapse icon button in the navbar
122
+ 3. Click the collapse icon to enable auto-collapse mode
123
+ 4. Observe how completed tasks automatically collapse
124
+ 5. Click the collapse icon again to disable the feature
125
+
126
+ :::hint
127
+
128
+ The auto-collapse setting is saved to your browser's localStorage and syncs across all tabs. This feature is especially useful when working through long tutorial pages with many tasks.
129
+
130
+ :::
131
+
132
+ ::::
package/docs/index.mdx ADDED
@@ -0,0 +1,159 @@
1
+ ---
2
+ title: Interactive Tasks
3
+ hide_title: true
4
+ sidebar_class_name: title-logo-sidebar-docusaurus
5
+ sidebar_label: "Interactive Tasks"
6
+ sidebar_position: 0
7
+ ---
8
+
9
+ import LogoDocusaurus from './logo-docusaurus.svg';
10
+
11
+ <div align="center">
12
+ <div style={{ display: 'flex', justifyContent: 'center', margin: '1rem' }}>
13
+ <LogoDocusaurus width="110" height="110"/>
14
+ </div>
15
+ <div align="center">
16
+ # Interactive Tasks
17
+ </div>
18
+ <div align="center">
19
+ <p>
20
+ *A Docusaurus plugin that transforms documentation into interactive learning experiences!*
21
+ </p>
22
+ <h4>
23
+ <a href="./interactive-tasks/install">🔧 Setup</a> ·
24
+ <a href="https://www.npmjs.com/package/@sp-days-framework/docusaurus-plugin-interactive-tasks">📦 NPM Package</a> ·
25
+ <a href="https://github.com/helse-sorost/sp-days-framework">💻 Source Code</a>
26
+ </h4>
27
+ </div>
28
+ </div>
29
+
30
+ <div style={{ position: 'relative', marginTop: '2rem', display: 'flex', justifyContent: 'center' }}>
31
+ <div style={{ position: 'absolute', left: '50%', marginTop: '4px', transform: 'translateX(-50%)', fontWeight: 500, color: 'var(--ifm-color-emphasis-600)' }}>
32
+ Preview
33
+ </div>
34
+ <div id="preview-task-example" style={{ borderRadius: '12px', padding: '2rem 1.7rem 0rem', background: 'var(--ifm-color-emphasis-200)' }}>
35
+ <style>{`
36
+ #preview-task-example h3 {
37
+ display: none !important;
38
+ }
39
+ `}</style>
40
+ ::::task-example[Calibrate the Flux Capacitor ⚡]
41
+
42
+ Great Scott, Marty! We need to recalibrate the **temporal documentation flux capacitor** to 1.21 gigawatts!
43
+
44
+ 1. Check the chronosync matrix for para-dimensional efficiency
45
+ 2. Initiate the **quantum state persistence protocol**
46
+ 3. Engage the localStorage temporal buffer
47
+ 4. Restart the cross-timeline synchronization array by running the following command:
48
+ ```bash
49
+ sudo systemctl restart ntpd
50
+ ```
51
+
52
+ :::hint
53
+ The "Mark as Done" actuator button is located in the down-right quadrant of the task containment field. A simple click should energize the completion state capacitor!
54
+ :::
55
+
56
+ :::output
57
+ If done correctly, you should observe the following temporal anomalies:
58
+
59
+ ```
60
+ ⚡ Flux capacitor status: ENGAGED
61
+ 📊 Temporal progress vector: SYNCHRONIZED
62
+ 💾 localStorage quantum buffer: PERSISTED
63
+ ✅ Task completion waveform: COLLAPSED TO TRUE STATE
64
+ ```
65
+
66
+ Heavy! Your progress just traveled through time! 🚗💨
67
+ :::
68
+
69
+ :::solution
70
+ When you check that box, the plugin harnesses the power of localStorage to preserve your completion state across multiple timeline iterations (browser sessions).
71
+
72
+ The temporal data persists even if you reload the page or jump to a different tab - it's like the DeLorean maintaining 88 mph across different roads!
73
+
74
+ Key features of the completion tracking system:
75
+ - **Persistent storage** across browser sessions
76
+ - **Real-time synchronization** between tabs
77
+ - **Automatic state management** for your learning progress
78
+ - **Cross-dimensional compatibility** (works in any timeline!)
79
+
80
+ *This is heavy... but in a good way!* 🎸
81
+ :::
82
+
83
+ ::::
84
+ </div>
85
+ </div>
86
+ <br/>
87
+
88
+ ---
89
+
90
+ ## Features
91
+
92
+ - **Interactive Tasks** - Collapsible task components with completion tracking
93
+ - **Hints, Solutions & Expected Outputs** - Optional toggleable hints, solutions, and expected outputs for each task
94
+ - **Auto-Numbering** - Automatic task numbering per page
95
+ - **Persistent Progress** - Completion status saved to localStorage
96
+ - **Progress Tracking** - Visual progress indicators in sidebar and task progression components
97
+ - **Sidebar Badges** - Automatic completion badges (e.g., "2/5") in sidebar navigation
98
+ - **Auto-Collapse Toggle** - Navbar button to enable/disable auto-collapsing of completed tasks
99
+
100
+ ## Getting Started
101
+
102
+ Create interactive tasks using simple markdown directives:
103
+
104
+ ````mdx
105
+ ::::task[Install the Plugin]
106
+
107
+ Install the Interactive Tasks plugin using npm or yarn.
108
+
109
+ :::hint
110
+ Use npm install or yarn add to install the package.
111
+ :::
112
+
113
+ :::output
114
+ You should see output similar to:
115
+
116
+ ```
117
+ added 1 package, and audited 2 packages in 3s
118
+
119
+ found 0 vulnerabilities
120
+ ```
121
+ :::
122
+
123
+ :::solution
124
+ ```bash
125
+ npm install @sp-days-framework/docusaurus-plugin-interactive-tasks
126
+ ```
127
+ :::
128
+
129
+ ::::
130
+ ````
131
+
132
+ ::::task-example[Install the Plugin]
133
+
134
+ Install the Interactive Tasks plugin using npm or yarn.
135
+
136
+ :::hint
137
+ Use npm install or yarn add to install the package.
138
+ :::
139
+
140
+ :::output
141
+ You should see output similar to:
142
+
143
+ ```
144
+ added 1 package, and audited 2 packages in 3s
145
+
146
+ found 0 vulnerabilities
147
+ ```
148
+ :::
149
+
150
+ :::solution
151
+ ```bash
152
+ npm install @sp-days-framework/docusaurus-plugin-interactive-tasks
153
+ ```
154
+ :::
155
+
156
+ ::::
157
+
158
+
159
+ Tasks are automatically numbered, track completion in localStorage, and sync across browser tabs. See [Install](install.mdx) for installation and configuration.
@@ -0,0 +1,121 @@
1
+ ---
2
+ sidebar_position: 1.1
3
+ sidebar_custom_props:
4
+ section: "Setup"
5
+ section_position: 1
6
+ ---
7
+
8
+ import Tabs from "@theme/Tabs";
9
+ import TabItem from "@theme/TabItem";
10
+
11
+ # Installation
12
+
13
+ :::tip[Already Included]
14
+ If you're using `@sp-days-framework/create-sp-days`, the Interactive Tasks plugin is already installed and configured. You can start creating tasks right away!
15
+ :::
16
+
17
+ Install the plugin using your preferred package manager:
18
+
19
+ <Tabs>
20
+ <TabItem value="npm" label="npm" default>
21
+ ```bash
22
+ npm install @sp-days-framework/docusaurus-plugin-interactive-tasks
23
+ ```
24
+ </TabItem>
25
+ <TabItem value="yarn" label="Yarn">
26
+ ```bash
27
+ yarn add @sp-days-framework/docusaurus-plugin-interactive-tasks
28
+ ```
29
+ </TabItem>
30
+ </Tabs>
31
+
32
+ Add the plugin to your plugins array and the remark plugin to your docs configuration:
33
+
34
+ ```js title="docusaurus.config.js" {2,9-11}
35
+ module.exports = {
36
+ plugins: ["@sp-days-framework/docusaurus-plugin-interactive-tasks"],
37
+
38
+ presets: [
39
+ [
40
+ "classic",
41
+ {
42
+ docs: {
43
+ beforeDefaultRemarkPlugins: [
44
+ require("@sp-days-framework/docusaurus-plugin-interactive-tasks")
45
+ .remarkTaskDirective,
46
+ ],
47
+ },
48
+ },
49
+ ],
50
+ ],
51
+ };
52
+ ```
53
+
54
+ ### Frontmatter Options
55
+
56
+ Customize task badge appearance for individual pages:
57
+
58
+ ```mdx title="docs/my-module.mdx"
59
+ ---
60
+ title: My Module
61
+ sidebar_task_hide_progress: false
62
+ sidebar_task_disable_icon: false
63
+ sidebar_task_badge_colors:
64
+ completed:
65
+ lightmode: "#4caf50"
66
+ darkmode: "#66bb6a"
67
+ incomplete:
68
+ lightmode: "#2196f3"
69
+ darkmode: "#42a5f5"
70
+ font:
71
+ lightmode: "#ffffff"
72
+ darkmode: "#000000"
73
+ ---
74
+
75
+ # My Module Content
76
+ ```
77
+
78
+ ### Category Sidebar Configuration
79
+
80
+ Customize task badges for entire categories using `_category_.yml` or `_category_.json`:
81
+
82
+ <Tabs>
83
+ <TabItem value="yaml" label="YAML" default>
84
+ ```yaml title="docs/module-01/_category_.yml"
85
+ label: "Module 1"
86
+ position: 1
87
+ customProps:
88
+ sidebar_task_badge_colors:
89
+ completed:
90
+ lightmode: "#4caf50"
91
+ darkmode: "#66bb6a"
92
+ incomplete:
93
+ lightmode: "#2196f3"
94
+ darkmode: "#42a5f5"
95
+ sidebar_task_disable_icon: false
96
+ ```
97
+ </TabItem>
98
+ <TabItem value="json" label="JSON">
99
+ ```json title="docs/module-02/_category_.json"
100
+ {
101
+ "label": "Module 2",
102
+ "position": 2,
103
+ "customProps": {
104
+ "sidebar_task_hide_progress": false,
105
+ "sidebar_task_badge_colors": {
106
+ "completed": {
107
+ "lightmode": "#4caf50",
108
+ "darkmode": "#66bb6a"
109
+ },
110
+ "incomplete": {
111
+ "lightmode": "#2196f3",
112
+ "darkmode": "#42a5f5"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+ </TabItem>
119
+ </Tabs>
120
+
121
+ See [Advanced Configuration](./advanced-configuration.mdx) for all available options.