Skip to content

Conversation

@Natal1a
Copy link
Collaborator

@Natal1a Natal1a commented Jan 28, 2021

No description provided.

Copy link
Collaborator

@s-justina s-justina left a comment

Choose a reason for hiding this comment

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

Kilka uwag do kodu.

parentId?: string,
className?: string
): HTMLElement => {
const component: HTMLElement = document.createElement('button')!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Myślę że div byłby lepszym wyborem, z tego względu że po kliknięciu nie będzie "odciśnięty" oraz jest blokowy.

const component: HTMLElement = document.createElement('button')!

label = HTMLElement
? (component.innerHTML = `${label}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Metoda appendChild będzie tutaj chyba bardziej wydajna.

label = HTMLElement
? (component.innerHTML = `${label}`)
: /(jpg|gif|png|JPG|GIF|PNG|JPEG|jpeg)$/.test(`${label}`)
? (component.style.backgroundImage = `url(${label})`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wydaje mi się że podwójna ternary operation nie jest zbyt dobrze czytelna.


label = HTMLElement
? (component.innerHTML = `${label}`)
: /(jpg|gif|png|JPG|GIF|PNG|JPEG|jpeg)$/.test(`${label}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sprawdzenie czy string jest obrazkiem zrobiłam już w moim komponencie. Przeniosę tę funkcję gdzieś indziej żebyśmy obie mogły z niej korzystać.

component.addEventListener('click', onClick)

const parentEl = document.getElementById(`${parentId}`)
component.classList.add(`${className}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Parametry parentId oraz className masz zaznaczone jako niewymagane parametry, więc najlepiej byłoby najpierw sprawdzić czy taka zmienna istnieje zanim ją wywołasz.. w każdym razie na pewno dla className, bo nie jest przypisana do osobnej zmiennej.

label: ContainerComponentLabel,
onClick: () => void,
parentId?: string,
className?: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Proponuję odwrócić kolejność: className a następnie parentId. Najprawdopodobniej częściej będzie używana klasa bez podania odnośnika rodzica więc będzie można podać wówczas mniej parametrów przy wywołaniu komponentu.

@Natal1a Natal1a linked an issue Jan 30, 2021 that may be closed by this pull request
4 tasks
Copy link
Collaborator

@s-justina s-justina left a comment

Choose a reason for hiding this comment

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

Tylko jedna uwaga :)

@@ -0,0 +1,35 @@
.game-mode_container {
box-sizing: border-box;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tego nie musisz pisać, bo to jest w resecie Mirona dla wszystkich elementów.

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.

UI Komponent | Kafel trybu gry

4 participants