-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[WEB-4731] feat: add baseui input component to propel package #7769
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ad195e
✨ feat: add input component to propel package
JayashTripathy 787f81c
🚨 fix: lint
JayashTripathy c8a657d
🚨 fix: lint
JayashTripathy 41227e4
Merge branch 'preview' of https://github.com/makeplane/plane into fea…
JayashTripathy 21ef643
fix: add aria-invalid attribute to Input component for better accessi…
JayashTripathy 44b37d2
chore: fix formatting in package.json and reorder imports in popover-…
JayashTripathy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "./input"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { Input } from "./index"; | ||
|
|
||
| const meta: Meta<typeof Input> = { | ||
| title: "Components/Input", | ||
| component: Input, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| tags: ["autodocs"], | ||
| argTypes: { | ||
| mode: { | ||
| control: "select", | ||
| options: ["primary", "transparent", "true-transparent"], | ||
| }, | ||
| inputSize: { | ||
| control: "select", | ||
| options: ["xs", "sm", "md"], | ||
| }, | ||
| hasError: { | ||
| control: "boolean", | ||
| }, | ||
| type: { | ||
| control: "select", | ||
| options: ["text", "email", "password", "number", "tel", "url", "search"], | ||
| }, | ||
| autoComplete: { | ||
| control: "select", | ||
| options: ["on", "off"], | ||
| }, | ||
| disabled: { | ||
| control: "boolean", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof Input>; | ||
|
|
||
| const createStory = (args: Partial<React.ComponentProps<typeof Input>>): Story => ({ | ||
| args: { placeholder: "Enter text...", className: "w-[400px]", ...args }, | ||
| }); | ||
|
|
||
| const createShowcaseStory = ( | ||
| title: string, | ||
| sections: Array<{ label: string; props: Partial<React.ComponentProps<typeof Input>> }> | ||
| ): Story => ({ | ||
| render: () => ( | ||
| <div className="space-y-4 w-[400px]"> | ||
| <div className="space-y-2"> | ||
| <h3 className="text-sm font-medium">{title}</h3> | ||
| <div className="space-y-2"> | ||
| {sections.map(({ label, props }, index) => ( | ||
| <div key={index} className="w-full"> | ||
| <label className="text-xs text-gray-500">{label}</label> | ||
| <Input className="w-full" {...props} /> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ), | ||
| }); | ||
|
|
||
| export const Default = createStory({}); | ||
|
|
||
| export const Primary = createStory({ | ||
| mode: "primary", | ||
| placeholder: "Primary input", | ||
| }); | ||
|
|
||
| export const Transparent = createStory({ | ||
| mode: "transparent", | ||
| placeholder: "Transparent input", | ||
| }); | ||
|
|
||
| export const TrueTransparent = createStory({ | ||
| mode: "true-transparent", | ||
| placeholder: "True transparent input", | ||
| }); | ||
|
|
||
| export const ExtraSmall = createStory({ | ||
| inputSize: "xs", | ||
| placeholder: "Extra small input", | ||
| }); | ||
|
|
||
| export const Small = createStory({ | ||
| inputSize: "sm", | ||
| placeholder: "Small input", | ||
| }); | ||
|
|
||
| export const Medium = createStory({ | ||
| inputSize: "md", | ||
| placeholder: "Medium input", | ||
| }); | ||
|
|
||
| export const WithError = createStory({ | ||
| hasError: true, | ||
| placeholder: "Input with error", | ||
| defaultValue: "Invalid input", | ||
| }); | ||
|
|
||
| export const Disabled = createStory({ | ||
| disabled: true, | ||
| placeholder: "Disabled input", | ||
| defaultValue: "Cannot edit this", | ||
| }); | ||
|
|
||
| export const WithValue = createStory({ | ||
| defaultValue: "Pre-filled value", | ||
| placeholder: "Input with value", | ||
| }); | ||
|
|
||
| export const Email = createStory({ | ||
| type: "email", | ||
| placeholder: "Enter your email", | ||
| autoComplete: "on", | ||
| }); | ||
|
|
||
| export const Password = createStory({ | ||
| type: "password", | ||
| placeholder: "Enter your password", | ||
| autoComplete: "off", | ||
| }); | ||
|
|
||
| export const Number = createStory({ | ||
| type: "number", | ||
| placeholder: "Enter a number", | ||
| }); | ||
|
|
||
| export const Search = createStory({ | ||
| type: "search", | ||
| placeholder: "Search...", | ||
| }); | ||
|
|
||
| export const AllModes = createShowcaseStory("Input Modes", [ | ||
| { label: "Primary", props: { mode: "primary", placeholder: "Primary input" } }, | ||
| { label: "Transparent", props: { mode: "transparent", placeholder: "Transparent input" } }, | ||
| { label: "True Transparent", props: { mode: "true-transparent", placeholder: "True transparent input" } }, | ||
| ]); | ||
|
|
||
| export const AllSizes = createShowcaseStory("Input Sizes", [ | ||
| { label: "Extra Small (xs)", props: { inputSize: "xs", placeholder: "Extra small input" } }, | ||
| { label: "Small (sm)", props: { inputSize: "sm", placeholder: "Small input" } }, | ||
| { label: "Medium (md)", props: { inputSize: "md", placeholder: "Medium input" } }, | ||
| ]); | ||
|
|
||
| export const AllStates = createShowcaseStory("Input States", [ | ||
| { label: "Normal", props: { placeholder: "Normal input" } }, | ||
| { label: "With Error", props: { hasError: true, placeholder: "Input with error" } }, | ||
| { label: "Disabled", props: { disabled: true, placeholder: "Disabled input" } }, | ||
| { label: "With Value", props: { defaultValue: "Pre-filled value", placeholder: "Input with value" } }, | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import * as React from "react"; | ||
| import { Input as BaseInput } from "@base-ui-components/react/input"; | ||
| // helpers | ||
| import { cn } from "../utils"; | ||
|
|
||
| export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
| mode?: "primary" | "transparent" | "true-transparent"; | ||
| inputSize?: "xs" | "sm" | "md"; | ||
| hasError?: boolean; | ||
| } | ||
|
|
||
| const Input = React.forwardRef<HTMLInputElement, InputProps>((props, ref) => { | ||
| const { | ||
| id, | ||
| type, | ||
| name, | ||
| mode = "primary", | ||
| inputSize = "sm", | ||
| hasError = false, | ||
| className = "", | ||
| autoComplete = "off", | ||
| ...rest | ||
| } = props; | ||
|
|
||
| return ( | ||
| <BaseInput | ||
| id={id} | ||
| ref={ref} | ||
| type={type} | ||
| name={name} | ||
| className={cn( | ||
| "block rounded-md bg-transparent text-sm placeholder-custom-text-400 focus:outline-none", | ||
| { | ||
| "rounded-md border-[0.5px] border-custom-border-200": mode === "primary", | ||
| "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary": | ||
| mode === "transparent", | ||
| "rounded border-none bg-transparent ring-0": mode === "true-transparent", | ||
| "border-red-500": hasError, | ||
| "px-1.5 py-1": inputSize === "xs", | ||
| "px-3 py-2": inputSize === "sm", | ||
| "p-3": inputSize === "md", | ||
| }, | ||
| className | ||
| )} | ||
| aria-invalid={hasError || undefined} | ||
| autoComplete={autoComplete} | ||
| {...rest} | ||
| /> | ||
JayashTripathy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| }); | ||
|
|
||
| Input.displayName = "form-input-field"; | ||
|
|
||
| export { Input }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.