-
Notifications
You must be signed in to change notification settings - Fork 1
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
Convert AddressForm From Angular to React #969
base: master
Are you sure you want to change the base?
Changes from 1 commit
db24bf2
f72807a
710f548
474b173
b8750e6
aea7f50
0f64054
72d2e73
92b865d
4945084
2fba43c
1bf6987
a07a0e2
5cb7503
aa10dea
bbabb3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { ChangeEvent, FocusEvent, HTMLInputTypeAttribute } from 'react'; | ||
|
||
interface TextInputProps { | ||
title?: string, | ||
type?: HTMLInputTypeAttribute, | ||
name: string, | ||
required?: boolean, | ||
maxLength?: number, | ||
pattern?: string, | ||
disabled?: boolean, | ||
onChange: (event: ChangeEvent<any>) => void, | ||
onBlur: (event: FocusEvent<any>) => void, | ||
value?: string, | ||
error?: string, | ||
} | ||
|
||
const TextInput = ({ | ||
title, | ||
type = 'text', | ||
name, | ||
required = false, | ||
maxLength, | ||
pattern, | ||
disabled, | ||
onChange, | ||
onBlur, | ||
value, | ||
error, | ||
}: TextInputProps) => ( | ||
<div className={`form-group${required && ' is-required' || ''}${error && ' has-error' || ''}`}> | ||
{ title && <label>{title}</label> } | ||
<input | ||
type={type} | ||
className="form-control form-control-subtle" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these overridable? Not all text inputs have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I could create an optional prop that overrides the input className value. |
||
name={name} | ||
required={required} | ||
maxLength={maxLength} | ||
pattern={pattern} | ||
disabled={disabled} | ||
onChange={onChange} | ||
onBlur={onBlur} | ||
value={value} | ||
/> | ||
{ error && ( | ||
<div role="alert"> | ||
<div className="help-block">{error}</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
|
||
export default TextInput; |
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.
This structure isn't always in place for text inputs. What's the best way to build a different structure when we need it? (e.g.
personalOptionsModal.tpl.html
)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 could maybe remove this wrapping
div
from here, and create a wrapper component that will only be used for AddressForm text inputs.