-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.ts
54 lines (47 loc) · 1.26 KB
/
index.ts
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
import xs, { Stream } from 'xstream';
import { run } from '@cycle/run';
import { button, div, span, makeDOMDriver, DOMSource, VNode } from '@cycle/dom';
import isolate from '@cycle/isolate';
import { modalify, ModalAction } from '../../../src/modalify';
interface Sources {
DOM: DOMSource;
}
interface Sinks {
DOM?: Stream<VNode>;
modal?: Stream<ModalAction>;
}
function main({ DOM }: Sources): Sinks {
return {
DOM: xs.of(button('.button', ['open modal'])),
modal: DOM.select('.button')
.events('click')
.mapTo({
type: 'open',
component: isolate(modal)
} as ModalAction)
};
}
function modal({ DOM }: Sources): Sinks {
return {
DOM: xs.of(
div('.div', [
span('.span', ['This is a modal. Yeah? :)']),
button('.button', ['close'])
])
),
modal: DOM.select('.button')
.events('click')
.mapTo({ type: 'close' } as ModalAction)
};
}
const modalifiedMain = modalify(main, {
name: 'modal',
DOMDriverKey: 'DOM',
center: true,
modalContainerClass: null,
background: 'rgba(0,0,0,0.8)',
zIndex: 500
});
run(modalifiedMain, {
DOM: makeDOMDriver('#app')
});