new page structure

This commit is contained in:
j 2022-04-26 15:25:34 +01:00
parent 9874924d27
commit 7f00dcffc4
3 changed files with 183 additions and 41 deletions

View file

@ -11,7 +11,6 @@ def events(request, slug=''):
context = {} context = {}
context['settings'] = settings context['settings'] = settings
context['events'] = Event.objects.all().order_by('position') context['events'] = Event.objects.all().order_by('position')
context['postscript'], c = Page.objects.get_or_create(slug='postscript')
context['intro'], c = Page.objects.get_or_create(slug='intro') context['intro'], c = Page.objects.get_or_create(slug='intro')
return render(request, 'events.html', context) return render(request, 'events.html', context)
@ -19,8 +18,9 @@ def events(request, slug=''):
def timeline(request): def timeline(request):
context = {} context = {}
context['settings'] = settings context['settings'] = settings
context['postscript'], c = Page.objects.get_or_create(slug='postscript') context['title'], c = Page.objects.get_or_create(slug='title')
context['intro'], c = Page.objects.get_or_create(slug='intro') context['about'], c = Page.objects.get_or_create(slug='about')
context['imprint'], c = Page.objects.get_or_create(slug='imprint')
timeline = {'events': []} timeline = {'events': []}

View file

@ -6,12 +6,10 @@
margin: auto; margin: auto;
} }
p { p {
} }
#intro { #about, #imprint {
max-width: 800px; max-width: 800px;
margin: auto; margin: auto;
line-height: 1.33em; line-height: 1.33em;
@ -27,10 +25,6 @@ p {
margin-top: 64px; margin-top: 64px;
} }
img {
width: 100%;
margin: auto;
}
.row { .row {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -40,16 +34,24 @@ p {
} }
} }
} }
#about {
img {
width: 100%;
margin: auto;
}
}
#contact { #contact {
.content { .content {
padding-top: 5%; padding-top: 64px;
width: 640px; width: 640px;
max-width: calc(100% - 16px);
height: 480px; height: 480px;
margin: auto; margin: auto;
} }
input, textarea { input, textarea {
width: 600px; width: 600px;
max-width: 100%;
border-radius: 4px; border-radius: 4px;
border: 1px solid black; border: 1px solid black;
} }
@ -57,7 +59,7 @@ p {
background: none; background: none;
} }
input[type="submit"]:hover { input[type="submit"]:hover {
background: red; font-weight: bold;
cursor: pointer; cursor: pointer;
} }
textarea { textarea {
@ -124,3 +126,91 @@ p {
flex-direction: column-reverse; flex-direction: column-reverse;
} }
} }
.page {
display: none;
}
.page.active {
display: inherit;
}
#title {
background-image: url("/media/image/birds_medium.jpg");
background-size: cover;
&.active {
display: flex;
}
.content {
margin: auto;
padding-bottom: 128px;
.start {
font-size: 36px;
display: block;
width: 100%;
text-align: center;
}
}
.credit {
position: fixed;
left: 5px;
bottom: 5px;
color: #000;
}
}
@media screen and (max-width: 799px) {
#title {
display: block;
.content {
padding-top: 64px;
}
}
}
#contact {
background-image: url("/media/image/birds_medium.jpg");
background-size: cover;
input, textarea {
background: transparent;
color: #fff;
}
}
#menu {
position: fixed;
right: 0;
top: 0;
z-index: 101;
}
#menu-overlay {
z-index: 100;
position: fixed;
display: none;
bottom: 0;
left: 0;
right: 0;
top: 0;
background: #fff;
background-image: url("/media/image/birds_medium.jpg");
background-size: cover;
&.active {
display: flex;
}
ul {
margin: auto;
margin-right: 16px;
margin-top: 64px;
text-align: right;
list-style-type: none;
padding: 0;
li {
line-height: 1.5em;
font-size: 36px;
a, a:visited, a:active, a:hover {
}
}
}
}

View file

