-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.html
More file actions
88 lines (79 loc) · 2.06 KB
/
map.html
File metadata and controls
88 lines (79 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Learningmap Editor Test</title>
<link rel="stylesheet" href="./dist/web-component-learningmap.css">
<style>
body {
margin: 0;
padding: 0;
font-family: system-ui, -apple-system, sans-serif;
}
hyperbook-learningmap {
display: block;
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<hyperbook-learningmap id="map" language="en"></hyperbook-learningmap>
<script src="./dist/index.umd.js"></script>
<script>
const map = document.getElementById('map');
// Initialize with sample data
const initialData = {
settings: {
title: "Sample Learning Roadmap",
background: {
color: "#f0f9ff"
}
},
nodes: [
{
id: "node1",
type: "task",
position: {x: 100, y: 100},
className: "red",
data: {
label: "Getting Started",
summary: "Introduction to the topic",
description: "Learn the fundamentals",
resources: [
{label: "Documentation", url: "https://example.com/docs"}
]
}
},
{
id: "node2",
type: "topic",
className: "blue",
position: {x: 100, y: 300},
data: {
label: "Advanced Topics",
summary: "Deep dive into advanced concepts",
unlock: {
after: ["node1"]
},
completion: {
needs: ["node1"]
}
}
}
],
edges: [],
};
map.setAttribute('roadmap-data', JSON.stringify(initialData));
// Listen for save events
map.addEventListener('change', (event) => {
console.log('Roadmap changed:', event.detail);
});
const initialState = {
nodes: {node1: {state: "started"}}
}
map.setAttribute('initial-state', JSON.stringify(initialState));
</script>
</body>
</html>