Skip to content

Commit

Permalink
feat: localise headings
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 24, 2023
1 parent f5d2251 commit 49dc895
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 45 deletions.
32 changes: 10 additions & 22 deletions src/app/(public)/about/work/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { flattenToArray, flattenToObject } from '@/lib/graphqlUtils';

import Heading from '@/components/atoms/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';
import Publications from '@/components/organisms/about-work/Publications';
import WorkExperience from '@/components/organisms/about-work/WorkExperience';
Expand Down Expand Up @@ -91,36 +92,15 @@ const AboutPage = async () => {
const { intro, jobs, languages, publications, schools, skills } =
await queryData();

const noOfYears = (new Date().getFullYear() - 2015).toString();

const iconDimension = 36;
const titleIconDimension = 42;

return (
<main className='min-h-main'>
<section className='dark:bg-dark bg-white'>
<div className='layout relative flex flex-col py-12'>
<Heading title='aboutWork.title' />

<div>
<div className='m-2 flex'>
<Image
className='mr-2 h-auto'
src={intro.icon.url}
alt={intro.title}
width={titleIconDimension}
height={titleIconDimension}
/>

<h2>{intro.title}</h2>
</div>

<div className='mb-5'>
<ReactMarkdown>
{intro.content.replace('8', noOfYears)}
</ReactMarkdown>
</div>
</div>
<Intro intro={intro} />

<div className='mb-10 grid grid-cols-1 gap-5 md:grid-cols-3 md:gap-6'>
{skills.map((skill: Skill) => (
Expand Down Expand Up @@ -149,12 +129,20 @@ const AboutPage = async () => {
))}
</div>

<hr />

<WorkExperience jobs={jobs} />

<hr />

<Education schools={schools} />

<hr />

<Languages languages={languages} />

<hr />

<Publications publications={publications} />
</div>
</section>
Expand Down
33 changes: 33 additions & 0 deletions src/components/atoms/SectionHeading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use client';

import Image from 'next/image';
import * as React from 'react';
import { useTranslation } from 'react-i18next';

interface SectionHeadingProps {
titlePrefix: string;
}

const SectionHeading = ({ titlePrefix }: SectionHeadingProps) => {
const { t } = useTranslation();

const titleIconDimension = 36;

return (
<div className='m-2 flex flex-col items-center'>
<Image
className='h-auto'
src={t(`${titlePrefix}.icon`)}
alt={t(`${titlePrefix}.title`)}
width={titleIconDimension}
height={titleIconDimension}
/>

<h2 className='-mt-0.5 underline decoration-1 underline-offset-4 md:decoration-2'>
{t(`${titlePrefix}.title`)}
</h2>
</div>
);
};

export default SectionHeading;
8 changes: 4 additions & 4 deletions src/components/organisms/about-work/Education.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Image from 'next/image';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

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

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

export interface EducationProps {
Expand All @@ -12,10 +14,8 @@ export interface EducationProps {

const Education = ({ schools }: EducationProps) => {
return (
<div className=''>
<div className='m-2 flex'>
<h2>Education</h2>
</div>
<div className='my-4'>
<SectionHeading titlePrefix='aboutWork.education' />

<div>
{schools.map((school) => (
Expand Down
28 changes: 28 additions & 0 deletions src/components/organisms/about-work/Intro.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use client';

import * as React from 'react';
import ReactMarkdown from 'react-markdown';

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

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

interface IntroProps {
intro: SoftwareDevIntro;
}

const Intro = ({ intro }: IntroProps) => {
const noOfYears = (new Date().getFullYear() - 2015).toString();

return (
<div>
<SectionHeading titlePrefix='aboutWork.softwareDevelopment' />

<div className='mb-5'>
<ReactMarkdown>{intro.content.replace('8', noOfYears)}</ReactMarkdown>
</div>
</div>
);
};

export default Intro;
10 changes: 5 additions & 5 deletions src/components/organisms/about-work/Languages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import Image from 'next/image';
import * as React from 'react';

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

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

export interface LanguageProps {
Expand All @@ -11,12 +13,10 @@ export interface LanguageProps {

const Languages = ({ languages }: LanguageProps) => {
return (
<div className='mb-6'>
<div className='m-2 flex'>
<h2>Languages</h2>
</div>
<div className='mb-6 mt-4'>
<SectionHeading titlePrefix='aboutWork.languages' />

<div className='grid grid-cols-1 gap-3 md:grid-cols-4 md:gap-6'>
<div className='mt-4 grid grid-cols-1 gap-3 md:grid-cols-4 md:gap-6'>
{languages.map((language) => (
<div
key={language.id}
Expand Down
9 changes: 4 additions & 5 deletions src/components/organisms/about-work/Publications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from 'react';
import { AiOutlineFilePdf } from 'react-icons/ai';

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

import { Publication } from '@/types/Publication';
Expand All @@ -13,12 +14,10 @@ export interface PublicationProps {

const Publications = ({ publications }: PublicationProps) => {
return (
<div className='mb-6'>
<div className='m-2 flex'>
<h2>Publications</h2>
</div>
<div className='mb-6 mt-4'>
<SectionHeading titlePrefix='aboutWork.publications' />

<div className='grid grid-cols-1 gap-3 md:grid-cols-3 md:gap-8'>
<div className='mt-4 grid grid-cols-1 gap-3 md:grid-cols-3 md:gap-8'>
{publications.map((publication) => (
<div
key={publication.id}
Expand Down
8 changes: 4 additions & 4 deletions src/components/organisms/about-work/WorkExperience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useTheme } from 'next-themes';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

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

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

export interface WorkExperienceProps {
Expand All @@ -15,10 +17,8 @@ const WorkExperience = ({ jobs }: WorkExperienceProps) => {
const { theme } = useTheme();

return (
<div className=''>
<div className='m-2 flex'>
<h2>Work Experience</h2>
</div>
<div className='my-4'>
<SectionHeading titlePrefix='aboutWork.workExperience' />

<div>
{jobs.map((job) => (
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/school_bbe225685d.svg"
},
"languages": {
"title": "Work Experience",
"title": "Languages",
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/internet_60bf166c34.svg"
},
"publications": {
Expand Down
8 changes: 4 additions & 4 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692734473/laptop_4a3ba3b30c.svg"
},
"workExperience": {
"title": "Work Experience",
"title": "Esperienza",
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/work_f1bb1eb3dd.svg"
},
"education": {
"title": "Education",
"title": "Studi",
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/school_bbe225685d.svg"
},
"languages": {
"title": "Work Experience",
"title": "Lingue",
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/internet_60bf166c34.svg"
},
"publications": {
"title": "Publications",
"title": "Pubblicazioni",
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/newspaper_e15ec94d21.svg"
}
}
Expand Down

0 comments on commit 49dc895

Please sign in to comment.