Skip to content

Commit

Permalink
reduce redundancy in HelpCol
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Apr 15, 2024
1 parent 70b1500 commit ba69e4d
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions src/fragmentarium/ui/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import React, { Component } from 'react'
import LuckyButton from 'fragmentarium/ui/front-page/LuckyButton'
import PioneersButton from 'fragmentarium/ui/PioneersButton'
import { withRouter, RouteComponentProps } from 'react-router-dom'
import { Button, ButtonToolbar, Col, Form, Row } from 'react-bootstrap'
import {
Button,
ButtonToolbar,
Col,
Form,
OverlayTriggerProps,
Row,
} from 'react-bootstrap'
import { stringify } from 'query-string'
import BibliographySelect from 'bibliography/ui/BibliographySelect'
import HelpTrigger from 'common/HelpTrigger'
Expand Down Expand Up @@ -70,14 +77,17 @@ export function isValidNumber(number?: string): boolean {

export const helpColSize = 1

function HelpCol({ ...props }): JSX.Element {
function HelpCol({
...props
}: Pick<OverlayTriggerProps, 'overlay'>): JSX.Element {
return (
<Col
sm={helpColSize}
as={Form.Label}
className="TransliterationSearchForm__label"
{...props}
/>
>
<HelpTrigger {...props} />
</Col>
)
}

Expand Down Expand Up @@ -181,9 +191,7 @@ class SearchForm extends Component<SearchFormProps, State> {
<>
<Form>
<Form.Group as={Row} controlId="number">
<HelpCol>
<HelpTrigger overlay={MuseumSearchHelp()} />
</HelpCol>
<HelpCol overlay={MuseumSearchHelp()} />
<Col>
<Form.Control
type="text"
Expand All @@ -202,9 +210,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="reference">
<HelpCol>
<HelpTrigger overlay={ReferenceSearchHelp()} />
</HelpCol>
<HelpCol overlay={ReferenceSearchHelp()} />
<Col>
<BibliographySelect
isClearable={true}
Expand All @@ -230,9 +236,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="period">
<HelpCol>
<HelpTrigger overlay={ScriptSearchHelp()} />
</HelpCol>
<HelpCol overlay={ScriptSearchHelp()} />
<Col>
<PeriodModifierSearchForm
onChange={this.onChange('scriptPeriodModifier')}
Expand All @@ -248,9 +252,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="site">
<HelpCol>
<HelpTrigger overlay={ProvenanceSearchHelp()} />
</HelpCol>
<HelpCol overlay={ProvenanceSearchHelp()} />
<Col>
<ProvenanceSearchForm
fragmentService={this.props.fragmentService}
Expand All @@ -260,9 +262,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="genre">
<HelpCol>
<HelpTrigger overlay={GenreSearchHelp()} />
</HelpCol>
<HelpCol overlay={GenreSearchHelp()} />
<Col>
<GenreSearchForm
fragmentService={this.props.fragmentService}
Expand All @@ -272,9 +272,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="lemmas">
<HelpCol>
<HelpTrigger overlay={LemmaSearchHelp()} />
</HelpCol>
<HelpCol overlay={LemmaSearchHelp()} />
<Col>
<LemmaSearchForm
wordService={this.props.wordService}
Expand All @@ -290,9 +288,7 @@ class SearchForm extends Component<SearchFormProps, State> {
</Col>
</Form.Group>
<Form.Group as={Row} controlId="transliteration">
<HelpCol>
<HelpTrigger overlay={TransliterationSearchHelp()} />
</HelpCol>
<HelpCol overlay={TransliterationSearchHelp()} />
<Col sm={12 - helpColSize}>
<Form.Control
as="textarea"
Expand Down

0 comments on commit ba69e4d

Please sign in to comment.