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

Add ChipInput component #808

Merged
merged 9 commits into from
Oct 10, 2023
Merged

Conversation

princerajpoot20
Copy link
Member

Related issue(s)

Resolves #753

@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2023

⚠️ No Changeset found

Latest commit: d080f7e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for asyncapi-studio-design-system ready!

Name Link
🔨 Latest commit d080f7e
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-studio-design-system/deploys/65251a3318e28100081ec440
😎 Deploy Preview https://deploy-preview-808--asyncapi-studio-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for modest-rosalind-098b67 ready!

Name Link
🔨 Latest commit d080f7e
🔍 Latest deploy log https://app.netlify.com/sites/modest-rosalind-098b67/deploys/65251a33d3ec9a000811d9a4
😎 Deploy Preview https://deploy-preview-808--modest-rosalind-098b67.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

left some comments.

Comment on lines 4 to 5
initialChips?: string[];
initialInputValue?: string;
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we add support for the following props:

Suggested change
initialChips?: string[];
initialInputValue?: string;
name: string;
id: string;
className: string;
onChange: function;
isDisabled: boolean;
initialChips?: string[];
initialInputValue?: string;

Comment on lines 12 to 13
const [chips, setChips] = useState<string[]>(initialChips);
const [inputValue, setInputValue] = useState<string>(initialInputValue);
Copy link
Member

Choose a reason for hiding this comment

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

the state of this component is going to be managed from outside. no state management should be done in the component.


return (
<div className="flex flex-wrap items-center p-2 bg-gray-900 rounded">
<div className="w-full text-gray-100 mb-2">Tags</div>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<div className="w-full text-gray-100 mb-2">Tags</div>

};

return (
<div className="flex flex-wrap items-center p-2 bg-gray-900 rounded">
Copy link
Member

Choose a reason for hiding this comment

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

based on the design, this component should have a border as well.

@princerajpoot20
Copy link
Member Author

@KhudaDad414 Thankyou for the review. I have made the changes 🙂

Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

Left some comments.

I also noticed that if I delete the text and press delete again, it doesn't remove the last chip. I was expecting to be able to remove chips with the keyboard.

Also, I should be able to navigate through the chips using the keyboard (tab key) and remove a chip if needed (probably the delete key).

Hope that makes sense. It's looking awesome so far ♥️

className="p-1 bg-gray-900 text-white rounded outline-none"
placeholder={placeholder}
disabled={isDisabled}
defaultValue={'registr'}
Copy link
Member

Choose a reason for hiding this comment

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

I would not default it to this but an empty string. You can then create multiple cases in the design system:

  1. How it looks with all the defaults
  2. How it looks with some default text
  3. How it looks with a custom placeholder
  4. And so on...

@princerajpoot20
Copy link
Member Author

@fmvilas Thank you for the review. 🙂

Hope that makes sense. It's looking awesome so far ♥️

Definitely makes sense. My bad. I missed these things.
I have passed the remaining values from the design system but forgot to pass defaultValue from there. Instead, I just hardcoded it in the ChipInput.tsx 😄.

About navigating through chips, it's a great point that I missed out on. I use tab a lot to navigate. it just makes it so convenient.
I have used firstChipRef to get a reference to the first chip. So, when we are in the InputTestField and press tab, navigation will start from the first chip and continue from there.

@sonarcloud
Copy link

sonarcloud bot commented Oct 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

This is beautiful 👏

Great stuff! 🙌

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

LGMT!

@KhudaDad414
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit dbeb742 into asyncapi:master Oct 10, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual Designer: ChipInput component
4 participants