Add intro
This commit is contained in:
parent
b71e899750
commit
06ab639c42
3 changed files with 37 additions and 16 deletions
|
|
@ -1,3 +1,13 @@
|
||||||
|
export const modal = content => {
|
||||||
|
const wrapper = document.createElement('a')
|
||||||
|
wrapper.href = '/'
|
||||||
|
wrapper.className = 'fullview'
|
||||||
|
const fullview = document.createElement('div')
|
||||||
|
fullview.innerHTML = content
|
||||||
|
wrapper.appendChild(fullview)
|
||||||
|
return wrapper
|
||||||
|
}
|
||||||
|
|
||||||
export class Display {
|
export class Display {
|
||||||
constructor(baseUrl, dispatch, target) {
|
constructor(baseUrl, dispatch, target) {
|
||||||
this.baseUrl = baseUrl
|
this.baseUrl = baseUrl
|
||||||
|
|
@ -9,13 +19,6 @@ export class Display {
|
||||||
}
|
}
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
target.addEventListener('click', e => {
|
|
||||||
let target = findA(e.target)
|
|
||||||
if (!target) return
|
|
||||||
window.history.pushState(null, "", target.href)
|
|
||||||
dispatch(target.getAttribute('href'))
|
|
||||||
e.preventDefault()
|
|
||||||
})
|
|
||||||
target.addEventListener('dragstart', e => {
|
target.addEventListener('dragstart', e => {
|
||||||
let target = findA(e.target)
|
let target = findA(e.target)
|
||||||
if (!target || !target.draggable) return
|
if (!target || !target.draggable) return
|
||||||
|
|
@ -135,16 +138,12 @@ export class Display {
|
||||||
|
|
||||||
target.appendChild(field)
|
target.appendChild(field)
|
||||||
if (state.show !== null) {
|
if (state.show !== null) {
|
||||||
const wrapper = document.createElement('a')
|
|
||||||
wrapper.href = '/'
|
|
||||||
wrapper.className = 'fullview'
|
|
||||||
const fullview = document.createElement('div')
|
|
||||||
const data = state.items[state.show]
|
const data = state.items[state.show]
|
||||||
const name = data.name
|
const name = data.name
|
||||||
const desc = data.desc
|
const desc = data.desc
|
||||||
const img = '/img/' + data.img
|
const img = '/img/' + data.img
|
||||||
const text = (data.text || []).map(v => '<p>' + v + '</p>').join('')
|
const text = (data.text || []).map(v => '<p>' + v + '</p>').join('')
|
||||||
fullview.innerHTML = `
|
const wrapper = modal(`
|
||||||
<header>
|
<header>
|
||||||
<img src=${img} />
|
<img src=${img} />
|
||||||
<h1>${name}</h1>
|
<h1>${name}</h1>
|
||||||
|
|
@ -152,8 +151,7 @@ export class Display {
|
||||||
</header>
|
</header>
|
||||||
<div class=fulltext>${text}
|
<div class=fulltext>${text}
|
||||||
<blockquote>${data.quote || ''}</blockquote></div>
|
<blockquote>${data.quote || ''}</blockquote></div>
|
||||||
`
|
`)
|
||||||
wrapper.appendChild(fullview)
|
|
||||||
target.appendChild(wrapper)
|
target.appendChild(wrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
20
src/index.js
20
src/index.js
|
|
@ -1,4 +1,5 @@
|
||||||
import {Display} from './display.js'
|
import {modal, Display} from './display.js'
|
||||||
|
import intro from './intro.js'
|
||||||
|
|
||||||
const target = document.createElement('div')
|
const target = document.createElement('div')
|
||||||
|
|
||||||
|
|
@ -50,8 +51,23 @@ const dispatch = target => {
|
||||||
window.onpopstate = e => {
|
window.onpopstate = e => {
|
||||||
dispatch(document.location.search)
|
dispatch(document.location.search)
|
||||||
}
|
}
|
||||||
|
const findA = target => {
|
||||||
|
while (target.nodeName !== 'A') {
|
||||||
|
target = target.parentNode
|
||||||
|
if (!target) return
|
||||||
|
}
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
document.body.addEventListener('click', e => {
|
||||||
|
let target = findA(e.target)
|
||||||
|
if (!target) return
|
||||||
|
window.history.pushState(null, "", target.href)
|
||||||
|
dispatch(target.getAttribute('href'))
|
||||||
|
e.preventDefault()
|
||||||
|
})
|
||||||
display = new Display('', dispatch, target)
|
display = new Display('', dispatch, target)
|
||||||
|
|
||||||
dispatch(document.location.search)
|
if (document.location.search) dispatch(document.location.search)
|
||||||
|
else document.body.appendChild(modal(intro))
|
||||||
document.body.appendChild(target)
|
document.body.appendChild(target)
|
||||||
|
|
||||||
|
|
|
||||||
7
src/intro.js
Normal file
7
src/intro.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export default `<h1>Memory des Prekariats.</h1>
|
||||||
|
<p>
|
||||||
|
Unsichere Arbeits- und Lebensverhältnisse haben viele Gesichter. In diesem Spiel ist es eure Aufgabe, ihr geteiltes Leid aufzudecken. Klickt dafür auf die Symbole und lernt die historischen und heutigen Figuren des Prekariats kennen. Durch das Zusammenziehen der Kreise entdeckt ihr, was die Vergangenheit mit der Gegenwart verknüpft.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Ein Netzwerk der Prekären entsteht.
|
||||||
|
</p>`
|
||||||
Loading…
Add table
Add a link
Reference in a new issue