feat: redesign post form — hide GPS fields via :has(), teal CTA, status feedback

This commit is contained in:
2026-06-18 14:23:08 +02:00
parent c5d9c92968
commit c60f6726df
2 changed files with 115 additions and 33 deletions
+97 -21
View File
@@ -479,33 +479,109 @@ body {
.login-form .button.secondary { background: #f0f0f0; color: #333; text-decoration: none; line-height: 44px; padding: 0 1rem; } .login-form .button.secondary { background: #f0f0f0; color: #333; text-decoration: none; line-height: 44px; padding: 0 1rem; }
.login-form .rememberme { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); } .login-form .rememberme { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
/* ── Post form ──────────────────────────────────────────────────────────────── */ /* ── Post form ──────────────────────────────────────────────────────────────── */
.post-form-wrap h1 { font-size: 1.4rem; margin-bottom: 1.5rem; } .post-form-wrap h1 {
font-family: var(--font-display);
.form-actions-extra { font-size: var(--text-xl);
display: flex; font-weight: 400;
gap: 0.75rem; margin-bottom: var(--space-6);
margin-top: 1rem; color: var(--color-ink);
} }
.btn-extra { /* Hide GPS coordinate fields — filled by JS, not user-facing */
flex: 1; .post-form-wrap .form-field:has(input[name="data[lat]"]),
padding: 0.75rem 0.5rem; .post-form-wrap .form-field:has(input[name="data[lng]"]) { display: none !important; }
/* Grav form field inputs */
.post-form-wrap .form-field { margin-bottom: var(--space-5); }
.post-form-wrap .form-label label {
display: block;
font-size: var(--text-sm);
font-weight: 600;
color: var(--color-ink);
margin-bottom: var(--space-2);
}
.post-form-wrap input[type="text"],
.post-form-wrap input[type="datetime-local"],
.post-form-wrap textarea {
width: 100%;
font-family: var(--font-ui);
font-size: var(--text-base);
padding: 0.875rem 1rem;
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
background: var(--color-canvas);
color: var(--color-ink);
min-height: 44px; min-height: 44px;
background: #f0f0f0; transition: border-color 0.15s;
border: 1px solid #ccc; -webkit-appearance: none;
border-radius: 6px; }
font-size: 0.95rem;
.post-form-wrap input:focus,
.post-form-wrap textarea:focus {
outline: 2px solid var(--color-accent);
outline-offset: 1px;
border-color: var(--color-accent);
}
.post-form-wrap textarea { resize: vertical; min-height: 160px; line-height: var(--leading-normal); }
/* Submit button */
.post-form-wrap .form-actions input[type="submit"],
.post-form-wrap .form-actions .btn,
.post-form-wrap .form-actions button[type="submit"] {
display: block;
width: 100%;
padding: 1rem;
min-height: 52px;
background: var(--color-accent);
color: var(--color-accent-on);
border: none;
border-radius: var(--radius-md);
font-family: var(--font-ui);
font-size: var(--text-base);
font-weight: 600;
cursor: pointer; cursor: pointer;
text-align: center; transition: background 0.15s;
margin-top: var(--space-6);
} }
.btn-extra:hover { background: #e5e5e5; } .post-form-wrap .form-actions input[type="submit"]:hover,
.post-form-wrap .form-actions button[type="submit"]:hover { background: var(--color-accent-hover); }
.field-status { /* Location / weather action buttons */
font-size: 0.85rem; .form-action-row {
color: #555; display: flex;
margin-top: 0.4rem; gap: var(--space-3);
min-height: 1.2em; margin-top: var(--space-5);
} }
.btn-action {
flex: 1;
padding: 0.75rem var(--space-3);
min-height: 44px;
background: var(--color-canvas);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
font-family: var(--font-ui);
font-size: var(--text-sm);
font-weight: 500;
cursor: pointer;
color: var(--color-ink);
transition: background 0.15s, border-color 0.15s;
}
.btn-action:hover { background: var(--color-paper); border-color: var(--color-accent); }
/* Status feedback */
.form-status {
font-size: var(--text-sm);
color: var(--color-ink-muted);
margin-top: var(--space-2);
min-height: 1.4em;
}
.form-status--ok { color: var(--color-accent); }
.form-status--err { color: #B44A2A; }
@@ -2,15 +2,15 @@
{% block content %} {% block content %}
<div class="post-form-wrap"> <div class="post-form-wrap">
<h1>{{ page.title }}</h1> <h1>New Entry</h1>
{% include 'forms/form.html.twig' ignore missing %} {% include 'forms/form.html.twig' ignore missing %}
<div class="form-actions-extra"> <div class="form-action-row">
<button type="button" id="get-location" class="btn-extra">📍 Get Current Location</button> <button type="button" id="get-location" class="btn-action">📍 Get Location</button>
<button type="button" id="get-weather" class="btn-extra">🌤 Get Weather</button> <button type="button" id="get-weather" class="btn-action">🌤 Get Weather</button>
</div> </div>
<p id="location-status" class="field-status"></p> <p id="location-status" class="form-status"></p>
<p id="weather-status" class="field-status"></p> <p id="weather-status" class="form-status"></p>
</div> </div>
<script> <script>
@@ -29,9 +29,10 @@ function getField(name) {
document.getElementById('get-location').addEventListener('click', function() { document.getElementById('get-location').addEventListener('click', function() {
var status = document.getElementById('location-status'); var status = document.getElementById('location-status');
status.className = 'form-status';
status.textContent = 'Getting location…'; status.textContent = 'Getting location…';
if (!navigator.geolocation) { if (!navigator.geolocation) {
status.textContent = 'Geolocation not supported by your browser.'; status.textContent = 'Geolocation not supported.';
return; return;
} }
navigator.geolocation.getCurrentPosition(function(pos) { navigator.geolocation.getCurrentPosition(function(pos) {
@@ -41,20 +42,23 @@ document.getElementById('get-location').addEventListener('click', function() {
var lngField = getField('lng'); var lngField = getField('lng');
if (latField) latField.value = lat; if (latField) latField.value = lat;
if (lngField) lngField.value = lng; if (lngField) lngField.value = lng;
status.textContent = '📍 Location set: ' + lat + ', ' + lng; status.textContent = ' Location captured · ' + lat + ', ' + lng;
status.classList.add('form-status--ok');
}, function(err) { }, function(err) {
status.textContent = 'Could not get location: ' + err.message; status.textContent = 'Could not get location: ' + err.message;
status.classList.add('form-status--err');
}); });
}); });
document.getElementById('get-weather').addEventListener('click', function() { document.getElementById('get-weather').addEventListener('click', function() {
var status = document.getElementById('weather-status'); var status = document.getElementById('weather-status');
status.className = 'form-status';
var latField = getField('lat'); var latField = getField('lat');
var lngField = getField('lng'); var lngField = getField('lng');
var lat = latField ? latField.value.trim() : ''; var lat = latField ? latField.value.trim() : '';
var lng = lngField ? lngField.value.trim() : ''; var lng = lngField ? lngField.value.trim() : '';
if (!lat || !lng) { if (!lat || !lng) {
status.textContent = 'Enter or get coordinates first.'; status.textContent = 'Get location first, then fetch weather.';
return; return;
} }
status.textContent = 'Fetching weather…'; status.textContent = 'Fetching weather…';
@@ -71,10 +75,12 @@ document.getElementById('get-weather').addEventListener('click', function() {
var descField = getField('weather_desc'); var descField = getField('weather_desc');
if (tempField) tempField.value = temp; if (tempField) tempField.value = temp;
if (descField) descField.value = desc; if (descField) descField.value = desc;
status.textContent = '🌤 Weather set: ' + desc + ' · ' + temp + '°C'; status.textContent = ' Weather set · ' + desc + ' · ' + temp + '°C';
status.classList.add('form-status--ok');
}) })
.catch(function() { .catch(function() {
status.textContent = 'Could not fetch weather — enter manually if needed.'; status.textContent = 'Could not fetch weather — enter manually if needed.';
status.classList.add('form-status--err');
}); });
}); });
</script> </script>