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

#342 Support type prop to set the type of input, adjusted styles to fit with designs, added Icon functionality #369

Merged
merged 15 commits into from
Nov 25, 2022

Conversation

marcinsawicki
Copy link
Contributor

@marcinsawicki marcinsawicki commented Jul 28, 2022

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:

  • Added support for native type prop to enable switching between text and password mode, where text is the default
  • In password mode, added an icon to switch between password visibility
  • Added icon prop for passing the component, which will be displayed as decoration in input
  • Refactored code and styles to fit with the designs
  • Changes size prop to kind to set the input size, because size is reserved in native props and has a different desitnation

Storybook

Checklist

Obligatory:

  • Self-review
  • Unit & integration tests
  • Storybook cases
  • Design review
  • Functional (QA) review

Optional:

  • Accessibility cases (keyboard control, correct HTML markup, etc.)

@marcinsawicki marcinsawicki added the feature New feature or request label Jul 28, 2022
@marcinsawicki marcinsawicki marked this pull request as draft July 28, 2022 08:09
@marcinsawicki marcinsawicki marked this pull request as ready for review July 28, 2022 10:24
@@ -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';

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} />

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

@marcinsawicki marcinsawicki requested review from sgraczyk and a team July 28, 2022 12:21
@kstvsko kstvsko self-requested a review August 1, 2022 09:16
Copy link

@kstvsko kstvsko left a 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 => (
<>

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

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';

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

Copy link
Contributor

Choose a reason for hiding this comment

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

☝️

@kstvsko
Copy link

kstvsko commented Sep 6, 2022

@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.

@marcinsawicki marcinsawicki changed the title #342 Added kinds to set the type of input, adjusted styles to fit with designs, added Icon functionality #342 Support type prop to set the type of input, adjusted styles to fit with designs, added Icon functionality Oct 7, 2022
size?: InputSize | undefined;
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {
kind?: InputSize | undefined;
Copy link
Contributor

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;

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.

Copy link
Contributor

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={

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

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;
Copy link
Contributor

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';
Copy link
Contributor

Choose a reason for hiding this comment

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

For me it could be a generic size type lifted up in folders structure as we are slowly starting to repeat ourselves

Screenshot 2022-11-15 at 08 42 54

z-index: $stacking-context-level-popover;
border-radius: 4px;
box-shadow: 0 1px 10px 0 rgb(66 77 87 / 30%);

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?

@jpyzio123
Copy link
Contributor

Reversed eye icons in type:password. By default the icon should be crossed out indicating the password is hidden
image

@jpyzio123
Copy link
Contributor

jpyzio123 commented Nov 18, 2022

mission icon options to put icon to the right side or two icons on both sides as in designs
202706408-0981fb2b-3a88-4b19-8321-41ad8cc94940 png (632×1428) 2022-11-18 13-36-59

@marcinsawicki marcinsawicki merged commit 48ecd8a into v1 Nov 25, 2022
@marcinsawicki marcinsawicki deleted the feature/342 branch November 25, 2022 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Input] Add missing functionalities and enable possibility the type of input
6 participants