Skip to content

Commit

Permalink
chore: update components import (#399)
Browse files Browse the repository at this point in the history
* rename the folder 'input' to 'inputs', 'RadioInput' to 'Radio' and 'file.tsx' to 'file-input.tsx'.

* Update component imports

* Rename from 'inputs' to 'form'.
  • Loading branch information
jonasbrunvoll authored Oct 21, 2024
1 parent 6e61828 commit 9916bd7
Show file tree
Hide file tree
Showing 32 changed files with 130 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type CheckboxProps = {
onClick?: () => void;
};

export function Checkbox({
export default function Checkbox({
onChange,
error,
disabled = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type FileInputProps = {

const MAX_ALLOWED_FILE_SIZE = 10 * 1024 * 1024; // 10MB

export function FileInput({ onChange, label, name }: FileInputProps) {
export default function FileInput({ onChange, label, name }: FileInputProps) {
const { t } = useTranslation();
const id = useId();
const { static: staticColors } = useTheme();
Expand Down
13 changes: 13 additions & 0 deletions src/page-modules/contact/components/form/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export { default as Checkbox } from './checkbox';
export { default as DescriptionModal } from './description-modal';
export { default as ErrorMessage } from './error-message';
export { default as FileInput } from './file-input';
export { default as Input } from './input';
export { default as Radio } from './radio';
export { default as Select } from './select';
export { default as Textarea } from './textarea';
export {
SearchableSelect,
getLineOptions,
getStopOptions,
} from './searchable-select';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type RadioInputProps = {
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
} & JSX.IntrinsicElements['input'];

export function RadioInput({
export default function Radio({
onChange,
checked,
label,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as SearchableSelect } from './searchable-select';
export { getLineOptions, getStopOptions } from './utils';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Line } from '@atb/page-modules/contact';
import { Option } from './index';
import { Option } from './searchable-select';

export const getLineOptions = (lines: Line[]): Option<Line>[] => {
return lines.map((line) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type CheckboxProps = {
value: string;
};

export function Textarea({ onChange, error, value }: CheckboxProps) {
export default function Textarea({ onChange, error, value }: CheckboxProps) {
return (
<div>
<textarea className={style.textarea} value={value} onChange={onChange} />
Expand Down
14 changes: 14 additions & 0 deletions src/page-modules/contact/components/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export {
Checkbox,
DescriptionModal,
ErrorMessage,
FileInput,
Input,
Radio,
Select,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from './form';
export { SectionCard } from './section-card';
1 change: 0 additions & 1 deletion src/page-modules/contact/components/input/index.ts

This file was deleted.

16 changes: 8 additions & 8 deletions src/page-modules/contact/group-travel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useMachine } from '@xstate/react';
import { groupTravelStateMachine } from './group-travel-state-machine';
import { SectionCard } from '../components/section-card';
import { PageText, useTranslation } from '@atb/translations';
import style from '../contact.module.css';
import { RadioInput } from '../components/input/radio';
import { Typo } from '@atb/components/typography';
import { useLines } from '../lines/use-lines';
import { Line } from '../server/journey-planner/validators';
import { Input } from '../components/input';
import { Textarea } from '../components/input/textarea';
import { Button } from '@atb/components/button';
import SearchableSelect from '../components/input/searchable-select';
import {
Radio,
Textarea,
Input,
SectionCard,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../components/input/searchable-select/utils';
} from '../components';

export default function GroupTravelContent() {
const { t } = useTranslation();
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function GroupTravelContent() {
<SectionCard title={t(PageText.Contact.groupTravel.title)}>
<ul className={style.form_options__list}>
<li>
<RadioInput
<Radio
label={t(PageText.Contact.groupTravel.travelTypeBus.radioLabel)}
value={'bus'}
checked={travelType === 'bus'}
Expand All @@ -52,7 +52,7 @@ export default function GroupTravelContent() {
/>
</li>
<li>
<RadioInput
<Radio
label={t(PageText.Contact.groupTravel.travelTypeBoat.radioLabel)}
value={'boat'}
checked={travelType === 'boat'}
Expand Down
15 changes: 8 additions & 7 deletions src/page-modules/contact/means-of-transport/forms/delayForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { PageText, useTranslation } from '@atb/translations';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { ContextProps } from '../means-of-transport-form-machine';
import { meansOfTransportFormEvents } from '../events';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type DelayFormProps = {
state: { context: ContextProps };
send: (event: typeof meansOfTransportFormEvents) => void;
Expand Down
14 changes: 7 additions & 7 deletions src/page-modules/contact/means-of-transport/forms/driverForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { PageText, useTranslation } from '@atb/translations';
import { ContextProps } from '../means-of-transport-form-machine';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { meansOfTransportFormEvents } from '../events';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type DriverFormProps = {
state: { context: ContextProps };
Expand Down
14 changes: 7 additions & 7 deletions src/page-modules/contact/means-of-transport/forms/injuryForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { PageText, useTranslation } from '@atb/translations';
import { ContextProps } from '../means-of-transport-form-machine';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { meansOfTransportFormEvents } from '../events';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type InjuryFormProps = {
state: { context: ContextProps };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { PageText, useTranslation } from '@atb/translations';
import { ContextProps } from '../means-of-transport-form-machine';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { meansOfTransportFormEvents } from '../events';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type ServiceOfferingFormProps = {
state: { context: ContextProps };
Expand Down
14 changes: 7 additions & 7 deletions src/page-modules/contact/means-of-transport/forms/stopForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { PageText, useTranslation } from '@atb/translations';
import { ContextProps } from '../means-of-transport-form-machine';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { meansOfTransportFormEvents } from '../events';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type StopFormProps = {
state: { context: ContextProps };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { PageText, useTranslation } from '@atb/translations';
import { ContextProps } from '../means-of-transport-form-machine';
import { useLines } from '../../lines/use-lines';
import { SectionCard } from '../../components/section-card';
import { Typo } from '@atb/components/typography';
import Select from '../../components/input/select';
import { ComponentText } from '@atb/translations';
import { Input } from '../../components/input';
import { TransportModeType } from '@atb-as/config-specs';
import { Line } from '../..';
import { FileInput } from '../../components/input/file';
import { Textarea } from '../../components/input/textarea';
import { meansOfTransportFormEvents } from '../events';
import { Checkbox } from '../../components/input/checkbox';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Select,
Input,
FileInput,
Textarea,
Checkbox,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type TransportationFormProps = {
state: { context: ContextProps };
Expand Down
5 changes: 2 additions & 3 deletions src/page-modules/contact/means-of-transport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
import { Button } from '@atb/components/button';
import { PageText, useTranslation } from '@atb/translations';
import { FormEventHandler, useState } from 'react';
import { SectionCard } from '../components/section-card';
import { RadioInput } from '../components/input/radio';
import { Radio, SectionCard } from '../components';
import style from '../contact.module.css';

const MeansOfTransportContent = () => {
Expand All @@ -41,7 +40,7 @@ const MeansOfTransportContent = () => {
<ul className={style.form_options__list}>
{Object.values(FormType).map((formType) => (
<li key={formType}>
<RadioInput
<Radio
label={t(
PageText.Contact.modeOfTransport[formType].description,
)}
Expand Down
19 changes: 10 additions & 9 deletions src/page-modules/contact/ticket-control/forms/feeComplaintForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import style from '../../contact.module.css';
import { Input } from '../../components/input';
import { SectionCard } from '../../components/section-card';
import { PageText, TranslatedString, useTranslation } from '@atb/translations';
import { Checkbox } from '../../components/input/checkbox';
import { Typo } from '@atb/components/typography';
import { RadioInput } from '../../components/input/radio';
import { Textarea } from '../../components/input/textarea';
import ErrorMessage from '../../components/input/error-message';
import { FileInput } from '../../components/input/file';
import { ContextProps } from '../ticket-control-form-machine';
import { ticketControlFormEvents } from '../events';
import {
Input,
SectionCard,
Checkbox,
Radio,
Textarea,
FileInput,
} from '../../components';

type FeeComplaintFormProps = {
state: { context: ContextProps };
Expand Down Expand Up @@ -132,7 +133,7 @@ const FormContent = ({ state, send }: FormProps) => {
)}
</Typo.h3>

<RadioInput
<Radio
label={t(
PageText.Contact.ticketControl.feeComplaint.ticketStorage.app.title,
)}
Expand All @@ -146,7 +147,7 @@ const FormContent = ({ state, send }: FormProps) => {
})
}
/>
<RadioInput
<Radio
label={t(PageText.Contact.input.travelCardNumber.label)}
name="isAppTicketStorageMode"
checked={!state.context.isAppTicketStorageMode}
Expand Down
14 changes: 7 additions & 7 deletions src/page-modules/contact/ticket-control/forms/feedbackForm.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { SectionCard } from '../../components/section-card';
import { ComponentText, PageText, useTranslation } from '@atb/translations';
import { TransportModeType } from '@atb-as/config-specs';
import { Input } from '../../components/input';
import { Line } from '../..';
import { Textarea } from '../../components/input/textarea';
import { Typo } from '@atb/components/typography';
import { FileInput } from '../../components/input/file';
import { ticketControlFormEvents } from '../events';
import { ContextProps } from '../ticket-control-form-machine';
import Select from '../../components/input/select';
import { useLines } from '../../lines/use-lines';
import SearchableSelect from '../../components/input/searchable-select';
import {
SectionCard,
Input,
Textarea,
FileInput,
Select,
SearchableSelect,
getLineOptions,
getStopOptions,
} from '../../components/input/searchable-select/utils';
} from '../../components';

type FeedbackFormProps = {
state: { context: ContextProps };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Input } from '../../components/input';
import { SectionCard } from '../../components/section-card';
import { Input, SectionCard } from '../../components';
import { PageText, useTranslation } from '@atb/translations';
import { ticketControlFormEvents } from '../events';
import { ContextProps } from '../ticket-control-form-machine';
Expand Down
Loading

0 comments on commit 9916bd7

Please sign in to comment.