Skip to content

Conversation

@tomaszdworniczak
Copy link
Collaborator

@tomaszdworniczak tomaszdworniczak commented Jan 15, 2021

Zostawiłem trochę bałagan w App.js, ale to tylko, dlatego żebyście mogli zobaczyć jak ten komponent wygląda. Po review zakomentuję kod, który będzie odpowiedzialny za renderowanie rankingu aż do czasu 'sprzątania' :P

renderComponent(ModeRanking(emptyRanking));

expect(screen.getByText('Leaderboard is empty...')).toBeInTheDocument();
expect(screen.queryByTestId('playerRowNum1')).toBeFalsy();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dobrze napisane testy! :)

toBeFalsy ma kilka możliwośći, a zdaje mi się, żę bardziej czytelnie jest dać po prostu, że go nie ma:

expect(screen.queryByTestId('playerRowNum1')).not.toBeInTheDocument()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

racja, zamienię na notToBeInTheDocument() :P

Copy link
Owner

@MateuszNaKodach MateuszNaKodach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomdworniczak kurde, no co Ty zrobiłeś!? Nie mam za bardzo, do czego się przyczepić :) Świetnie!
Może z SCSSem by się coś znalazło, ale jeśli tak to nie będę wyręczał naszego CSSMastera @PiotrWr.

Nawet commity z oznaczeniem taska :) (pamiętaj o squash przy mergu).

}

if (typeof topScores !== 'undefined' && topScores.length > 0) {
for (let i = 0; i < topScores.length; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie musicie ograniczac się w komponencie do jednej funkcji :) Dobrze byłoby dodać do osobnych np.
PlayerRow - mysle, ze to zwiększy czytelność. export zostawiacie tylko przy ModeRanking tak jak jest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mówisz, żeby pętle tworzące dane części wyodrębnić do osobnych funkcji?

Copy link
Owner

@MateuszNaKodach MateuszNaKodach Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Może być cała pętla, ale bardziej chodziło mi o obiekt (komponent) w jej ciele.

titleRow.appendChild(headerElement);
}

if (typeof topScores !== 'undefined' && topScores.length > 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tutaj wystarczy:
if (topScores !== undefined && topScores.length > 0)
Albo w ogóle :
if (!topScores && topScores.length > 0)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A najlepiej to nazwać też co to dla nasz znaczy. Czyli:

const rankingIsEmpty = !topScores && topScores.length > 0
if(rankingIsEmpty){
/...cos tam tutaj..//
}

a jak się pomęczysz i wydorebnisz komponenty o których piszę niżej to może się uda coś w stylu nawet:

rankingContainer = rankingIsEmpty ? EmptyRanking() : RankingWithScores()

oczywiscie jakies tam argumenty do tych funkcji.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm fajne rozwiązanie! :-)

rankingContainer.appendChild(playerRow);
}
} else {
const emptyRankingElem = document.createElement('p');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dobrze tak samo wyciągnąć takie dwa komponenty

EmptyRanking()

i np. RankingWithScores()

wtedy ten if będzie czytelniejszy.


const headerElementTitles = ['Place', 'Player', 'Answered'];

for (let i = 0; i < headerElementTitles.length; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tak samo, dobrze dodać funkcję, która będzie jakimś RankingHeader() i tam wszystko w środku sobie przygotować :)
Wtedy całość ModeRanking będzie bardziej czytelna.

Copy link
Collaborator

@PiotrRynio PiotrRynio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegancko 👍 :D

@PiotrRynio
Copy link
Collaborator

@tomdworniczak kurde, no co Ty zrobiłeś!? Nie mam za bardzo, do czego się przyczepić :) Świetnie!
Może z SCSSem by się coś znalazło, ale jeśli tak to nie będę wyręczał naszego CSSMastera @PiotrWr.

Nawet commity z oznaczeniem taska :) (pamiętaj o squash przy mergu).

Jest Ok ;)

@tomaszdworniczak tomaszdworniczak merged commit bfdd339 into develop Jan 15, 2021
@MateuszNaKodach MateuszNaKodach deleted the UI_players_ranking_for_game_mode branch January 18, 2021 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants