Skip to content

Commit

Permalink
feat: create LanguageSwitcher component
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 27, 2023
1 parent a0e28d2 commit e434da5
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/(public)/about/work/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Image from 'next/image';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

import Heading from '@/components/atoms/Heading';
import Heading from '@/components/atoms/headings/Heading';
import Education from '@/components/organisms/about-work/Education';
import Intro from '@/components/organisms/about-work/Intro';
import Languages from '@/components/organisms/about-work/Languages';
Expand Down
73 changes: 73 additions & 0 deletions src/components/atoms/LanguageSwitcher/LanguageSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { InputLabel, MenuItem, Select, SelectChangeEvent } from '@mui/material';
import FormControl from '@mui/material/FormControl';
import { useState } from 'react';

// export interface LanguageSwitcherProps {
// language: string;
// }

interface Language {
label: string;
value: string;
enabled: boolean;
}

const languages: Language[] = [
{
label: '🇬🇧 EN',
value: 'en',
enabled: true,
},
{
label: '🇮🇹 IT',
value: 'it',
enabled: true,
},
{
label: '🇩🇪 DE',
value: 'de',
enabled: true,
},
];

const LanguageSwitcher = () => {
const [chosenLanguage, setChosenLanguage] = useState('');

const handleChange = (event: SelectChangeEvent) => {
setChosenLanguage(event.target.value);
};

const label = <>🌐</>;

return (
<div>
<FormControl sx={{ m: 1, minWidth: 80 }} size='small'>
<InputLabel id='demo-select-small-label'>{label}</InputLabel>
<Select
id='demo-select-small'
labelId='demo-select-small-label'
value={chosenLanguage}
label={label}
onChange={handleChange}
style={{ fontSize: '14px' }}
>
{languages.map(
(lang: Language) =>
lang.enabled && (
<MenuItem
className='font-light'
style={{ fontSize: '14px', fontWeight: 300 }}
key={lang.value}
value={lang.value}
>
{lang.label}
</MenuItem>
)
)}
</Select>
</FormControl>
</div>
);
};

export default LanguageSwitcher;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Meta } from '@storybook/react';

import LanguageSwitcher, {
LanguageSwitcherProps,
} from '@/components/atoms/LanguageSwitcher/LanguageSwitcher';

const meta: Meta<typeof LanguageSwitcher> = {
title: 'LanguageSwitcher',
component: LanguageSwitcher,
tags: ['autodocs'],
};

export default meta;

export const SampleStory = (args: LanguageSwitcherProps) => {
return <LanguageSwitcher {...args} />;
};
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Education.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from 'next/image';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

import SectionHeading from '@/components/atoms/SectionHeading';
import SectionHeading from '@/components/atoms/headings/SectionHeading';

import { School } from '@/types/School';

Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

import SectionHeading from '@/components/atoms/SectionHeading';
import SectionHeading from '@/components/atoms/headings/SectionHeading';

import { SoftwareDevIntro } from '@/types/ShortText';

Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Languages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from 'next/image';
import * as React from 'react';

import SectionHeading from '@/components/atoms/SectionHeading';
import SectionHeading from '@/components/atoms/headings/SectionHeading';

import { Language } from '@/types/Language';

Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Publications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { AiOutlineFilePdf } from 'react-icons/ai';

import SectionHeading from '@/components/atoms/SectionHeading';
import SectionHeading from '@/components/atoms/headings/SectionHeading';
import UnstyledLink from '@/components/links/UnstyledLink';

import { Publication } from '@/types/Publication';
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/WorkExperience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTheme } from 'next-themes';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

import SectionHeading from '@/components/atoms/SectionHeading';
import SectionHeading from '@/components/atoms/headings/SectionHeading';

import { Job } from '@/types/Job';

Expand Down

0 comments on commit e434da5

Please sign in to comment.