Skip to content
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

Form input component #112

Merged
merged 17 commits into from
Aug 23, 2023
Merged

Form input component #112

merged 17 commits into from
Aug 23, 2023

Conversation

PixelSculptor
Copy link
Contributor

This PR includes:

  • implementation of input form component
  • styles for input form component (with type variants)
  • mixins for positioning, custom border, outline, fonts, range element
  • function to converting px value to rem unit
  • documentation of UI component in storybook

@PixelSculptor PixelSculptor added frontend Frontend tasks components Create new component labels Aug 5, 2023
Copy link
Collaborator

@marcol13 marcol13 left a comment

Choose a reason for hiding this comment

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

Great job with that component 💪 I have several suggestions for you 😉 Check it in your free time

@@ -0,0 +1,92 @@
@use 'functions' as utils;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great job with these mixins and functions 💪

@@ -1,10 +1,12 @@

// Do not edit directly
Copy link
Collaborator

Choose a reason for hiding this comment

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

That is good idea to group these variables, but I am afraid that when we add or modify one of variables in Figma Tokens, these changes will be overwritten. Alternatively we can build our own solution to translate JSON representation of tokens to SCSS file 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe there is possiblity to add some comments through Figma plugin before deploying changes to repo

}
@use '../abstracts/' as *;

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need all this font weights? Maybe we could limit this to 3 or 4 weights? For example: 200, 400, 600, 700. What do you think about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I will short this URL ;)

required,
darkTheme
}) => {
const themePicker = darkTheme ? 'input-fragment--dark' : 'input-fragment'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice approach to apply correct class based on theme. Since we don't have proper design in our Figma it is not mandatory to implement this, but it is a good reminder to think about this in next meeting, because there are several things to discuss.

The best way (in my opinion) to create themes in React app, is creating proper ThemeProvider. Here is one example of using this: https://webtips.dev/how-i-theme-my-react-app-with-sass#google_vignette . We can build something similar, but it should be separate task for it 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can discuss on our daily this general solution to avoid next time copy paste our own solution for every component

<div className={classNames(styles[themePicker])}>
<label
htmlFor={id}
className={classNames(styles['input-fragment__label'])}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you are using only one style, you don't need to use classNames function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thanks :D

const placeholderText = inputType !== 'password' ? placeholder : null

return (
<div className={classNames(styles[themePicker])}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, in classNames function, you can add another argument which could be a prop passing from parent.

Sometimes (especially in forms) programmers might want to customize a specific input to their needs. In that situation they want to pass their own styles to this component. For that case you could add className prop and use it here:

Suggested change
<div className={classNames(styles[themePicker])}>
<div className={classNames(styles[themePicker], className)}>

'password',
'textArea',
'submit',
'checkbox',
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion, you could get rid of some of these variants in FormInput component. textArea, submit, checkbox, date, file, radio, range, search and time probably would have different styles or functionality than the current component 😄

@@ -0,0 +1,3 @@
@function px-to-rem-converter($px-value, $base: 16px) {
@return ($px-value * 1px / $base * 1rem);
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I tried to run our application, I get this warning:
image

Maybe we should use there calc or math.div indeed.

Copy link
Collaborator

@marcol13 marcol13 left a comment

Choose a reason for hiding this comment

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

Great job! Looks good to me 💪🎉

@PixelSculptor PixelSculptor merged commit 9157041 into frontend Aug 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
components Create new component frontend Frontend tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants