Skip to content

Instantly share code, notes, and snippets.

@jednano
Created January 21, 2016 17:43
Show Gist options
  • Save jednano/66a00561d1649e4f6bec to your computer and use it in GitHub Desktop.
Save jednano/66a00561d1649e4f6bec to your computer and use it in GitHub Desktop.
TypeScript/React example
import {
Component,
EventHandler,
FormEvent
} from 'react';
import { ElementProps, resolveClassNames } from '../../../helpers/bem';
import { Label } from '../../Form';
export default class InputPassword extends Component<
InputPasswordProps,
InputPasswordState
> {
public render() {
const {
element,
modifiers,
helpMessage,
helpAction,
value,
onChange,
inputTabIndex,
helpActionTabIndex,
} = this.props;
return resolveClassNames(
<div {...{ element, modifiers }}>
<Label
block="form-label"
modifiers="full-width"
label="Password"
{...{ helpMessage, helpAction }}
tabIndex={helpActionTabIndex}
>
<input
element="input"
type="password"
name="password"
autoComplete="off"
{...{ value, onChange }}
tabIndex={inputTabIndex}
/>
</Label>
</div>
);
}
}
interface InputPasswordProps extends ElementProps {
helpMessage: string;
helpAction?: Function;
value?: string;
onChange?: EventHandler<FormEvent>;
helpActionTabIndex?: number;
inputTabIndex?: number;
}
interface InputPasswordState {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment