feat: change some icons

This commit is contained in:
Sonny
2023-12-16 22:52:34 +01:00
parent e8f2d80e6a
commit 8b86fbfd7f
7 changed files with 53 additions and 16 deletions

1
public/icons/en.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><clipPath id="a"><path d="M0 0v30h60V0z"/></clipPath><clipPath id="b"><path d="M30 15h30v15zv15H0zH0V0zV0h30z"/></clipPath><g clip-path="url(#a)"><path d="M0 0v30h60V0z" fill="#012169"/><path d="M0 0l60 30m0-30L0 30" stroke="#fff" stroke-width="6"/><path d="M0 0l60 30m0-30L0 30" clip-path="url(#b)" stroke="#C8102E" stroke-width="4"/><path d="M30 0v30M0 15h60" stroke="#fff" stroke-width="10"/><path d="M30 0v30M0 15h60" stroke="#C8102E" stroke-width="6"/></g></svg>

After

Width:  |  Height:  |  Size: 527 B

1
public/icons/fr.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3 2"><path fill="#EC1920" d="M0 0h3v2H0z"/><path fill="#fff" d="M0 0h2v2H0z"/><path fill="#051440" d="M0 0h1v2H0z"/></svg>

After

Width:  |  Height:  |  Size: 175 B

View File

@@ -33,7 +33,7 @@
"privacy": "Privacy", "privacy": "Privacy",
"terms": "Terms of use", "terms": "Terms of use",
"language": { "language": {
"fr": "French", "fr": "Français",
"en": "English" "en": "English"
}, },
"lang": "Language", "lang": "Language",

View File

@@ -34,7 +34,7 @@
"terms": "CGU", "terms": "CGU",
"language": { "language": {
"fr": "Français", "fr": "Français",
"en": "Anglais" "en": "English"
}, },
"lang": "Langage", "lang": "Langage",
"settings": "Paramètres", "settings": "Paramètres",

View File

@@ -1,8 +1,15 @@
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
import Image from 'next/image';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import Selector from './Selector'; import Selector from './Selector';
export default function LangSelector() { type Country = 'fr' | 'en';
export default function LangSelector({
onSelected,
}: {
onSelected?: (country: Country) => void;
}) {
const router = useRouter(); const router = useRouter();
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
@@ -17,11 +24,30 @@ export default function LangSelector() {
<Selector <Selector
name='lng-select' name='lng-select'
value={i18n.language} value={i18n.language}
onChangeCallback={(value: string) => onToggleLanguageClick(value)} onChangeCallback={(value: Country) => {
options={languages.map((lang: 'fr' | 'en') => ({ onToggleLanguageClick(value);
if (onSelected) {
setTimeout(() => onSelected(value), 150);
}
}}
options={languages.map((lang: Country) => ({
label: t(`common:language.${lang}`), label: t(`common:language.${lang}`),
value: lang, value: lang,
}))} }))}
formatOptionLabel={(country) => (
<div
className='country-option'
style={{ display: 'flex', gap: '.5em', alignItems: 'center' }}
>
<Image
src={`/icons/${country.value}.svg`}
alt='country-image'
height={24}
width={24}
/>
<span>{country.label}</span>
</div>
)}
/> />
); );
} }

View File

