-
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.
Feature/us 20 add card view mode and translations (#73)
Co-authored-by: Samuel Poirier <[email protected]>
- Loading branch information
Showing
19 changed files
with
214 additions
and
143 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
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
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,26 @@ | ||
type Props = { | ||
readonly text: string, | ||
readonly checked: boolean, | ||
readonly onChange: (checked: boolean) => void, | ||
readonly additionalClassNames?: string, | ||
} | ||
|
||
const ToggleSwitch = ({ text, checked, onChange, additionalClassNames }: Props) => ( | ||
<div className={`form-check form-switch ${additionalClassNames ?? ''}`}> | ||
<input | ||
checked={checked} | ||
className={`form-check-input ${ | ||
checked | ||
? 'text-bg-primary' | ||
: '' | ||
}`} | ||
onChange={event => | ||
onChange(event.target.checked)} | ||
role='switch' | ||
type='checkbox' | ||
/> | ||
<label className='form-check-label'>{text}</label> | ||
</div> | ||
) | ||
|
||
export default ToggleSwitch |
83 changes: 58 additions & 25 deletions
83
canopeum_frontend/src/components/site/SiteSummaryCard.tsx
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 |
---|---|---|
@@ -1,40 +1,73 @@ | ||
import headerLogo from '@assets/images/map/MARR4059.png' | ||
import ToggleSwitch from '@components/inputs/ToggleSwitch' | ||
import PrimaryIconBadge from '@components/PrimaryIconBadge' | ||
import type { SiteSocial } from '@services/api' | ||
import { useEffect, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
type Props = { | ||
readonly viewMode: 'admin' | 'user' | 'visitor', | ||
readonly site: SiteSocial, | ||
} | ||
|
||
const SiteSummaryCard = ({ site }: Props) => ( | ||
<div className='card mb-3'> | ||
<div className='row g-0'> | ||
<div className='col-md-4'> | ||
{/* TODO: replace img source when backend offers an image endpoint */} | ||
<img alt='header logo' className='img-fluid' src={headerLogo} /> | ||
</div> | ||
<div className='col-md-8'> | ||
<div className='card-body'> | ||
<h1 className='fw-bold card-title'>{site.name}</h1> | ||
<div className='card-text d-flex flex-row gap-1'> | ||
<PrimaryIconBadge type='school' /> | ||
<h4 className='fw-bold text-primary'>{site.type.en}</h4> | ||
</div> | ||
<p className='card-text'>{site.description ?? ''}</p> | ||
<div className='container fw-bold'> | ||
<div className='mb-2'> | ||
<span className='material-symbols-outlined align-middle'>person</span> | ||
<span>Sponsors:</span> | ||
const onFollowClick = () => { | ||
// TODO implement follow here when backend is available | ||
} | ||
|
||
const updateSiteIsPublic = async (_: boolean) => { | ||
// TODO Implement site update when backend is ready | ||
} | ||
const SiteSummaryCard = ({ site, viewMode }: Props) => { | ||
const { t } = useTranslation() | ||
const [isPublic, setIsPublic] = useState(true) | ||
|
||
useEffect(() => void updateSiteIsPublic(isPublic), [isPublic]) | ||
|
||
return ( | ||
<div className='card mb-3'> | ||
<div className='row g-0'> | ||
<div className='col-md-4'> | ||
{/* TODO: replace img source when backend offers an image endpoint */} | ||
<img alt='header logo' className='img-fluid' src={headerLogo} /> | ||
</div> | ||
<div className='col-md-8'> | ||
<div className='card-body'> | ||
<div className='d-flex flex-row justify-content-between'> | ||
<h1 className='fw-bold card-title'>{site.name}</h1> | ||
{viewMode === 'user' && ( | ||
<button className='btn btn-secondary' onClick={onFollowClick} type='button'> | ||
{t('mapSite.siteSummaryCard.follow')} | ||
</button> | ||
)} | ||
{viewMode === 'admin' && ( | ||
<ToggleSwitch | ||
additionalClassNames='fs-4' | ||
checked={isPublic} | ||
onChange={setIsPublic} | ||
text={t('mapSite.siteSummaryCard.public')} | ||
/> | ||
)} | ||
</div> | ||
<div className='row'> | ||
{site.sponsors.map(sponsorName => ( | ||
<div className='col-12 col-sm-6 col-md-4 col-lg-3 mb-3' key={sponsorName}>{sponsorName}</div> | ||
))} | ||
<div className='card-text d-flex flex-row gap-1'> | ||
<PrimaryIconBadge type='school' /> | ||
<h4 className='fw-bold text-primary'>{site.type.en}</h4> | ||
</div> | ||
<p className='card-text'>{site.description ?? ''}</p> | ||
<div className='container fw-bold'> | ||
<div className='mb-2'> | ||
<span className='material-symbols-outlined align-middle'>person</span> | ||
<span>{t('mapSite.siteSummaryCard.sponsors')}:</span> | ||
</div> | ||
<div className='row'> | ||
{site.sponsors.map(sponsorName => ( | ||
<div className='col-12 col-sm-6 col-md-4 col-lg-3 mb-3' key={sponsorName}>{sponsorName}</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
) | ||
} | ||
export default SiteSummaryCard |
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,7 @@ | ||
{ | ||
"siteSummaryCard": { | ||
"follow": "Follow", | ||
"sponsors": "Sponsors", | ||
"public": "Public" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"siteSummaryCard": { | ||
"follow": "Suivre", | ||
"sponsors": "Commanditaires", | ||
"public": "Publique" | ||
} | ||
} |
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
Oops, something went wrong.