-
Notifications
You must be signed in to change notification settings - Fork 10
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
#342 Support type prop to set the type of input, adjusted styles to fit with designs, added Icon functionality #369
Conversation
@@ -1,15 +1,20 @@ | |||
import * as React from 'react'; | |||
import { ComponentMeta, Story } from '@storybook/react'; | |||
|
|||
import { StoryDescriptor } from '../../stories/components/StoryDescriptor'; | |||
import * as MaterialIcons from '@livechat/design-system-icons/react/material'; |
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 can remove the line break from 3
export const Kinds = (): JSX.Element => ( | ||
<> | ||
<StoryDescriptor title="Text"> | ||
<Input placeholder={placeholderText} /> |
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.
While defining specific variants, we should not rely on default
values as it's intended to include prop value for docs
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.
As for now, it is compliant with the designs. The only thing I would rethink is if we want to have a hover state on the clickable icons like the one for showing/hiding password. I will take care of the topic and bring a new issue if needed.
); | ||
|
||
export const WithIcon = (): JSX.Element => ( | ||
<> |
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.
React.Fragment
is not necessary here
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.
Bump ☝🏼
|
||
export interface InputProps extends React.HTMLAttributes<HTMLInputElement> { | ||
size?: InputSize | undefined; | ||
error?: boolean | undefined; | ||
disabled?: boolean | undefined; | ||
kind?: 'text' | 'password'; |
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.
To be honest, I'm not sure if it's a good approach. We already extend React.HTMLAttributes<HTMLInputElement>
which has a prop called type
And it should handle password
type -> https://www.w3schools.com/html/html_form_input_types.asp
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.
☝️
@sgraczyk @MichalPaszowski @marcinsawicki Any idea how the disabled input with icon looks? I had to fix that issue in Figma and I also wanted to take care of it here, but I cannot see the disabled input with the icon on Storybook. |
size?: InputSize | undefined; | ||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> { | ||
kind?: InputSize | undefined; |
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.
why do you need to | undefined
in this and the next three lines
disabled?: boolean | undefined; | ||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> { | ||
wrapperSize?: InputSize; |
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.
Maybe inputSize
. I'm not sure if wrapper
is easy to understand.
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 definitely agree with that. inputSize
feels much better
kind="plain" | ||
icon={ | ||
<Icon | ||
customColor={ |
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 would move these conditions to constants
: 'var(--content-disabled)' | ||
} | ||
source={ | ||
!isPasswordVisible ? VisibilityOnIcon : VisibilityOffIcon |
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.
As above, the target is to make JSX as simple as possible
disabled?: boolean | undefined; | ||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> { | ||
wrapperSize?: InputSize; |
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 definitely agree with that. inputSize
feels much better
|
||
type InputSize = 'xsmall' | 'small' | 'medium' | 'large'; | ||
type InputSize = 'compact' | 'medium' | 'large'; |
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-index: $stacking-context-level-popover; | ||
border-radius: 4px; | ||
box-shadow: 0 1px 10px 0 rgb(66 77 87 / 30%); |
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.
How about a shadow color from tokens here?
Resolves: #342
Description
The
Input
component is missing some functionalities after migration from the old implementation. Also, we found that the component has incorrect or missing styles.What's changed:
type
prop to enable switching betweentext
andpassword
mode, wheretext
is the defaultpassword
mode, added an icon to switch between password visibilityicon
prop for passing the component, which will be displayed as decoration in inputsize
prop tokind
to set the input size, becausesize
is reserved in native props and has a different desitnationStorybook
Checklist
Obligatory:
Optional: