This repository has been archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
slide-deck.js
124 lines (114 loc) · 3.54 KB
/
slide-deck.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import React, { Component } from 'react';
import 'prismjs';
import loadLanguages from 'prismjs/components/index.js';
import 'prismjs/plugins/keep-markup/prism-keep-markup.js';
import 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js';
import 'prismjs/plugins/unescaped-markup/prism-unescaped-markup.js';
import 'reveal.js/css/reveal.css';
import '@objectpartners/revealjs-theme';
import 'prismjs/themes/prism-okaidia.css';
import 'prismjs/plugins/unescaped-markup/prism-unescaped-markup.css';
import './slide-deck.css';
export class SlideDeck extends Component {
componentDidMount() {
loadLanguages(['groovy', 'json', 'jsx', 'flow', 'typescript']); // why groovy? Exactly.
require.ensure(
[
'reveal.js',
'reveal.js/lib/js/classList.js',
'reveal.js/lib/js/head.min.js',
'reveal.js/lib/js/html5shiv.js'
],
() => {
const Reveal = require('reveal.js');
require('reveal.js/lib/js/classList.js');
require('reveal.js/lib/js/head.min.js');
require('reveal.js/lib/js/html5shiv.js');
window.Reveal = Reveal;
Reveal.initialize({
history: true,
margin: 0.1,
dependencies: [
{
async: true,
src: require('reveal.js/plugin/zoom-js/zoom.js')
},
{
async: true,
src: require('reveal.js/plugin/markdown/marked.js')
},
{
async: true,
src: require('reveal.js/plugin/notes/notes.js')
}
]
});
}
);
}
getSectionProps(html) {
const section = html.match(/<section[^>]+/);
if (!section) {
return {};
}
const props = section
.pop()
.replace(/<section\s/, '')
.split(/([\w-]+)="([^"]+)"/)
.filter(part => part && part.length > 0);
return props.reduce((merged, part, index) => {
if (part % 1 === 0) {
merged[part] = '';
} else if (props[index - 1]) {
merged[props[index - 1]] = part;
}
return merged;
}, {});
}
render() {
const { slides } = this.props;
const { PRESENTATION_DATE: date } = process.env;
return (
<div className="reveal">
<div className="slides">
<section data-state="title">
<h1>Starter Kit</h1>
<h2>{date}</h2>
</section>
{slides.map((deck, deckIndex) => {
return (
<section key={deckIndex}>
{deck.map((html, slideIndex) => {
const key = `${deckIndex}-${slideIndex}`;
if (html.default) {
const Slide = html.default;
return (
<section key={key}>
<Slide />
</section>
);
}
const sectionProps = this.getSectionProps(html);
return (
<section
key={key}
{...sectionProps}
dangerouslySetInnerHTML={{ __html: html }} // #yolo
/>
);
})}
</section>
);
})}
<section data-background="https://media.giphy.com/media/eTVG7eVNnud8Y/giphy.gif">
<h2>Questions</h2>
</section>
<section data-state="title">
<h1>Thank you!</h1>
<h3>Follow us! @objectpartners</h3>
</section>
</div>
</div>
);
}
}