Skip to content

Commit 2785a2e

Browse files
author
olaru
committed
New fronend contact page
1 parent 203452d commit 2785a2e

8 files changed

Lines changed: 735 additions & 71 deletions

File tree

‎public/css/contact.css‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎public/js/app.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Contact page: topic pills and the client-side "message sent" state.
2+
// The form is not wired to a backend yet, so submit only swaps the panels.
3+
(function () {
4+
var form = document.querySelector('[data-contact-form]');
5+
if (!form) {
6+
return;
7+
}
8+
9+
var topicInput = form.querySelector('[data-contact-topic]');
10+
var pills = form.querySelectorAll('[data-topic]');
11+
var sent = document.querySelector('[data-contact-sent]');
12+
var sentTopic = sent.querySelector('[data-contact-sent-topic]');
13+
var reset = sent.querySelector('[data-contact-reset]');
14+
15+
function currentPill() {
16+
return form.querySelector('[data-topic][aria-pressed="true"]');
17+
}
18+
19+
function selectTopic(id) {
20+
pills.forEach(function (pill) {
21+
pill.setAttribute('aria-pressed', String(pill.getAttribute('data-topic') === id));
22+
});
23+
topicInput.value = id;
24+
}
25+
26+
pills.forEach(function (pill) {
27+
pill.addEventListener('click', function () {
28+
selectTopic(pill.getAttribute('data-topic'));
29+
});
30+
});
31+
32+
form.addEventListener('submit', function (event) {
33+
event.preventDefault();
34+
var pill = currentPill();
35+
sentTopic.textContent = pill ? pill.textContent : '';
36+
form.hidden = true;
37+
sent.hidden = false;
38+
sent.querySelector('h2').focus({ preventScroll: true });
39+
});
40+
41+
reset.addEventListener('click', function () {
42+
form.reset();
43+
selectTopic(pills[0].getAttribute('data-topic'));
44+
sent.hidden = true;
45+
form.hidden = false;
46+
form.querySelector('input:not([type="hidden"])').focus();
47+
});
48+
})();

‎src/App/assets/js/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ import '../scss/index.scss'
22
import 'bootstrap/dist/js/bootstrap.bundle';
33

44
import './components/_main'
5+
import './components/_contact'

0 commit comments

Comments
 (0)