-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frontend login form #110
base: frontend
Are you sure you want to change the base?
Frontend login form #110
Conversation
A-Wodnicki
commented
Aug 1, 2023
|
gap: $form-gap; | ||
text-align: center; | ||
background-color: $alternative-a900; | ||
border: 6px solid $primary-p700; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest change border width to rem cause everywhere you're using rem so it's good idea to keep consistency
border-radius: 0.625rem; | ||
padding: 2.875rem 5.4375rem; | ||
|
||
@media screen and (height > 45rem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if resolution for media query should be define as rem unit. @marcol13 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kapson007 yes, you are right. It should be defined in px
unit.
} | ||
} | ||
|
||
h3 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we are using BEM but imo its better to use class selectors and avoid tag selectors as much as possible to control specificity properly.
} | ||
|
||
.passwordReset { | ||
margin-top: -$form-gap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the future its better to create another var rather than using like that beacuse now it's not semantic - using var for gaps in place for margins.
password: string().required('Pole "Hasło" jest wymagane.') | ||
}) | ||
|
||
const handleChange = (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ciekawe podejście. Powinno działać, ale lepiej użyć do tego useRef
. Ten hook nie powoduje rerenderowania się elementu przy każdej zmianie (w tym przypadku na każdy onChange
któregokolwiek z inputów), a walidacja w czasie rzeczywistym nie jest nam potrzebna (wystarczy jedynie sprawdzenie poprawności po kliknięciu przycisku). Jest to więc bardziej wydajny sposób na poradzenie sobie z formularzem 😉
https://levelup.gitconnected.com/react-forms-usestate-vs-useref-5cb584cc19fd
Według mnie lepszym podejściem byłoby zrobić ref
y na każdy input i po kliknięciu przycisku (czyli na onSubmit) odczytywać wartości inputów poprzez .current.value
.
https://dev.to/sobhandash/react-forms-and-useref-hook-4p1l
Errory mogą być wtedy nadal przechowywane jako useState
(bo będą wymuszały rerenderowanie pewnego fragmentu komponentu — komunikatu o błędzie).
} | ||
|
||
return ( | ||
<div className={styles.view}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Z tego diva w późniejszym etapie będzie trzeba utworzyć jakiś nowy komponent 😉 Tak, żeby w pliku LoginForm.jsx
był sam element form
. Na razie niech tak to zostanie, ja się postaram ty zająć 😉
</div> | ||
</header> | ||
<form className={styles.form} ref={loginForm} onSubmit={handleSubmit}> | ||
<header> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wydaje mi się, że w tym miejscu element header
jest trochę niepotrzebny. Można go zastąpić zwykłym divem.
)} | ||
<Button | ||
style={styles.button} | ||
onClick={() => loginForm.current.onSubmit} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tutaj, tak jak mówiliśmy na spotkaniu, możesz zmienić definicję komponentu Button
, tak aby ten onClick
nie był required
. Wtedy nie będzie trzeba tu robić niepotrzebnych fikołków 😉
<span className={styles.errorSpan}>Nie udało się zalogować</span> | ||
)} | ||
<Button | ||
style={styles.button} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Żeby nie było potem wątpliwości i definicji w SCSS button.button
, możesz zmienić nazwę klasy na inną, np. styles.submitButton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Możesz nawet nie zwracać specjalnie uwagi na złe stylowanie tego komponentu, bo Button.jsx
jest do poprawy, także nie musisz tego na siłę dostosowywać w tym LoginFormie 😉 Ale oczywiście na razie możesz tak to zostawić 😄
Btw. świetna robota! Widok formularza wygląda praktycznie identycznie jak na makiecie. Kilka sugestii ode mnie i wcześniej od @Kapson007 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks nice, there are some comments to consider with team ;)
</div> | ||
</header> | ||
<form className={styles.form} ref={loginForm} onSubmit={handleSubmit}> | ||
<h3 className={styles.header__level3}>Zaloguj się do swojego konta</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now is better but maybe we should avoid addicting to structure and only write just header
or BEM element login__header
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
login__header
sounds better 😄 header__level3
is a little bit confusing
grid-template-rows: auto 1fr; | ||
align-items: center; | ||
background-color: #282828; | ||
color: $base-white; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please mark as TODO to refactor in the future this calculation with mixin
background-color: #282828; | ||
color: $base-white; | ||
font-size: calc($font-size-p * 1px); | ||
font-weight: 600; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any var for font weight? @marcol13 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there are no variables for that. I am not sure if it is necessary, because in default font-weight values have specific meaning, e.g. 400 - normal
, 600 - semibold
.
What do you think about it? Should I add proper tokens for weight
? @A-Wodnicki @PixelSculptor
background-color: $alternative-a900; | ||
border: 0.375rem solid $primary-p700; | ||
border-radius: 0.625rem; | ||
padding: 2.875rem 5.4375rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it expected to use these specific float values? @marcol13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these values were copied directly from our Figma if they were available to check, I set it to display the values in rem units
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay approve ;) we need to figure out on our meeting how to round up/down these values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss that on our next meeting 😉 Because maybe not everything should be in rem
} | ||
} | ||
|
||
button.button { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you want raise specificity? I think here you don't need button selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Higher specificity was required to override some rules over button component without using !important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried .form__button
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.form__button
is more readable than button.button
😉
color: $alternative-a900; | ||
font-weight: 600; | ||
border-radius: $border-radius-md; | ||
padding: 0.5625rem 1.875rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same specific value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wygląda to bardzo dobrze! 🎉 Kilka małych komentarzy. Myślę, że jak je poprawisz to będzie można tego Pull Requesta mergować 😉
password: string().required('Pole "Hasło" jest wymagane.') | ||
}) | ||
|
||
const handleChange = (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Myślę, że teraz, gdy korzystamy z useRef
, to ta funkcja nie jest nam za bardzo potrzebna 😉 Walidacja razem z ustawieniem błędów powinna się odbywać tylko po naciśnięciu przycisku. Po zmianie wartości w inputach nie potrzebujemy na bieżąco kontroli nad wartościami wpisywanymi przez użytkownika. Wprowadza to tylko niepotrzebne operacje 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Czyli błędy, które wcześniej się pojawiły mają się chować przy submicie? Ta funkcja je chowa jak wpisze się coś do inputa, w którym błąd wystąpił
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaa rozumiem... Nie przewidywaliśmy w sumie takiego zachowania inputa — myślę, że dla prostoty i optymalizacji nie trzeba tutaj usuwać komunikatu o błędzie po wpisaniu tam czegokolwiek.
@@ -0,0 +1,15 @@ | |||
import React from 'react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ogólnie to niekoniecznie potrzebne są nam w Storybooku całe widoki jako historyjki 😉 Bardziej nam będzie zależało, żeby tam znalazły się komponenty, ale kudosy za to, że to postawiłeś 😁 Myślę, że możesz tak to zostawić, ale w przyszłości nie jest wymagane, żebyś to aplikował dla całych stron 😉