@@ -147,69 +147,67 @@ const { class: className } = Astro.props as { class?: string };
147147
148148 // Color palette that cycles through (matches @utils/authorUtils.ts)
149149 const bgColors = ['#5F735E', '#BF9595', '#D1CDC0'];
150- const getBgColor = (index: number): string => {
151- return bgColors[index % bgColors.length];
152- };
150+ const getBgColor = (index: number): string => bgColors[index % bgColors.length];
153151 const bgColor = member.index !== undefined ? getBgColor(member.index) : bgColors[0];
154152
155- // Build avatar HTML
156- const avatarHTML = data.avatar
157- ? `<div class="profile-modal--avatar" style="background-color: ${bgColor}">
158- <img src="${data.avatar.src}" alt="${data.name}" />
159- </div >`
160- : '';
161-
162- // Build meta grid items
163- const metaItems = [];
164-
165- if (data.bio) {
166- metaItems .push (`
167- <div class="profile-modal--meta-item">
168- <label>About</label>
169- <p>${data .bio }</p>
170- </div>
171- ` );
153+ this.contentContainer.textContent = '';
154+
155+ // Row 1: avatar + info
156+ const rowFirst = document.createElement('div');
157+ rowFirst.className = 'profile-modal--row-first';
158+
159+ if (data.avatar) {
160+ const avatarDiv = document.createElement('div');
161+ avatarDiv.className = 'profile-modal--avatar';
162+ avatarDiv.style.backgroundColor = bgColor;
163+ const img = document.createElement('img');
164+ img.src = data.avatar.src;
165+ img.alt = data.name;
166+ avatarDiv.appendChild(img);
167+ rowFirst.appendChild(avatarDiv);
172168 }
173- if (data.tick) {
174- metaItems .push (`
175- <div class="profile-modal--meta-item">
176- <label>What makes me tick</label>
177- <p>${data .tick }</p>
178- </div>
179- ` );
180- }
181- if (data.surprising) {
182- metaItems .push (`
183- <div class="profile-modal--meta-item">
184- <label>Something surprising</label>
185- <p>${data .surprising }</p>
186- </div>
187- ` );
169+
170+ const infoDiv = document.createElement('div');
171+ infoDiv.className = 'profile-modal--info';
172+ const infoHeader = document.createElement('div');
173+ infoHeader.className = 'profile-modal--info-header';
174+ const h2 = document.createElement('h2');
175+ h2.textContent = data.name;
176+ infoHeader.appendChild(h2);
177+ if (data.title) {
178+ const titleP = document.createElement('p');
179+ titleP.textContent = data.title;
180+ infoHeader.appendChild(titleP);
188181 }
189- if (data.weekends) {
190- metaItems .push (`
191- <div class="profile-modal--meta-item">
192- <label>On weekends I'm</label>
193- <p>${data .weekends }</p>
194- </div>
195- ` );
182+ infoDiv.appendChild(infoHeader);
183+ rowFirst.appendChild(infoDiv);
184+ this.contentContainer.appendChild(rowFirst);
185+
186+ // Row 2: meta items
187+ const metaFields: { label: string; value: string | undefined }[] = [
188+ { label: 'About', value: data.bio },
189+ { label: 'What makes me tick', value: data.tick },
190+ { label: 'Something surprising', value: data.surprising },
191+ { label: "On weekends I'm", value: data.weekends },
192+ ];
193+
194+ const presentFields = metaFields.filter((f) => f.value);
195+ if (presentFields.length > 0) {
196+ const rowSecond = document.createElement('div');
197+ rowSecond.className = 'profile-modal--row-second';
198+ for (const field of presentFields) {
199+ const item = document.createElement('div');
200+ item.className = 'profile-modal--meta-item';
201+ const label = document.createElement('label');
202+ label.textContent = field.label;
203+ const p = document.createElement('p');
204+ p.textContent = field.value!;
205+ item.appendChild(label);
206+ item.appendChild(p);
207+ rowSecond.appendChild(item);
208+ }
209+ this.contentContainer.appendChild(rowSecond);
196210 }
197-
198- // Populate the content
199- this.contentContainer.innerHTML = `
200- <div class =" profile-modal--row-first" >
201- ${ avatarHTML }
202- <div class =" profile-modal--info" >
203- <div class =" profile-modal--info-header" >
204- <h2 >${ data .name } </h2 >
205- ${ data .title ? ` <p>${data .title }</p> ` : ' ' }
206- </div >
207-
208- </div >
209- </div >
210-
211- ${ metaItems .length > 0 ? ` <div class="profile-modal--row-second">${metaItems .join (' ' )}</div> ` : ' ' }
212- `;
213211 }
214212 }
215213
0 commit comments