-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add single agency radio select component
- Loading branch information
1 parent
b1e08d3
commit 4de682b
Showing
12 changed files
with
224 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import './agencyRadioSelect.styles'; | ||
import { AgencyDataInterface } from '../../globalState/interfaces'; | ||
import { Headline } from '../headline/Headline'; | ||
import { RadioButton } from '../radioButton/RadioButton'; | ||
import { InfoTooltip } from '../infoTooltip/InfoTooltip'; | ||
import { AgencyLanguages } from './AgencyLanguages'; | ||
import clsx from 'clsx'; | ||
|
||
interface AgencyRadioSelectProps { | ||
agency: AgencyDataInterface; | ||
checkedValue: string; | ||
showTooltipAbove?: boolean; | ||
prefix?: string; | ||
onChange?: (agency: AgencyDataInterface) => void; | ||
onKeyDown?: (event: KeyboardEvent) => void; | ||
} | ||
|
||
export const AgencyRadioSelect = ({ | ||
checkedValue, | ||
onChange, | ||
onKeyDown, | ||
agency, | ||
prefix, | ||
showTooltipAbove = false | ||
}: AgencyRadioSelectProps) => { | ||
const { t } = useTranslation('agencies'); | ||
const agencyIdAsString = agency.id.toString(); | ||
|
||
return ( | ||
<div className="agencyRadioSelect__wrapper"> | ||
{prefix && ( | ||
<Headline semanticLevel="4" styleLevel="5" text={prefix} /> | ||
)} | ||
<div | ||
className={clsx('agencyRadioSelect__radioContainer', { | ||
'agencyRadioSelect__radioContainer--withHeadline': !!prefix | ||
})} | ||
> | ||
<RadioButton | ||
name="agencySelection" | ||
handleRadioButton={() => onChange && onChange(agency)} | ||
onKeyDown={(e: KeyboardEvent) => onKeyDown && onKeyDown(e)} | ||
type="smaller" | ||
value={agencyIdAsString} | ||
checked={agencyIdAsString === checkedValue} | ||
inputId={`agency-${agencyIdAsString}`} | ||
> | ||
{t([`agency.${agencyIdAsString}.name`, agency.name])} | ||
</RadioButton> | ||
|
||
<InfoTooltip | ||
translation={{ | ||
ns: 'agencies', | ||
prefix: 'agency' | ||
}} | ||
info={agency} | ||
showTeamAgencyInfo={agency.teamAgency} | ||
isProfileView={showTooltipAbove} | ||
/> | ||
</div> | ||
|
||
<div className="agencyRadioSelect__content"> | ||
{agency.agencyLogo && ( | ||
<img | ||
className="agencyRadioSelect__logo" | ||
src={agency.agencyLogo} | ||
alt={t([ | ||
`agency.${agencyIdAsString}.name`, | ||
agency.name | ||
])} | ||
/> | ||
)} | ||
<AgencyLanguages agencyId={agency.id} /> | ||
</div> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
59 changes: 59 additions & 0 deletions
59
src/components/agencyRadioSelect/agencyRadioSelect.styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
$infoIconSize: 16px; | ||
|
||
.agencyRadioSelect { | ||
position: relative; | ||
width: 100%; | ||
|
||
&__wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
padding: 12px 0; | ||
|
||
.radioButton { | ||
flex-basis: calc(100% - #{$infoIconSize + 1px}); | ||
min-height: unset; | ||
padding: 4px 0 4px 4px; | ||
|
||
&__label { | ||
font-size: 16px; | ||
padding-left: 16px; | ||
} | ||
|
||
&__contentWrapper { | ||
align-items: center; | ||
} | ||
} | ||
|
||
&:not(:last-of-type) { | ||
border-bottom: 1px solid $black-10-opacity; | ||
} | ||
|
||
& > .headline { | ||
margin-left: $registration-form-margin-left; | ||
} | ||
} | ||
|
||
&__radioContainer { | ||
display: flex; | ||
|
||
&--withHeadline { | ||
margin-top: 12px; | ||
} | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-start; | ||
margin-left: 44px; | ||
} | ||
|
||
&__logo { | ||
max-width: 60px; | ||
max-height: 60px; | ||
margin-right: 16px; | ||
object-fit: contain; | ||
object-position: center left; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.