Skip to content

Commit b0373ba

Browse files
committed
fix: required field
1 parent 57a83ad commit b0373ba

8 files changed

Lines changed: 33 additions & 29 deletions

File tree

src/components/form/Select.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
'use client'
22

33
import classNames from 'classnames'
4-
import React, { SelectHTMLAttributes } from 'react'
4+
import { SelectHTMLAttributes } from 'react'
55
import styles from './Input.module.css'
66

77
export type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
88
id: string
99
label?: string
1010
inline?: boolean
1111
hint?: string
12+
withoutColon?: boolean
1213
padding?: 'sm' | 'lg'
1314
}
1415

15-
const Select = ({ id, label, hint, inline, padding, className, children, ...selectProps }: SelectProps) => {
16+
const Select = ({
17+
id,
18+
label,
19+
hint,
20+
inline,
21+
padding,
22+
className,
23+
children,
24+
withoutColon,
25+
...selectProps
26+
}: SelectProps) => {
1627
return (
1728
<div className={inline ? styles.containerInline : styles.container}>
1829
{label && (
1930
<label className={classNames(styles.label, { [styles.labelInline]: inline })} htmlFor={`text-select-${id}`}>
2031
{label}
21-
{selectProps.required && <span className={styles.required}> *</span>} :
32+
{selectProps.required && <span className={styles.required}> *</span>}
33+
{withoutColon ? '' : ' :'}
2234
{hint && <span className={classNames(styles.hint, 'text-sm')}>{hint}</span>}
2335
</label>
2436
)}

src/components/form/addresses/AddressInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const AddressInput = ({
5858
{label && (
5959
<label className={classNames(inputStyles.label, { [inputStyles.labelError]: !!error })} htmlFor={`input-${id}`}>
6060
{label}
61-
{inputProps.required && <span className={inputStyles.required}> *</span>}
6261
{hint && <span className={classNames(inputStyles.hint, 'text-sm')}>{hint}</span>}
6362
</label>
6463
)}

src/components/outils/ItineraireSimulator.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ const ItineraireSimulator = ({ withComparisonMode }: { withComparisonMode: boole
2929
<div className={styles.simulator}>
3030
<p>{t('header')}</p>
3131
<div className={styles.addresses}>
32-
<AddressInput
33-
large
34-
id='itineraire-start'
35-
label={t('start')}
36-
required
37-
place={start?.address}
38-
setPlace={setStart}
39-
/>
40-
<AddressInput large id='itineraire-end' label={t('end')} required place={end?.address} setPlace={setEnd} />
32+
<AddressInput large id='itineraire-start' label={t('start')} place={start?.address} setPlace={setStart} />
33+
<AddressInput large id='itineraire-end' label={t('end')} place={end?.address} setPlace={setEnd} />
4134
</div>
4235
<div className={styles.roundTrip}>
4336
<CheckboxInput id='roundTrip' label={t('roundTrip')} checked={roundTrip} setChecked={setRoundTrip} />

src/components/outils/TeletravailSimulator.module.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
.transportMode {
2222
width: 100%;
2323

24+
label {
25+
width: 100%;
26+
}
2427
select {
2528
max-width: 100%;
2629
}

src/components/outils/TeletravailSimulator.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useTranslations } from 'next-intl'
44
import Image from 'next/image'
5-
import React, { useEffect, useMemo, useRef } from 'react'
5+
import { useEffect, useMemo, useRef } from 'react'
66
import useParamContext from 'src/providers/ParamProvider'
77
import { Category } from 'types/category'
88
import { ComputedEquivalent, DeplacementType } from 'types/equivalent'
@@ -67,19 +67,11 @@ const TeletravailSimulator = () => {
6767
<>
6868
<form id='teletravail-simulator' className={styles.simulator}>
6969
<div className={itineraireStyles.addresses}>
70-
<AddressInput
71-
large
72-
id='teletravail-start'
73-
label={t('start')}
74-
required
75-
place={start?.address}
76-
setPlace={setStart}
77-
/>
78-
<AddressInput large id='teletravail-end' label={t('end')} required place={end?.address} setPlace={setEnd} />
70+
<AddressInput large id='teletravail-start' label={t('start')} place={start?.address} setPlace={setStart} />
71+
<AddressInput large id='teletravail-end' label={t('end')} place={end?.address} setPlace={setEnd} />
7972
</div>
8073
<div className={styles.transportMode}>
8174
<SelectEquivalent
82-
required
8375
label={t('mode')}
8476
id='mode'
8577
value={transport}
@@ -88,6 +80,7 @@ const TeletravailSimulator = () => {
8880
setTransport(event.target.value)
8981
}}
9082
equivalents={deplacements}
83+
withoutColon
9184
/>
9285
</div>
9386
<div className={itineraireStyles.days}>

src/components/outils/equivalents/simulators/UsageNumeriqueEquivalentSimulator.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import classNames from 'classnames'
44
import { useTranslations } from 'next-intl'
5-
import React, { useMemo } from 'react'
5+
import { useMemo } from 'react'
66
import useParamContext from 'src/providers/ParamProvider'
77
import useUsageNumeriqueContext from 'src/providers/UsageNumeriqueProvider'
88
import { Category } from 'types/category'
@@ -179,7 +179,6 @@ const UsageNumeriqueEquivalentSimulator = ({ slug }: { slug: 'visio' | 'email' |
179179
</div>
180180
<div>
181181
<Radio
182-
required
183182
className={baseStyles.radio}
184183
id='radio-construction'
185184
label={

src/components/outils/usageNumerique/UsageForm.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
> div {
1717
max-width: 50%;
1818
width: 100%;
19+
20+
> div {
21+
align-items: flex-start;
22+
width: 100%;
23+
}
1924
}
2025

2126
input {

src/components/shareable/overScreens/TransportShare.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useTranslations } from 'next-intl'
4-
import React, { useMemo, useState } from 'react'
4+
import { useMemo, useState } from 'react'
55
import useParamContext from 'src/providers/ParamProvider'
66
import { Category } from 'types/category'
77
import { TransportSimulateur } from 'types/transport'
@@ -94,7 +94,7 @@ const TransportShare = () => {
9494
return selected ? (
9595
<>
9696
<form id='transport-share'>
97-
<Radio required id='tabs' label={t('onglet')} hint={t('onglet-hint')}>
97+
<Radio id='tabs' label={t('onglet')} hint={t('onglet-hint')}>
9898
<RadioInput
9999
value='distance'
100100
selected={selected}
@@ -132,7 +132,7 @@ const TransportShare = () => {
132132
/>
133133
)}
134134
<div className={styles.separator} />
135-
<Radio required id='comparisonModes' label={t('mode-share')}>
135+
<Radio id='comparisonModes' label={t('mode-share')}>
136136
<RadioInput
137137
value='list'
138138
selected={comparisonMode}

0 commit comments

Comments
 (0)