Skip to content

Commit 74eb470

Browse files
authored
Merge pull request #65 from topcoder-platform/PROD-1024_textarea
PROD-1024 textarea - PLAT-895_create-intake
2 parents 743119d + 8d56e48 commit 74eb470

File tree

23 files changed

+132
-44
lines changed

23 files changed

+132
-44
lines changed

src/header/tool-selectors/tool-selectors-wide/tool-selector-wide/ToolSelectorWide.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ToolSelectorWide: FC<ToolSelectorWideProps> = (props: ToolSelectorWideProp
2323
<Link
2424
className='large-tab'
2525
tabIndex={-1}
26-
to={route}
26+
to={route}
2727
>
2828
{title}
2929
</Link>

src/lib/button/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
export { default as Button } from './Button'
2-
export type {
3-
ButtonSize,
4-
ButtonStyle,
5-
ButtonType
6-
} from './Button'
2+
export
3+
// tslint:disable-next-line: no-unused-expression
4+
type { ButtonSize } from './Button'
5+
export
6+
// tslint:disable-next-line: no-unused-expression
7+
type { ButtonStyle } from './Button'
8+
export
9+
// tslint:disable-next-line: no-unused-expression
10+
type { ButtonType } from './Button'

src/lib/form/Form.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
formSubmitAsync,
1313
formValidateAndUpdate,
1414
} from './form-functions'
15+
import { InputText, InputTextarea } from './form-input'
1516
import { FormInputModel } from './form-input.model'
1617
import styles from './Form.module.scss'
17-
import { TextInput } from './text-input'
1818

1919
interface FormProps<ValueType, RequestType> {
2020
readonly formDef: FormDefinition
@@ -71,15 +71,26 @@ const Form: <ValueType extends any, RequestType extends any>(props: FormProps<Va
7171
const formInputs: Array<JSX.Element> = props.formDef.inputs
7272
.map(input => formGetInputModel(props.formDef.inputs, input.name))
7373
.map((inputModel, index) => {
74-
return (
75-
<TextInput
76-
{...inputModel}
77-
key={inputModel.name}
78-
tabIndex={inputModel.notTabbable ? -1 : index + 1}
79-
type={inputModel.type || 'text'}
80-
value={inputModel.value}
81-
/>
82-
)
74+
switch (inputModel.type) {
75+
case 'textarea':
76+
return <InputTextarea
77+
{...inputModel}
78+
key={inputModel.name}
79+
tabIndex={inputModel.notTabbable ? -1 : index + 1}
80+
value={inputModel.value}
81+
/>
82+
default:
83+
return (
84+
<InputText
85+
{...inputModel}
86+
key={inputModel.name}
87+
tabIndex={inputModel.notTabbable ? -1 : index + 1}
88+
type={inputModel.type || 'text'}
89+
value={inputModel.value}
90+
/>
91+
)
92+
}
93+
8394
})
8495

8596
const buttons: Array<JSX.Element> = props.formDef.buttons

src/lib/form/form-field-wrapper/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/lib/form/form-input.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface FormInputModel {
99
readonly notTabbable?: boolean
1010
readonly placeholder?: string
1111
readonly preventAutocomplete?: boolean
12-
readonly type: 'password' | 'text'
12+
readonly type: 'password' | 'text' | 'textarea'
1313
readonly validators: Array<(value: string | undefined, formValues?: HTMLFormControlsCollection, otherField?: string) => string | undefined>
1414
value?: string
1515
}

src/lib/form/form-field-wrapper/Form-Field-Wrapper.module.scss renamed to src/lib/form/form-input/form-field-wrapper/FormFieldWrapper.module.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
@import '../../styles';
1+
@import '../../../styles';
22

33
$form-pad-top: calc($pad-md - $border);
44
$border-xs: 1px;
55
$error-line-height: 14px;
66

77
.form-field-wrapper {
8-
position: relative;
98
display: flex;
109
flex-direction: column;
1110
justify-content: flex-start;
1211
padding-bottom: $pad-md;
1312

1413
.form-field {
14+
flex: 1;
1515
display: flex;
1616
flex-direction: column;
1717
align-items: flex-start;
18-
padding: $pad-sm $form-pad-top;
18+
padding: $pad-sm $form-pad-top $border-xs $form-pad-top;
1919
height: calc($pad-xxl * 2);
2020
background: $tc-white;
2121
border: $border-xs solid $black-40;
@@ -35,7 +35,7 @@ $error-line-height: 14px;
3535
&.focus,
3636
&.form-field-error {
3737
border-width: $border;
38-
padding: calc($pad-sm - $border-xs) calc($form-pad-top - $border-xs);
38+
padding: calc($pad-sm - $border-xs) calc($form-pad-top - $border-xs) 0 calc($form-pad-top - $border-xs);
3939
}
4040

4141
&.disabled {
@@ -54,6 +54,8 @@ $error-line-height: 14px;
5454
}
5555

5656
.label {
57+
display: flex;
58+
flex-direction: column;
5759
top: calc(50% - $form-pad-top/2);
5860
color: $turq-160;
5961
margin-bottom: $pad-xs;

src/lib/form/form-field-wrapper/Form-Field-Wrapper.tsx renamed to src/lib/form/form-input/form-field-wrapper/FormFieldWrapper.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import classNames from 'classnames'
22
import { Dispatch, FC, ReactNode, SetStateAction, useState } from 'react'
33

4-
import { IconSolid } from '../../svgs'
4+
import { IconSolid } from '../../../svgs'
55

6-
import styles from './Form-Field-Wrapper.module.scss'
6+
import styles from './FormFieldWrapper.module.scss'
7+
8+
export const optionalHint: string = '(optional)'
79

810
interface FormFieldWrapperProps {
911
readonly children: ReactNode
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as FormFieldWrapper } from './FormFieldWrapper'
2+
export { optionalHint as inputOptionalHint } from './FormFieldWrapper'

src/lib/form/form-input/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { inputOptionalHint } from './form-field-wrapper'
2+
export * from './input-text'
3+
export * from './input-textarea'

0 commit comments

Comments
 (0)