@@ -1,5 +1,5 @@
import { MutableRefObject, useEffect, useState } from 'react'; import { MutableRefObject, ReactNode, useEffect, useState } from 'react';
import Select, { OptionsOrGroups, GroupBase } from 'react-select'; import Select, { GroupBase, OptionsOrGroups } from 'react-select';
type Option = { label: string | number; value: string | number }; type Option = { label: string | number; value: string | number };
@@ -13,6 +13,7 @@ interface SelectorProps {
options: OptionsOrGroups<Option, GroupBase<Option>>; options: OptionsOrGroups<Option, GroupBase<Option>>;
value?: number | string; value?: number | string;
onChangeCallback?: (value: number | string) => void; onChangeCallback?: (value: number | string) => void;
formatOptionLabel?: (data: Option) => ReactNode;
disabled?: boolean; disabled?: boolean;
} }
@@ -26,6 +27,7 @@ export default function Selector({
value, value,
options = [], options = [],
onChangeCallback, onChangeCallback,
formatOptionLabel,
disabled = false, disabled = false,
}: SelectorProps): JSX.Element { }: SelectorProps): JSX.Element {
const [selectorValue, setSelectorValue] = useState<Option>(); const [selectorValue, setSelectorValue] = useState<Option>();
@@ -71,6 +73,9 @@ export default function Selector({
ref={innerRef} ref={innerRef}
isDisabled={disabled} isDisabled={disabled}
menuPlacement='auto' menuPlacement='auto'
formatOptionLabel={(value) =>
formatOptionLabel && formatOptionLabel(value)
}
/> />
</div> </div>
); );

View File

@@ -9,12 +9,15 @@ import { useTranslation } from 'next-i18next';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { FaUser } from 'react-icons/fa'; import { FaUser } from 'react-icons/fa';
import { IoLogOutOutline, IoSettingsOutline } from 'react-icons/io5'; import {
import { TfiWorld } from 'react-icons/tfi'; IoLanguageOutline,
IoLogOutOutline,
IoSettingsOutline,
} from 'react-icons/io5';
import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'; import { Tab, TabList, TabPanel, Tabs } from 'react-tabs';
import LangSelector from '../LangSelector'; import LangSelector from 'components/LangSelector';
import Modal from '../Modal/Modal'; import Modal from 'components/Modal/Modal';
import Profile from '../Profile/Profile'; import Profile from 'components/Profile/Profile';
import styles from './settings-modal.module.scss'; import styles from './settings-modal.module.scss';
export default function SettingsModal() { export default function SettingsModal() {
@@ -32,6 +35,7 @@ export default function SettingsModal() {
enableOnFormTags: ['INPUT'], enableOnFormTags: ['INPUT'],
}); });
const iconsSize = 22;
return ( return (
<> <>
<button <button
@@ -54,21 +58,21 @@ export default function SettingsModal() {
selectedClassName={styles['tab-selected']} selectedClassName={styles['tab-selected']}
disabledClassName={styles['tab-disabled']} disabledClassName={styles['tab-disabled']}
> >
<FaUser size={18} /> {t('common:profile')} <FaUser size={iconsSize} /> {t('common:profile')}
</Tab> </Tab>
<Tab <Tab
className={styles['tab']} className={styles['tab']}
selectedClassName={styles['tab-selected']} selectedClassName={styles['tab-selected']}
disabledClassName={styles['tab-disabled']} disabledClassName={styles['tab-disabled']}
> >
<TfiWorld size={18} /> {t('common:lang')} <IoLanguageOutline size={iconsSize} /> {t('common:lang')}
</Tab> </Tab>
<button <button
className={clsx('reset', styles['tab'])} className={clsx('reset', styles['tab'])}
style={{ color: 'red' }} style={{ color: 'red' }}
onClick={() => signOut({ callbackUrl: PATHS.LOGIN })} onClick={() => signOut({ callbackUrl: PATHS.LOGIN })}
> >
<IoLogOutOutline size={18} /> {t('common:logout')} <IoLogOutOutline size={iconsSize} /> {t('common:logout')}
</button> </button>
</TabList> </TabList>
@@ -83,7 +87,7 @@ export default function SettingsModal() {
selectedClassName={styles['tab-panel-selected']} selectedClassName={styles['tab-panel-selected']}
> >
<p>{t('common:select-your-lang')}</p> <p>{t('common:select-your-lang')}</p>
<LangSelector /> <LangSelector onSelected={modal.close} />
</TabPanel> </TabPanel>
</Tabs> </Tabs>
</Modal> </Modal>