Skip to content

Commit f7f3d1b

Browse files
committed
Replace the "team" word by "participant"
1 parent 9a5c5fe commit f7f3d1b

File tree

4 files changed

+67
-69
lines changed

4 files changed

+67
-69
lines changed

src/dom.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ export function createMatchLabel(label: string, status: string): HTMLElement {
8484
}
8585

8686
/**
87-
* Creates a container which contains the teams of a match.
87+
* Creates a container which contains the opponents of a match.
8888
*/
89-
export function createTeamsContainer(): HTMLElement {
90-
const teams = document.createElement('div');
91-
teams.classList.add('teams');
92-
return teams;
89+
export function createOpponentsContainer(): HTMLElement {
90+
const opponents = document.createElement('div');
91+
opponents.classList.add('opponents');
92+
return opponents;
9393
}
9494

9595
/**
96-
* Creates a container which contains a team.
96+
* Creates a container which contains a participant.
9797
*/
98-
export function createTeamContainer(): HTMLElement {
98+
export function createParticipantContainer(): HTMLElement {
9999
const teamDOM = document.createElement('div');
100-
teamDOM.classList.add('team');
100+
teamDOM.classList.add('participant');
101101
return teamDOM;
102102
}
103103

104104
/**
105-
* Creates a container which contains the name of a team.
105+
* Creates a container which contains the name of a participant.
106106
*/
107107
export function createNameContainer(): HTMLElement {
108108
const nameDOM = document.createElement('div');
@@ -111,7 +111,7 @@ export function createNameContainer(): HTMLElement {
111111
}
112112

113113
/**
114-
* Creates a container which contains the result of a match for a team.
114+
* Creates a container which contains the result of a match for a participant.
115115
*/
116116
export function createResultContainer(): HTMLElement {
117117
const resultDOM = document.createElement('div');
@@ -176,45 +176,45 @@ export function setupHint(nameContainer: HTMLElement, hint: string): void {
176176
}
177177

178178
/**
179-
* Sets a win for a team.
179+
* Sets a win for a participant.
180180
*
181-
* @param teamContainer The team container.
181+
* @param participantContainer The participant container.
182182
* @param resultContainer The result container.
183-
* @param team The team result.
183+
* @param participant The participant result.
184184
*/
185-
export function setupWin(teamContainer: HTMLElement, resultContainer: HTMLElement, team: ParticipantResult): void {
186-
if (team.result && team.result === 'win') {
187-
teamContainer.classList.add('win');
185+
export function setupWin(participantContainer: HTMLElement, resultContainer: HTMLElement, participant: ParticipantResult): void {
186+
if (participant.result && participant.result === 'win') {
187+
participantContainer.classList.add('win');
188188

189-
if (team.score === undefined)
189+
if (participant.score === undefined)
190190
resultContainer.innerText = 'W';
191191
}
192192
}
193193

194194
/**
195-
* Sets a loss for a team.
195+
* Sets a loss for a participant.
196196
*
197-
* @param teamContainer The team container.
197+
* @param participantContainer The participant container.
198198
* @param resultContainer The result container.
199-
* @param team The team result.
199+
* @param participant The participant result.
200200
*/
201-
export function setupLoss(teamContainer: HTMLElement, resultContainer: HTMLElement, team: ParticipantResult): void {
202-
if (team.result && team.result === 'loss' || team.forfeit) {
203-
teamContainer.classList.add('loss');
201+
export function setupLoss(participantContainer: HTMLElement, resultContainer: HTMLElement, participant: ParticipantResult): void {
202+
if (participant.result && participant.result === 'loss' || participant.forfeit) {
203+
participantContainer.classList.add('loss');
204204

205-
if (team.forfeit)
205+
if (participant.forfeit)
206206
resultContainer.innerText = 'F'; // Forfeit.
207-
else if (team.score === undefined)
207+
else if (participant.score === undefined)
208208
resultContainer.innerText = 'L';
209209
}
210210
}
211211

212212
/**
213-
* Adds the team origin to a name
213+
* Adds the participant origin to a name
214214
*
215215
* @param nameContainer The name container.
216216
* @param text The text to set (origin).
217-
* @param placement The placement of the team origin.
217+
* @param placement The placement of the participant origin.
218218
*/
219219
export function addTeamOrigin(nameContainer: HTMLElement, text: string, placement: Placement): void {
220220
const span = document.createElement('span');
@@ -267,7 +267,7 @@ export function getFinalConnection(finalType: FinalType, roundNumber: number, ma
267267
/**
268268
* Sets the connection a match containers.
269269
*
270-
* @param teamsContainer The teams container.
270+
* @param teamsContainer The opponents container.
271271
* @param matchContainer The match container.
272272
* @param connection The connection to set.
273273
*/

src/main.ts

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class BracketsViewer {
208208
const data: number | string = item[prop];
209209

210210
if (prop === 'id') {
211-
const participant = this.participants.find(team => team.id === data);
211+
const participant = this.participants.find(participant => participant.id === data);
212212

213213
if (participant !== undefined) {
214214
const cell = dom.createCell(participant.name);
@@ -269,108 +269,106 @@ export class BracketsViewer {
269269
inLowerBracket = inLowerBracket || false;
270270

271271
const match = dom.createMatchContainer();
272-
const teams = dom.createTeamsContainer();
272+
const opponents = dom.createOpponentsContainer();
273273

274274
const team1 = this.createTeam(results.opponent1, hint, inLowerBracket);
275275
const team2 = this.createTeam(results.opponent2, hint, inLowerBracket);
276276

277277
if (label)
278-
teams.append(dom.createMatchLabel(label, lang.getMatchStatus(results.status)));
278+
opponents.append(dom.createMatchLabel(label, lang.getMatchStatus(results.status)));
279279

280-
teams.append(team1, team2);
281-
match.append(teams);
280+
opponents.append(team1, team2);
281+
match.append(opponents);
282282

283283
if (!connection)
284284
return match;
285285

286-
dom.setupConnection(teams, match, connection);
286+
dom.setupConnection(opponents, match, connection);
287287

288288
return match;
289289
}
290290

291-
// TODO: get rid of the word "team"
292-
293291
/**
294-
* Creates a team for a match.
292+
* Creates a participant for a match.
295293
*
296-
* @param team Information about the team.
294+
* @param participant Information about the participant.
297295
* @param hint Hint of the match.
298296
* @param inLowerBracket Whether the match is in lower bracket.
299297
*/
300-
private createTeam(team: ParticipantResult | null, hint: MatchHint, inLowerBracket: boolean): HTMLElement {
301-
const teamContainer = dom.createTeamContainer();
298+
private createTeam(participant: ParticipantResult | null, hint: MatchHint, inLowerBracket: boolean): HTMLElement {
299+
const participantContainer = dom.createParticipantContainer();
302300
const nameContainer = dom.createNameContainer();
303301
const resultContainer = dom.createResultContainer();
304302

305-
if (team === null)
303+
if (participant === null)
306304
nameContainer.innerText = 'BYE';
307305
else
308-
this.renderParticipant(teamContainer, nameContainer, resultContainer, team, hint, inLowerBracket);
306+
this.renderParticipant(participantContainer, nameContainer, resultContainer, participant, hint, inLowerBracket);
309307

310-
teamContainer.append(nameContainer, resultContainer);
308+
participantContainer.append(nameContainer, resultContainer);
311309

312-
if (team && team.id !== null)
313-
this.setupMouseHover(team.id, teamContainer);
310+
if (participant && participant.id !== null)
311+
this.setupMouseHover(participant.id, participantContainer);
314312

315-
return teamContainer;
313+
return participantContainer;
316314
}
317315

318316
/**
319317
* Renders a participant.
320318
*
321-
* @param teamContainer The team container.
319+
* @param participantContainer The participant container.
322320
* @param nameContainer The name container.
323321
* @param resultContainer The result container.
324-
* @param team The participant result.
322+
* @param participant The participant result.
325323
* @param hint Hint for the participant.
326324
* @param inLowerBracket Whether the match is in lower bracket.
327325
*/
328-
private renderParticipant(teamContainer: HTMLElement, nameContainer: HTMLElement, resultContainer: HTMLElement, team: ParticipantResult, hint: MatchHint, inLowerBracket: boolean): void {
329-
const participant = this.participants.find(item => item.id === team.id);
326+
private renderParticipant(participantContainer: HTMLElement, nameContainer: HTMLElement, resultContainer: HTMLElement, participant: ParticipantResult, hint: MatchHint, inLowerBracket: boolean): void {
327+
const found = this.participants.find(item => item.id === participant.id);
330328

331-
if (participant) {
332-
nameContainer.innerText = participant.name;
333-
this.renderTeamOrigin(nameContainer, team, inLowerBracket);
329+
if (found) {
330+
nameContainer.innerText = found.name;
331+
this.renderTeamOrigin(nameContainer, participant, inLowerBracket);
334332
} else
335-
this.renderHint(nameContainer, team, hint, inLowerBracket);
333+
this.renderHint(nameContainer, participant, hint, inLowerBracket);
336334

337-
resultContainer.innerText = `${team.score || '-'}`;
335+
resultContainer.innerText = `${participant.score || '-'}`;
338336

339-
dom.setupWin(teamContainer, resultContainer, team);
340-
dom.setupLoss(teamContainer, resultContainer, team);
337+
dom.setupWin(participantContainer, resultContainer, participant);
338+
dom.setupLoss(participantContainer, resultContainer, participant);
341339
}
342340

343341
/**
344342
* Renders a hint for a participant.
345343
*
346344
* @param nameContainer The name container.
347-
* @param team The participant result.
345+
* @param participant The participant result.
348346
* @param hint Hint for the participant.
349347
* @param inLowerBracket Whether the match is in lower bracket.
350348
*/
351-
private renderHint(nameContainer: HTMLElement, team: ParticipantResult, hint: MatchHint, inLowerBracket: boolean): void {
352-
if (hint === undefined || team.position === undefined) return;
349+
private renderHint(nameContainer: HTMLElement, participant: ParticipantResult, hint: MatchHint, inLowerBracket: boolean): void {
350+
if (hint === undefined || participant.position === undefined) return;
353351
if (!this.config.showSlotsOrigin) return;
354352
if (!this.config.showLowerBracketSlotsOrigin && inLowerBracket) return;
355353

356-
dom.setupHint(nameContainer, hint(team.position));
354+
dom.setupHint(nameContainer, hint(participant.position));
357355
}
358356

359357
/**
360358
* Renders a participant's origin.
361359
*
362360
* @param nameContainer The name container.
363-
* @param team The participant result.
361+
* @param participant The participant result.
364362
* @param inLowerBracket Whether the match is in lower bracket.
365363
*/
366-
private renderTeamOrigin(nameContainer: HTMLElement, team: ParticipantResult, inLowerBracket: boolean): void {
367-
if (team.position === undefined) return;
364+
private renderTeamOrigin(nameContainer: HTMLElement, participant: ParticipantResult, inLowerBracket: boolean): void {
365+
if (participant.position === undefined) return;
368366
if (this.config.participantOriginPlacement === 'none') return;
369367
if (!this.config.showSlotsOrigin) return;
370368
if (!this.config.showLowerBracketSlotsOrigin && inLowerBracket) return;
371369

372370
// 'P' for position (where the participant comes from) and '#' for actual seeding.
373-
const origin = inLowerBracket ? `P${team.position}` : `#${team.position}`;
371+
const origin = inLowerBracket ? `P${participant.position}` : `#${participant.position}`;
374372

375373
dom.addTeamOrigin(nameContainer, origin, this.config.participantOriginPlacement);
376374
}

src/style.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ h3 {
178178
}
179179
}
180180

181-
.teams {
181+
.opponents {
182182
width: 100%;
183183
position: relative;
184184

@@ -235,7 +235,7 @@ h3 {
235235
}
236236
}
237237

238-
.team {
238+
.participant {
239239
display: flex;
240240
justify-content: space-between;
241241
padding: 2px 8px;

src/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export interface Config {
3636
/**
3737
* Where the position of a participant is placed relative to its name.
3838
* - If `none`, the position is not added.
39-
* - If `before`, the position is prepended before the team name. "#1 Team"
40-
* - If `after`, the position is appended after the team name, in parentheses. "Team (#1)"
39+
* - If `before`, the position is prepended before the participant name. "#1 Team"
40+
* - If `after`, the position is appended after the participant name, in parentheses. "Team (#1)"
4141
*/
4242
participantOriginPlacement: Placement,
4343

0 commit comments

Comments
 (0)