@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.
package/docs/tasks.mdx ADDED
@@ -0,0 +1,433 @@
1
+ ---
2
+ sidebar_position: 2.1
3
+ toc_max_heading_level: 2
4
+ sidebar_label: "Task"
5
+ sidebar_custom_props:
6
+ section: "Components"
7
+ section_position: 2
8
+ ---
9
+
10
+ import Tabs from "@theme/Tabs";
11
+ import TabItem from "@theme/TabItem";
12
+
13
+ # Task Component
14
+
15
+ Learn how to create interactive tasks with various features including hints, solutions, and non-persistent examples.
16
+
17
+ <div style={{ position: 'relative', marginTop: '2rem', display: 'flex', justifyContent: 'center' }}>
18
+ <div style={{ position: 'absolute', left: '50%', marginTop: '4px', transform: 'translateX(-50%)', fontWeight: 500, color: 'var(--ifm-color-emphasis-600)' }}>
19
+ Preview
20
+ </div>
21
+ <div id="preview-task-example" style={{ borderRadius: '12px', padding: '2rem 2rem 0rem 2rem', background: 'var(--ifm-color-emphasis-200)' }}>
22
+ <style>{`
23
+ #preview-task-example h3 {
24
+ display: none !important;
25
+ }
26
+ `}</style>
27
+ ::::task-example[Explore the Task Component Features]
28
+
29
+ This is an interactive task component! **Try clicking the buttons** to explore its features:
30
+
31
+ 1. **Need guidance?** Click the "Show Hint" button below to reveal helpful information
32
+ 3. **Check your work?** Click "Show Expected Output" to see what you should get
33
+ 2. **Want the answer?** Click "Show Solution" to see the complete solution
34
+ 4. **Mark progress**: Click "Mark as Done" to track completion
35
+
36
+ :::hint
37
+
38
+ **This is a hint section!**
39
+
40
+ Hints are perfect for providing guidance without spoiling the solution. They can contain:
41
+ - Tips and best practices
42
+ - Links to relevant documentation
43
+ - Reminders about important concepts
44
+ - Warnings about common pitfalls
45
+
46
+ You can include any markdown content here, including lists, **formatting**, and [links](https://docusaurus.io).
47
+
48
+ :::
49
+
50
+ :::output
51
+
52
+ **This is an expected output section!**
53
+
54
+ The output section uses a success color theme to help users verify their work. Use it to show:
55
+ - Terminal command outputs
56
+ - Expected console logs
57
+ - API responses
58
+ - Visual results
59
+
60
+ This helps learners confirm they've completed the task correctly!
61
+
62
+ :::
63
+
64
+ :::solution
65
+
66
+ **This is a solution section!**
67
+
68
+ Solutions show the complete answer. This is where you'd typically include:
69
+ - Step-by-step instructions
70
+ - Complete code implementations
71
+ - Configuration examples
72
+ - Verification steps
73
+
74
+ Since this is a `task-example`, your completion status won't be saved. Regular `task` components automatically persist progress to browser localStorage.
75
+
76
+ :::
77
+
78
+ ::::
79
+ </div>
80
+ </div>
81
+
82
+
83
+
84
+ ---
85
+
86
+
87
+ ## Basic Task
88
+
89
+ A simple task without hints or solutions.
90
+
91
+
92
+ ```md
93
+ ::::task[Create a Component]
94
+
95
+ Create a new React component in `src/components/MyComponent.tsx`.
96
+
97
+ ::::
98
+ ```
99
+
100
+ ::::task-example[Create a Component]
101
+
102
+ Create a new React component in `src/components/MyComponent.tsx`.
103
+
104
+ ::::
105
+
106
+
107
+ ---
108
+
109
+ ## Task with Hint
110
+
111
+ Add a hint to guide users through the task.
112
+
113
+
114
+ ```mdx
115
+ ::::task[Configure TypeScript]
116
+
117
+ Set up TypeScript configuration for strict mode.
118
+
119
+ :::hint
120
+ Look for the `tsconfig.json` file in your project root.
121
+ :::
122
+
123
+ ::::
124
+ ```
125
+
126
+ ::::task-example[Configure TypeScript]
127
+
128
+ Set up TypeScript configuration for strict mode.
129
+
130
+ :::hint
131
+ Look for the `tsconfig.json` file in your project root.
132
+ :::
133
+
134
+ ::::
135
+
136
+ ---
137
+
138
+ ## Task with Solution
139
+
140
+ Provide a complete solution for the task.
141
+
142
+
143
+ ```mdx
144
+ ::::task[Create Package JSON]
145
+
146
+ Initialize a new Node.js project with npm.
147
+
148
+ :::solution
149
+ Run `npm init -y` in your project directory.
150
+ :::
151
+
152
+ ::::
153
+ ```
154
+
155
+ ::::task-example[Create Package JSON]
156
+
157
+ Initialize a new Node.js project with npm.
158
+
159
+ :::solution
160
+ Run `npm init -y` in your project directory.
161
+ :::
162
+
163
+ ::::
164
+
165
+ ---
166
+
167
+ ## Task with Hint and Solution
168
+
169
+ Combine both hint and solution for comprehensive guidance.
170
+
171
+ ````mdx
172
+ ::::task[Add API Route]
173
+
174
+ Create a new API endpoint for user authentication.
175
+
176
+ :::hint
177
+ API routes in Next.js go in the `app/api` directory.
178
+ :::
179
+
180
+ :::solution
181
+ Create `app/api/auth/route.ts`:
182
+
183
+ ```typescript
184
+ export async function POST(request: Request) {
185
+ const body = await request.json();
186
+ // Authentication logic here
187
+ return Response.json({ success: true });
188
+ }
189
+ ```
190
+ :::
191
+
192
+ ::::
193
+ ````
194
+
195
+ ::::task-example[Add API Route]
196
+
197
+ Create a new API endpoint for user authentication.
198
+
199
+ :::hint
200
+ API routes in Next.js go in the `app/api` directory.
201
+ :::
202
+
203
+ :::solution
204
+ Create `app/api/auth/route.ts`:
205
+
206
+ ```typescript
207
+ export async function POST(request: Request) {
208
+ const body = await request.json();
209
+ // Authentication logic here
210
+ return Response.json({ success: true });
211
+ }
212
+ ```
213
+ :::
214
+
215
+ ::::
216
+
217
+
218
+ ---
219
+
220
+ ## Task with Expected Output
221
+
222
+ Show users what output they should expect from completing the task.
223
+
224
+ ````mdx
225
+ ::::task[Run Docker Container]
226
+
227
+ Start a new nginx container in detached mode on port 8080.
228
+
229
+ :::output
230
+ ```bash
231
+ $ docker run -d -p 8080:80 nginx
232
+ a3f5c8b9d2e1f4a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1
233
+ ```
234
+
235
+ Visit `http://localhost:8080` and you should see the nginx welcome page.
236
+ :::
237
+
238
+ ::::
239
+ ````
240
+
241
+ ::::task-example[Run Docker Container]
242
+
243
+ Start a new nginx container in detached mode on port 8080.
244
+
245
+ :::output
246
+ ```bash
247
+ $ docker run -d -p 8080:80 nginx
248
+ a3f5c8b9d2e1f4a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1
249
+ ```
250
+
251
+ Visit `http://localhost:8080` and you should see the nginx welcome page.
252
+ :::
253
+
254
+ ::::
255
+
256
+ ---
257
+
258
+ ## Task with All Features
259
+
260
+ Combine hint, solution, and expected output for maximum guidance.
261
+
262
+ ````mdx
263
+ ::::task[Build and Test Application]
264
+
265
+ Build the application and verify it works correctly.
266
+
267
+ :::hint
268
+ Use the npm script defined in `package.json` for building.
269
+ :::
270
+
271
+ :::solution
272
+ ```bash
273
+ npm run build
274
+ npm run test
275
+ ```
276
+ :::
277
+
278
+ :::output
279
+ ```bash
280
+ $ npm run build
281
+ > Building application...
282
+ > ✓ Compiled successfully
283
+
284
+ $ npm run test
285
+ > Running tests...
286
+ > ✓ All tests passed (12/12)
287
+ ```
288
+ :::
289
+
290
+ ::::
291
+ ````
292
+
293
+ ::::task-example[Build and Test Application]
294
+
295
+ Build the application and verify it works correctly.
296
+
297
+ :::hint
298
+ Use the npm script defined in `package.json` for building.
299
+ :::
300
+
301
+ :::solution
302
+ ```bash
303
+ npm run build
304
+ npm run test
305
+ ```
306
+ :::
307
+
308
+ :::output
309
+ ```bash
310
+ $ npm run build
311
+ > Building application...
312
+ > ✓ Compiled successfully
313
+
314
+ $ npm run test
315
+ > Running tests...
316
+ > ✓ All tests passed (12/12)
317
+ ```
318
+ :::
319
+
320
+ ::::
321
+
322
+
323
+ ---
324
+
325
+ ## Using Markdown Features
326
+
327
+ Tasks fully support standard Docusaurus markdown features like the [admonitions feature](https://docusaurus.io/docs/markdown-features/admonitions).
328
+
329
+
330
+ ````mdx
331
+ ::::task[Setup Development Environment]
332
+
333
+ Follow these steps to configure your workspace.
334
+
335
+ :::note
336
+ Make sure you have Node.js 18+ installed before proceeding.
337
+ :::
338
+
339
+ **Installation Steps:**
340
+
341
+ 1. Install dependencies:
342
+ ```bash
343
+ npm install
344
+ ```
345
+
346
+ 2. Start the development server:
347
+ ```bash
348
+ npm run dev
349
+ ```
350
+
351
+ :::warning
352
+ Do not commit your `.env` file to version control!
353
+ :::
354
+
355
+ :::hint
356
+ Check the README.md for environment variable examples.
357
+ :::
358
+
359
+ ::::
360
+ ````
361
+
362
+ ::::task-example[Setup Development Environment]
363
+
364
+ Follow these steps to configure your workspace.
365
+
366
+ :::note
367
+ Make sure you have Node.js 18+ installed before proceeding.
368
+ :::
369
+
370
+ **Installation Steps:**
371
+
372
+ 1. Install dependencies:
373
+ ```bash
374
+ npm install
375
+ ```
376
+
377
+ 2. Start the development server:
378
+ ```bash
379
+ npm run dev
380
+ ```
381
+
382
+ :::warning
383
+ Do not commit your `.env` file to version control!
384
+ :::
385
+
386
+ :::hint
387
+ Check the README.md for environment variable examples.
388
+ :::
389
+
390
+ ::::
391
+
392
+ ## Syntax Reference
393
+
394
+ | Element | Directive | Requirement | Notes |
395
+ |---------|-----------|-------------|-------|
396
+ | **Task Container** | `::::task[Task Name]` (4+ colons) | Required | Tasks are auto-numbered sequentially per page |
397
+ | **Hint Section** | `:::hint` (3+ colons) | Optional | Max one per task; additional hints ignored with warning. Can appear anywhere inside task container |
398
+ | **Solution Section** | `:::solution` (3+ colons) | Optional | Max one per task; additional solutions ignored with warning. Can appear anywhere inside task container |
399
+ | **Expected Output Section** | `:::output` (3+ colons) | Optional | Max one per task; additional outputs ignored with warning. Can appear anywhere inside task container. Uses success color theme (`--ifm-color-success`) |
400
+ | **Task Example** | `::::task-example[Example Name]` (4+ colons) | Required | Same as regular tasks but non-persistent; uses "Example N" numbering |
401
+
402
+ ## Nesting
403
+
404
+ The `::::task` directive supports nesting [admonitions](https://docusaurus.io/docs/markdown-features/admonitions) and other markdown features by using colon count to determine hierarchy. Each parent container must use **more colons** than its children to prevent premature closure.
405
+
406
+ **Nesting rules:**
407
+ - Task container: `::::task` (4+ colons)
408
+ - Hint/Solution: `:::hint` or `:::solution` (3+ colons)
409
+ - Nested admonition: `:::note`, `:::tip`, etc. (3+ colons)
410
+ - For deeper nesting, add more colons to parent containers
411
+
412
+ Each level needs more colons than its children to avoid premature closure.
413
+
414
+ ### Nesting Example
415
+
416
+ ```mdx
417
+ ::::::task[Nested Example]
418
+ (Layer 1)
419
+
420
+ :::::hint
421
+ (Layer 2)
422
+
423
+ ::::note
424
+ (Layer 3)
425
+
426
+ :::warning
427
+ (Layer 4)
428
+ :::
429
+
430
+ :::::
431
+
432
+ ::::::
433
+ ```
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@sp-days-framework/docusaurus-plugin-interactive-tasks",
3
- "version": "1.0.5-rc2",
3
+ "version": "1.1.0-beta2",
4
4
  "description": "A Docusaurus plugin for interactive task components with progress tracking",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/helse-sorost/sp-days-framework",
7
+ "url": "git+https://github.com/helse-sorost/sp-days-framework.git",
8
8
  "directory": "docusaurus-plugin-interactive-tasks"
9
9
  },
10
10
  "keywords": [
@@ -21,6 +21,8 @@
21
21
  "types": "lib/index.d.ts",
22
22
  "files": [
23
23
  "lib/**/*",
24
+ "docs/**/*",
25
+ "publish-package-docs.js",
24
26
  "README.md",
25
27
  "LICENSE"
26
28
  ],
@@ -30,6 +32,7 @@
30
32
  "import": "./lib/index.js",
31
33
  "types": "./lib/index.d.ts"
32
34
  },
35
+ "./publish-package-docs": "./publish-package-docs.js",
33
36
  "./lib/theme/*": "./lib/theme/*",
34
37
  "./lib/plugin/*": "./lib/plugin/*"
35
38
  },
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Sykehuspartner HF
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ module.exports = {
9
+ id: "interactive-tasks-docs",
10
+ path: require("path").join(__dirname, "docs"),
11
+ routeBasePath: "package-docs/interactive-tasks",
12
+ beforeDefaultRemarkPlugins: [
13
+ [
14
+ require("./lib/index.js").remarkTaskDirective,
15
+ {
16
+ tocHeadingLevel: 3,
17
+ },
18
+ ],
19
+ ],
20
+ };