2025-05-14 19:00:13 +02:00
|
|
|
---
|
|
|
|
|
title: Form
|
|
|
|
|
tags:
|
|
|
|
|
- ui
|
|
|
|
|
---
|
2025-06-19 16:21:09 +02:00
|
|
|
{% set pageClass = "html_ui" %}
|
2025-06-21 13:39:36 +02:00
|
|
|
{% set bodyClass = "body_ui" %}
|
2025-05-15 20:00:51 +02:00
|
|
|
|
2025-05-14 19:00:13 +02:00
|
|
|
{% extends "demo/_app.njk" %}
|
|
|
|
|
|
|
|
|
|
{% block title %}{{ title }}
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{% block links %}
|
|
|
|
|
<link href="{{ pageBase }}css/ui.css" media="all" rel="stylesheet"/>
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{% block head %}
|
|
|
|
|
{{ super() }}
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{% block body %}
|
2025-06-19 16:45:20 +02:00
|
|
|
<header class="io">
|
2025-05-14 19:00:13 +02:00
|
|
|
<h1>Formulare</h1>
|
|
|
|
|
<button data-action="add">Hinzufügen</button>
|
2025-05-15 20:00:51 +02:00
|
|
|
<button data-action="change">Ändern</button>
|
|
|
|
|
<hr>
|
2025-06-19 16:45:20 +02:00
|
|
|
</header>
|
2025-05-15 20:00:51 +02:00
|
|
|
<form id="form" action="">
|
|
|
|
|
<div id="grid">
|
|
|
|
|
<div>a</div>
|
|
|
|
|
<div>b</div>
|
|
|
|
|
<div>c</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2025-05-14 19:00:13 +02:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{%- block script %}
|
|
|
|
|
{{ super() }}
|
|
|
|
|
<script>
|
|
|
|
|
const add = document.querySelector('[data-action=add]');
|
2025-05-15 20:00:51 +02:00
|
|
|
const change = document.querySelector('[data-action=change]');
|
|
|
|
|
const grid = document.getElementById('grid');
|
2025-05-14 19:00:13 +02:00
|
|
|
|
|
|
|
|
add.addEventListener('click', (e) => {
|
|
|
|
|
const item = document.createElement('div');
|
|
|
|
|
|
|
|
|
|
item.style.backgroundColor = '#f0f';
|
|
|
|
|
item.textContent = 'c'
|
2025-05-15 20:00:51 +02:00
|
|
|
|
2025-05-14 19:00:13 +02:00
|
|
|
grid.appendChild(item);
|
|
|
|
|
});
|
2025-05-15 20:00:51 +02:00
|
|
|
|
|
|
|
|
change.addEventListener('click', (e) => {
|
|
|
|
|
changeLayout(grid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function changeLayout(grid) {
|
|
|
|
|
const currentTemplate = grid.style.gridTemplateColumns;
|
|
|
|
|
|
|
|
|
|
if (currentTemplate === 'repeat(4, 1fr)') {
|
|
|
|
|
grid.style.gridTemplateColumns = 'repeat(2, 1fr)';
|
|
|
|
|
} else {
|
|
|
|
|
grid.style.gridTemplateColumns = 'repeat(4, 1fr)';
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-14 19:00:13 +02:00
|
|
|
</script>
|
|
|
|
|
{% endblock %}
|