tangled
alpha
login
or
join now
graham.systems
/
morkdeck
0
fork
atom
Generate web slides from Markdoc
0
fork
atom
overview
issues
2
pulls
pipelines
refactor(templates): remove web components
graham.systems
8 months ago
219dba82
05397253
verified
This commit was signed with the committer's
known signature
.
graham.systems
SSH Key Fingerprint:
SHA256:Fvaam8TgCBeBlr/Fo7eA6VGAIAWmzjwUqUTw5o6anWA=
-109
2 changed files
expand all
collapse all
unified
split
templates
components
presentation.eta
slide.eta
-65
templates/components/presentation.eta
reviewed
···
1
1
-
<script type="module">
2
2
-
import { LitElement, html, css } from 'lit';
3
3
-
4
4
-
class Presentation extends LitElement {
5
5
-
static properties = {
6
6
-
uuid: { type: String }
7
7
-
}
8
8
-
9
9
-
static styles = css`
10
10
-
:host {
11
11
-
display: block;
12
12
-
width: 100vw;
13
13
-
height: 100vh;
14
14
-
overflow-y: scroll;
15
15
-
scroll-behavior: smooth;
16
16
-
scroll-snap-type: y mandatory;
17
17
-
}
18
18
-
`
19
19
-
20
20
-
constructor() {
21
21
-
super()
22
22
-
23
23
-
this.observer = new IntersectionObserver(this.updateUrl, {
24
24
-
root: this,
25
25
-
threshold: 1
26
26
-
})
27
27
-
}
28
28
-
29
29
-
connectedCallback() {
30
30
-
super.connectedCallback()
31
31
-
document.addEventListener("readystatechange", e => {
32
32
-
if (event.target.readyState === "complete") {
33
33
-
const url = new URL(document.URL)
34
34
-
35
35
-
if (url.hash) {
36
36
-
document.querySelector(url.hash).scrollIntoView({ behavior: "instant"})
37
37
-
}
38
38
-
39
39
-
document.querySelectorAll("morkdeck-slide").forEach(e => this.observer.observe(e))
40
40
-
}
41
41
-
})
42
42
-
}
43
43
-
44
44
-
updateUrl(entries) {
45
45
-
for (const entry of entries) {
46
46
-
if (entry.isIntersecting) {
47
47
-
const url = new URL(document.URL)
48
48
-
const id = entry.target.getAttribute("id")
49
49
-
50
50
-
url.hash = `#${id}`
51
51
-
52
52
-
location.replace(url.toString())
53
53
-
54
54
-
break;
55
55
-
}
56
56
-
}
57
57
-
}
58
58
-
59
59
-
render () {
60
60
-
return html`<slot></slot>`
61
61
-
}
62
62
-
}
63
63
-
64
64
-
customElements.define("morkdeck-presentation", Presentation)
65
65
-
</script>
-44
templates/components/slide.eta
reviewed
···
1
1
-
<script type="module">
2
2
-
import { LitElement, html, css } from 'lit';
3
3
-
4
4
-
class Slide extends LitElement {
5
5
-
static styles = css`
6
6
-
:host {
7
7
-
display: block;
8
8
-
width: 100%;
9
9
-
height: 100%;
10
10
-
scroll-snap-align: center;
11
11
-
position: relative;
12
12
-
}
13
13
-
14
14
-
:host > section {
15
15
-
container: slide / inline-size;
16
16
-
box-sizing: border-box;
17
17
-
position: absolute;
18
18
-
inset: 0;
19
19
-
margin: auto;
20
20
-
aspect-ratio: 16 / 9;
21
21
-
max-width: 100%;
22
22
-
max-height: 100%;
23
23
-
24
24
-
display: flex;
25
25
-
flex-direction: column;
26
26
-
justify-content: center;
27
27
-
align-items: center;
28
28
-
29
29
-
padding: 6cqmin;
30
30
-
background: #1f1d2e;
31
31
-
}
32
32
-
`
33
33
-
34
34
-
render() {
35
35
-
return html`
36
36
-
<section>
37
37
-
<slot></slot>
38
38
-
</section>
39
39
-
`
40
40
-
}
41
41
-
}
42
42
-
43
43
-
customElements.define("morkdeck-slide", Slide)
44
44
-
</script>