Updating styling of RSVP page to work better with multiple members and in general be more legible

This commit is contained in:
collin 2025-07-13 16:12:07 +02:00
parent a6d9a99241
commit 7de0aa174d
3 changed files with 100 additions and 34 deletions

View file

@ -7,26 +7,31 @@
<h1 class="title fontXL textCenter backgroundLightGreen colorWhite">Collin and Lucy's Wedding</h1> <h1 class="title fontXL textCenter backgroundLightGreen colorWhite">Collin and Lucy's Wedding</h1>
<div class="contents fontM"> <div class="contents fontM">
<form id="rsvps" action="/api/rsvps" method="post"> <form id="rsvps" action="/api/rsvps" method="post">
<p> <div>
Attending: <span>Attending:</span>
<div class="fill-right">
<label for="attending-yes">Yes</label> <label for="attending-yes">Yes</label>
<input type="radio" id="attending-yes" name="attending" value="true" required/> <input type="radio" id="attending-yes" name="attending" value="true" required/>
<label for="attending-no">No</label> <label for="attending-no">No</label>
<input type="radio" id="attending-no" name="attending" value="false" required/> <input type="radio" id="attending-no" name="attending" value="false" required/>
</p> </div>
<p> </div>
<div>
<label for="party-size">Party Size:</label> <label for="party-size">Party Size:</label>
<select name="party-size" name="party-size" id="party-size"> <div class="fill-right">
<select name="party-size" name="party-size" id="party-size" >
<option value="1">1</option> <option value="1">1</option>
<option value="2">2</option> <option value="2">2</option>
<option value="3">3</option> <option value="3">3</option>
<option value="4">4</option> <option value="4">4</option>
<option value="5">5</option> <option value="5">5</option>
</select> </select>
</p> </div>
</div>
<div class="members"> <div class="members">
</div> </div>
<button>RSVP</button> <br style="margin-top:10px"/>
<button class="backgroundLightGreen colorWhite">RSVP</button>
</form> </form>
</div> </div>
<script src="/rsvp.js"></script> <script src="/rsvp.js"></script>

View file

@ -4,9 +4,7 @@ function createNewMember(id) {
const memberDiv = document.createElement("div"); const memberDiv = document.createElement("div");
memberDiv.classList.add("member"); memberDiv.classList.add("member");
const innerDiv = document.createElement("div"); const nameDiv = document.createElement("div");
const nameP = document.createElement("p");
const nameLabel = document.createElement("label"); const nameLabel = document.createElement("label");
nameLabel.htmlFor = `name-${id}`; nameLabel.htmlFor = `name-${id}`;
@ -17,11 +15,12 @@ function createNewMember(id) {
nameInput.id = `name-${id}`; nameInput.id = `name-${id}`;
nameInput.name = `name-${id}`; nameInput.name = `name-${id}`;
nameInput.required = true; nameInput.required = true;
nameInput.style = "width:0;flex:1;";
nameP.appendChild(nameLabel); nameDiv.appendChild(nameLabel);
nameP.appendChild(nameInput); nameDiv.appendChild(nameInput);
const childP = document.createElement("p"); const childDiv = document.createElement("div");
const childLabel = document.createElement("label"); const childLabel = document.createElement("label");
childLabel.htmlFor = `child-${id}`; childLabel.htmlFor = `child-${id}`;
@ -31,14 +30,17 @@ function createNewMember(id) {
childInput.type = "checkbox"; childInput.type = "checkbox";
childInput.id = `child-${id}`; childInput.id = `child-${id}`;
childInput.name = `child-${id}`; childInput.name = `child-${id}`;
childInput.style = 'font-size: 1rem';
childP.appendChild(childLabel); const childInputDiv = document.createElement("div");
childP.appendChild(childInput); childInputDiv.classList.add("fill-right");
innerDiv.appendChild(nameP); childInputDiv.appendChild(childInput);
innerDiv.appendChild(childP);
const dietP = document.createElement("p"); childDiv.appendChild(childLabel);
childDiv.appendChild(childInputDiv);
const dietDiv = document.createElement("p");
const dietLabel = document.createElement("label"); const dietLabel = document.createElement("label");
dietLabel.htmlFor = `diet-${id}`; dietLabel.htmlFor = `diet-${id}`;
@ -48,11 +50,16 @@ function createNewMember(id) {
dietInput.id = `diet-${id}`; dietInput.id = `diet-${id}`;
dietInput.name = `dietaryPreferences-${id}`; dietInput.name = `dietaryPreferences-${id}`;
dietP.appendChild(dietLabel); dietDiv.appendChild(dietLabel);
dietP.appendChild(dietInput); dietDiv.appendChild(dietInput);
memberDiv.appendChild(innerDiv); const separatorDiv = document.createElement("div");
memberDiv.appendChild(dietP); separatorDiv.classList.add("separator");
memberDiv.appendChild(separatorDiv);
memberDiv.appendChild(nameDiv);
memberDiv.appendChild(childDiv)
memberDiv.appendChild(dietDiv);
document.querySelector("div.members").appendChild(memberDiv); document.querySelector("div.members").appendChild(memberDiv);
} }

View file

@ -27,6 +27,44 @@ body {
box-sizing: border-box; box-sizing: border-box;
} }
select {
background-color: transparent;
border: none;
font-family: inherit;
font-size: inherit;
cursor: pointer;
line-height: inherit;
}
input {
font-family: inherit;
font-size: inherit;
background-color: transparent;
border: 1px solid grey;
}
input[type='radio'] {
margin: 5px;
}
input[type='radio'] + label {
margin-left: 10px;
}
textarea {
font-family: inherit;
font-size: inherit;
}
button {
font-family: inherit;
font-size: inherit;
color: inherit;
background-color: inherit;
border: none;
cursor: pointer;
}
/* #region reusable */ /* #region reusable */
.hidden { .hidden {
visibility: hidden; visibility: hidden;
@ -166,12 +204,22 @@ form#rsvps {
flex-direction: column; flex-direction: column;
} }
form#rsvps div#members { form#rsvps div {
display: flex;
flex-direction: row;
}
form#rsvps *.fill-right {
flex: 1;
justify-content: flex-end;
}
form#rsvps div.members {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
form#rsvps div.members { form#rsvps div.members div.member {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
@ -181,4 +229,10 @@ form#rsvps div.members div.member div {
flex-direction: row; flex-direction: row;
} }
form#rsvps div.members div.member div.separator {
margin-top: 10px;
margin-bottom: 10px;
border-top: 1px solid #8cad87;
}
/* #endregion */ /* #endregion */