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

feat: input component #221

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

feat: input component #221

wants to merge 15 commits into from

Conversation

jaimefps
Copy link

@jaimefps jaimefps commented May 5, 2023

Creates Text Input component as shown in Figma.

Screen Shot 2023-05-05 at 4 53 51 PM

Screen Shot 2023-05-05 at 4 53 58 PM

@jaimefps jaimefps requested a review from elevatebart as a code owner May 5, 2023 23:54
@changeset-bot
Copy link

changeset-bot bot commented May 5, 2023

🦋 Changeset detected

Latest commit: e642045

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@cypress-design/react-button Patch
@cypress-design/react-input Patch
@cypress-design/vue-input Patch
@cypress-design/constants-input Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented May 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cypress-design ❌ Failed (Inspect) May 18, 2023 5:52pm

Copy link
Contributor

@elevatebart elevatebart left a comment

Choose a reason for hiding this comment

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

Thank you @jaimefps this is a great start,

I took the liberty of adding the vue implementation.
I have a few questions that you could probably answser easily.

The typescript engine seems to work for me, I did not see your issues. Mybe it's a matter of restarting the TS server, maybe it's a git clean problem.

components/Input/react/Input.tsx Show resolved Hide resolved
Comment on lines +31 to +49
const usePropagateFocusProps = () => {
const [hasFocus, setHasFocus] = React.useState(false)
const enableFocusStyle = React.useCallback(() => setHasFocus(true), [])
const disableFocusStyle = React.useCallback(() => setHasFocus(false), [])
const propagateFocusProps = React.useMemo(() => {
return {
onFocus: enableFocusStyle,
onMouseEnter: enableFocusStyle,
onMouseOver: enableFocusStyle,
onBlur: disableFocusStyle,
onMouseLeave: disableFocusStyle,
onMouseOut: disableFocusStyle,
}
}, [enableFocusStyle, disableFocusStyle])
return {
propagateFocusProps,
hasFocus,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the style on focus is usually easier to build using tools like focus-within.

Copy link
Author

Choose a reason for hiding this comment

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

Is there an example of it in a react component at this time, it seems you've only done it in vue atm?

Copy link
Contributor

Choose a reason for hiding this comment

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

it is actually pure css... I'll modify this with an example.

components/Input/assertions.ts Show resolved Hide resolved
Comment on lines +28 to +30
const Contrast = ({ children }) => (
<div className="bg-white p-[2px] rounded">{children}</div>
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we had to create this blob, my guts tell me that "by default" inputs should have a background. That's an opinion though.

Why did you decide to not add it?

Copy link
Author

Choose a reason for hiding this comment

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

The disabled state doesn't contrast well with the default color of the container in the first generated sample, but I'll remove since we don't need it anymore. Moreover, from the figma designs, it seems that the only think distinguishing dark/light mode inputs is the background, so I'll add that based on the same pattern you did for the dark-mode in the tabs component.

@jaimefps jaimefps changed the title [misc]: Feat/input feat(input component) May 8, 2023
@elevatebart elevatebart changed the title feat(input component) feat: input component May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants