Skip to content

Commit

Permalink
feat(protocol-designer): update transfer form design (#3221)
Browse files Browse the repository at this point in the history
* update Transfer form design
* expand use of i18n in PD forms
* add colon and capitalization by default for form component labels via CSS
  • Loading branch information
IanLondon authored Mar 20, 2019
1 parent 55e332e commit 775ec4b
Show file tree
Hide file tree
Showing 30 changed files with 384 additions and 216 deletions.
2 changes: 1 addition & 1 deletion app/src/components/ConfigurePipette/ConfigForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class ConfigForm extends React.Component<Props> {
</FormColumn>
<FormColumn>
<ConfigFormGroup
groupLabel="Tip Pickup / Drop "
groupLabel="Tip Pickup / Drop"
formFields={tipFields}
/>
{this.props.showHiddenFields && (
Expand Down
12 changes: 7 additions & 5 deletions components/src/forms/CheckboxField.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Props = {
value?: boolean,
/** classes to apply */
className?: string,
/** classes to apply to inner label text div */
labelTextClassName?: ?string,
/** name of field in form */
name?: string,
/** label text for checkbox */
Expand All @@ -27,21 +29,21 @@ type Props = {

export default function CheckboxField (props: Props) {
const error = props.error != null
const labelClassName = cx(
const outerClassName = cx(
styles.form_field,
props.className,
{[styles.checkbox_disabled]: props.disabled})

const innerClassName = cx(
const innerDivClassName = cx(
styles.checkbox_icon,
{
[styles.error]: error,
[styles.checkbox_disabled]: props.disabled,
})

return (
<label className={labelClassName}>
<div className={innerClassName}>
<label className={outerClassName}>
<div className={innerDivClassName}>
<Icon name={props.value ? 'checkbox-marked' : 'checkbox-blank-outline'} width='100%' />
</div>
<input
Expand All @@ -52,7 +54,7 @@ export default function CheckboxField (props: Props) {
disabled={props.disabled}
onChange={props.onChange}
/>
<div {...props.hoverTooltipHandlers} className={styles.label_text}>
<div {...props.hoverTooltipHandlers} className={cx(props.labelTextClassName, styles.label_text)}>
{props.label}
</div>
</label>
Expand Down
4 changes: 2 additions & 2 deletions components/src/forms/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export default function FormGroup (props: Props) {

return (
<div className={className}>
<div {...props.hoverTooltipHandlers} className={styles.form_group_label}>
{props.label && <div {...props.hoverTooltipHandlers} className={styles.form_group_label}>
{error &&
<div className={styles.error_icon}>
<Icon name='alert' />
</div>
}
{props.label}
</div>
</div>}
{props.children}
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions components/src/forms/InputField.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ type Props = {
disabled?: boolean,
/** change handler */
onChange?: (event: SyntheticInputEvent<*>) => mixed,
/** classes to apply */
/** classes to apply to outer element */
className?: string,
/** inline label text. DEPRECATED */
label?: string,
/** classes to apply to inner label text div */
labelTextClassName?: ?string,
/** name of field in form */
name?: string,
/** optional ID of <input> element */
Expand Down Expand Up @@ -64,7 +66,7 @@ export default function InputField (props: Props) {

return (
<label className={labelClass}>
<div className={styles.label_text}>
<div className={cx(props.labelTextClassName, styles.label_text)}>
{props.label &&
error && (
<div className={styles.error_icon}>
Expand Down
7 changes: 5 additions & 2 deletions components/src/forms/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ type Props = {
}>,
/** Show radio buttons inline instead of stacked */
inline?: boolean,
/** classes to apply */
/** classes to apply to outer div */
className?: string,
/** classes to apply to inner label text div */
labelTextClassName?: ?string,
/** if is included, RadioGroup will use error style. The content of the string is ignored. */
error?: ?string,
}
Expand Down Expand Up @@ -56,7 +58,8 @@ export default function RadioGroup (props: Props) {
checked={radio.value === props.value}
onChange={props.onChange}
/>
<div className={styles.label_text}>{radio.name}</div>
<div className={cx(props.labelTextClassName, styles.label_text)}>
{radio.name}</div>
{radio.children}
</label>
)}
Expand Down
5 changes: 5 additions & 0 deletions components/src/forms/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@

font-weight: var(--fw-semibold);
margin-bottom: 0.15rem;
text-transform: capitalize;

&::after {
content: ":";
}
}

.checkbox_icon {
Expand Down
11 changes: 6 additions & 5 deletions protocol-designer/src/components/FilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type State = { isEditPipetteModalOpen: boolean }
const DATE_ONLY_FORMAT = 'MMM DD, YYYY'
const DATETIME_FORMAT = 'MMM DD, YYYY | h:mm A'

// TODO: Ian 2019-03-15 use i18n for labels
class FilePage extends React.Component<Props, State> {
state = {isEditPipetteModalOpen: false}

Expand All @@ -56,17 +57,17 @@ class FilePage extends React.Component<Props, State> {
render={({handleBlur, handleChange, handleSubmit, dirty, errors, setFieldValue, touched, values}) => (
<form onSubmit={handleSubmit} className={styles.card_content}>
<div className={cx(formStyles.row_wrapper, formStyles.stacked_row)}>
<FormGroup label='Date Created:' className={formStyles.column_1_2}>
<FormGroup label='Date Created' className={formStyles.column_1_2}>
{values.created && moment(values.created).format(DATE_ONLY_FORMAT)}
</FormGroup>

<FormGroup label='Last Exported:' className={formStyles.column_1_2}>
<FormGroup label='Last Exported' className={formStyles.column_1_2}>
{values['last-modified'] && moment(values['last-modified']).format(DATETIME_FORMAT)}
</FormGroup>
</div>

<div className={cx(formStyles.row_wrapper, formStyles.stacked_row)}>
<FormGroup label='Protocol Name:' className={formStyles.column_1_2}>
<FormGroup label='Protocol Name' className={formStyles.column_1_2}>
<InputField
placeholder='Untitled'
name='protocol-name'
Expand All @@ -75,15 +76,15 @@ class FilePage extends React.Component<Props, State> {
/>
</FormGroup>

<FormGroup label='Organization/Author:' className={formStyles.column_1_2}>
<FormGroup label='Organization/Author' className={formStyles.column_1_2}>
<InputField
name='author'
onChange={handleChange}
value={values.author} />
</FormGroup>
</div>

<FormGroup label='Description:' className={formStyles.stacked_row}>
<FormGroup label='Description' className={formStyles.stacked_row}>
<InputField
name='description'
value={values.description}
Expand Down
3 changes: 2 additions & 1 deletion protocol-designer/src/components/IngredientsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react'

import {IconButton, SidePanel, swatchColors} from '@opentrons/components'
import {sortWells} from '@opentrons/shared-data'
import i18n from '../../localization'
import {PDTitledList, PDListItem} from '../lists'
import StepDescription from '../StepDescription'
import LabwareDetailsCard from './LabwareDetailsCard'
Expand Down Expand Up @@ -71,7 +72,7 @@ class IngredGroupCard extends React.Component<CardProps, CardState> {
>
<PDListItem className={styles.ingredient_row_header}>
<span>Well</span>
<span>μL</span>
<span>{i18n.t('application.units.microliter')}</span>
<span>Name</span>
<span />
</PDListItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import i18n from '../../localization'
import styles from './LiquidPlacementForm.css'
import formStyles from '../forms/forms.css'
import stepEditFormStyles from '../StepEditForm/StepEditForm.css'
import type {Options} from '@opentrons/components'

export type ValidFormValues = {
Expand Down Expand Up @@ -100,6 +101,7 @@ export default class LiquidPlacementForm extends React.Component <Props> {
className={styles.liquid_field}>
<DropdownField
name='selectedLiquidId'
className={stepEditFormStyles.large_field}
options={liquidSelectionOptions}
error={touched.selectedLiquidId && errors.selectedLiquidId}
value={values.selectedLiquidId}
Expand All @@ -113,7 +115,7 @@ export default class LiquidPlacementForm extends React.Component <Props> {
>
<InputField
name='volume'
units='μL'
units={i18n.t('application.units.microliter')}
error={touched.volume && errors.volume}
value={values.volume}
onChange={this.handleChangeVolume(setFieldValue)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function LiquidEditForm (props: Props) {
<div className={formStyles.header}>{i18n.t('form.liquid_edit.details')}</div>
<div className={formStyles.row_wrapper}>
<FormGroup
label={`${i18n.t('form.liquid_edit.name')}:`}
label={i18n.t('form.liquid_edit.name')}
className={formStyles.column_1_2}>
<InputField
name='name'
Expand All @@ -71,7 +71,7 @@ export default function LiquidEditForm (props: Props) {
/>
</FormGroup>
<FormGroup
label={`${i18n.t('form.liquid_edit.description')}:`}
label={i18n.t('form.liquid_edit.description')}
className={formStyles.column_1_2}>
<InputField
name='description'
Expand Down
6 changes: 3 additions & 3 deletions protocol-designer/src/components/StepEditForm/ButtonRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type Props = OP & SP & DP
const ButtonRow = (props: Props) => {
const {canSave, onDelete, onSave, onCancel, onClickMoreOptions} = props
return (
<div className={cx(styles.form_row, styles.form_footer)}>
<div className={styles.start_group}>
<div className={cx(styles.button_row, styles.form_wrapper, styles.form_footer)}>
<div>
<OutlineButton className={styles.form_button} onClick={onDelete}>DELETE</OutlineButton>
<OutlineButton className={styles.form_button} onClick={onClickMoreOptions}>NOTES</OutlineButton>
</div>
<div className={styles.end_group}>
<div>
<PrimaryButton className={styles.form_button} onClick={onCancel}>CLOSE</PrimaryButton>
<PrimaryButton className={styles.form_button} disabled={!canSave} onClick={onSave}>SAVE</PrimaryButton>
</div>
Expand Down
Loading

0 comments on commit 775ec4b

Please sign in to comment.