@ -17,6 +17,13 @@
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
} }
#timeline, #tl {
height: 100%;
width:100%;
}
#tl {
display: block;
}
.tl-timeline { .tl-timeline {
} }
@ -27,24 +34,31 @@
.tl-timeline h1, .tl-timeline h2, .tl-timeline h3, .tl-timeline h4, .tl-timeline h5, .tl-timeline h6 { .tl-timeline h1, .tl-timeline h2, .tl-timeline h3, .tl-timeline h4, .tl-timeline h5, .tl-timeline h6 {
text-transform: initial !important; text-transform: initial !important;
} }
.active {
display: block
}
#intro, #contact {
display: none;
}
.tl-timeline .tl-timegroup-message { .tl-timeline .tl-timegroup-message {
color: #000 !important; color: #000 !important;
} }
</style> </style>
</head> </head>
<body> <body>
<div id="intro"> <div id="title" class="page tl-timeline">
{{ intro.body | safe }} <div class="content">
{{ title.body | safe }}
</div> </div>
<div id="timeline"></div> </div>
<div id="contact"> <div id="about" class="page tl-timeline">
<br>
<br>
{{ about.body | safe }}
</div>
<div id="timeline" class="page">
<div id="tl"></div>
</div>
<div id="imprint" class="page tl-timeline">
<br>
<br>
{{ imprint.body | safe }}
</div>
<div id="contact" class="page tl-timeline">
<div class="content"> <div class="content">
<form class="contact-form" action="/disabled" method="post"> <form class="contact-form" action="/disabled" method="post">
<input type="text" placeholder="Your name" name="name" required><br> <input type="text" placeholder="Your name" name="name" required><br>
@ -55,6 +69,21 @@
</form> </form>
</div> </div>
</div> </div>
<div id="menu-overlay" class="tl-timeline">
<ul>
<li><a href="#start" target="_self">timeline</a></li>
<li><a href="#about" target="_self">about</a></li>
<li><a href="#contact" target="_self">contact</a></li>
<li><a href="#imprint" target="_self">imprint</a></li>
</ul>
</div>
<div id="menu">
<svg viewBox="0 0 100 100" width="64" height="64">
<rect y="20" width="80" height="10"></rect>
<rect y="40" width="80" height="10"></rect>
<rect y="60" width="80" height="10"></rect>
</svg>
</div>
<script src="{% static 'timeline/js/timeline.js' %}"></script> <script src="{% static 'timeline/js/timeline.js' %}"></script>
<script> <script>
function submitContact(event) { function submitContact(event) {
@ -91,39 +120,62 @@
var timeline var timeline
function load_timeline() { function load_timeline() {
timeline = new TL.Timeline('timeline', data, { timeline = new TL.Timeline('tl', data, {
hash_bookmark: true, hash_bookmark: true,
debug: false, debug: false,
timenav_height: 100, timenav_height: 100,
}); });
} }
document.querySelector('#intro a[href="#title"]').addEventListener('click', event => { function openPage(qs) {
document.querySelector('#intro').style.display = 'none' var active = document.querySelector(qs)
document.querySelector('#contact').style.display = 'none' document.querySelectorAll('.page').forEach(page => {
document.querySelector('#timeline').style.display = 'block' if (page != active) {
if (page.classList.contains('active')) {
page.classList.remove('active')
active.classList.add('active')
}
}
})
active.classList.add('active')
}
document.querySelector('#about a[href="#title"]').addEventListener('click', event => {
openPage('#timeline')
load_timeline() load_timeline()
}) })
if (document.location.hash.slice(1).length) {
load_timeline()
}
function hashchange(event) { function hashchange(event) {
console.log('hc', document.location.hash.slice(1).length, document.location.hash.slice(1)) console.log('hc', document.location.hash.slice(1).length, document.location.hash.slice(1))
if (document.location.hash.slice(1) == 'contact') { var page
document.querySelector('#intro').style.display = 'none' if (document.location.hash.slice(1).length) {
document.querySelector('#contact').style.display = 'block' page = document.querySelector(document.location.hash + '.page')
document.querySelector('#timeline').style.display = 'none' }
if (page) {
openPage(document.location.hash)
} else if (document.location.hash.slice(1).length) { } else if (document.location.hash.slice(1).length) {
document.querySelector('#intro').style.display = 'none' openPage('#timeline')
document.querySelector('#contact').style.display = 'none' if (!timeline) {
document.querySelector('#timeline').style.display = 'block' load_timeline()
}
} else { } else {
document.querySelector('#intro').style.display = 'block' openPage("#title")
document.querySelector('#contact').style.display = 'none'
document.querySelector('#timeline').style.display = 'none'
} }
} }
window.addEventListener('hashchange', hashchange) window.addEventListener('hashchange', hashchange)
hashchange() hashchange()
document.querySelector('#menu').addEventListener('click', event => {
var overlay = document.querySelector('#menu-overlay')
if (overlay.classList.contains('active')) {
overlay.classList.remove('active')
} else {
overlay.classList.add('active')
}
})
document.querySelectorAll('#menu-overlay a').forEach(a => {
a.addEventListener('click', event => {
var overlay = document.querySelector('#menu-overlay')
overlay.classList.remove('active')
})
})
</script> </script>
</body> </body>
</html> </html>