-
Notifications
You must be signed in to change notification settings - Fork 87
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(design-system): add NumberInput component and stories #2267
Conversation
62ef520
to
caaff52
Compare
caaff52
to
e8c6dc9
Compare
i saw that there was a lock on disabled but it's not present in the storybook - should we add it in? |
Design changes, moving to draft again |
# Conflicts: # frontend/src/theme/components/index.ts
|
||
return ( | ||
<Box {...htmlProps} ref={ref} __css={styles.root}> | ||
<chakra.input |
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 are we using chakra's internal input
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.
the Input
component performs more transformation of inputProps
, removing some important variables such as aria-invalid
, etc. Resulting in some styles not being provided. I'll add a comment
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.
Possible to patch upstream, i will open an issue if I have time....
const controlProps = useFormControlProps(props) | ||
const { | ||
htmlProps, | ||
getInputProps, | ||
getIncrementButtonProps, | ||
getDecrementButtonProps, | ||
} = useNumberInput({ ...controlProps, clampValueOnBlur }) |
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 find it EXTREMELY frustrating that chakra
doesn't have any documentation on this. how do you know to use useFormControlProps
? how dyou know what args it takes, and that the return value can be passed back into useNumberInput
?
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 looked at the source code for their own NumberInput implementation.
Reason for using useFormControlProps
is so that this component can be wrapped with a FormControl
component and be able to access their relevant props, such as whether the field is disabled, readOnly, invalid, etc.
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.
Possible to patch upstream, i will open an issue if I have time....
# Conflicts: # frontend/src/theme/components/index.ts
Problem
This PR adds the
NumberInput
component, as well as stories depicting its various states and how to use it withreact-hook-form
.Closes #2004
Solution
Features:
Before & After Screenshots
In generated storybook.