Skip to content

Commit 0e4b359

Browse files
committed
feature: moves personal projects to own section as suggested to me
1 parent f7974a4 commit 0e4b359

File tree

19 files changed

+398
-134
lines changed

19 files changed

+398
-134
lines changed

src/app/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Language, LocalizationService } from "@/shared/services/localization-service"
1+
import { ApplicationLanguage, LocalizationService } from "@/shared/services/localization-service"
22
import { useEffect, useState } from "react"
33
import { Stack } from "@mui/material"
44
import { Router } from "./router"
55
import { Providers } from "./providers"
66

77
export default function App(): JSX.Element {
8-
const [language, setLanguage] = useState(Language.DANISH) // Initial value doesn't matter, as the language specified in 'LocalizationService' is the one used.
8+
const [language, setLanguage] = useState(ApplicationLanguage.DANISH) // Initial value doesn't matter, as the language specified in 'LocalizationService' is the one used.
99

1010
useEffect(() => {
1111
LocalizationService.instance.setupStateUpdater(setLanguage)

src/cv/components/education-section.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export function EducationSection(): JSX.Element {
5151
}
5252

5353
function getEducationComponents(): React.ReactNode {
54-
return educations.map(entity => (
55-
<Education educationEntity={entity} key={entity.startDate.getTime()}/>
54+
return educations.map((entity, index) => (
55+
<Education educationEntity={entity} key={entity.startDate.getTime()} index={index}/>
5656
))
5757
}
5858
}

src/cv/components/education-section/education.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { LabelledTypography } from "@/shared/components/labelled-typography";
2+
import { PageBreak } from "@/shared/components/page-break";
23
import { EducationEntity } from "@/shared/entities/education-entity";
3-
import { LocalizationService } from "@/shared/services/localization-service";
4+
import { ApplicationLanguage, LocalizationService } from "@/shared/services/localization-service";
45
import { Paper, Typography } from "@mui/material";
56
import { ReactNode } from "react";
67

78
interface EducationProps {
89
educationEntity: EducationEntity
10+
index: number
911
}
1012

1113
export function Education(props: EducationProps): JSX.Element {
@@ -15,19 +17,23 @@ export function Education(props: EducationProps): JSX.Element {
1517
const educationPeriode: string = buildEducationPeriodeString()
1618

1719
return (
18-
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
19-
<Typography color={'Highlight'}>
20-
{educationAsAt}
21-
</Typography>
22-
<Typography>
23-
{educationPeriode}
24-
</Typography>
25-
<LabelledTypography
26-
labelText={entityLocalizationService.getComponentText("educationDescriptionLabel")}
27-
labelProps={{color: 'GrayText'}}
28-
mainText={entityLocalizationService.getEntityText(props.educationEntity.descriptionKey)}
29-
mainProps={{variant: 'body1', style: {whiteSpace: 'pre-line'}}}/>
30-
</Paper>
20+
<>
21+
{insertNewPageInPrint(1, ApplicationLanguage.DANISH)}
22+
{insertNewPageInPrint(1, ApplicationLanguage.ENGLISH)}
23+
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
24+
<Typography color={'Highlight'}>
25+
{educationAsAt}
26+
</Typography>
27+
<Typography>
28+
{educationPeriode}
29+
</Typography>
30+
<LabelledTypography
31+
labelText={entityLocalizationService.getComponentText("educationDescriptionLabel")}
32+
labelProps={{color: 'GrayText'}}
33+
mainText={entityLocalizationService.getEntityText(props.educationEntity.descriptionKey)}
34+
mainProps={{variant: 'body1', style: {whiteSpace: 'pre-line'}}}/>
35+
</Paper>
36+
</>
3137
)
3238

3339
function buildEducationAsAtString(): string {
@@ -64,4 +70,12 @@ export function Education(props: EducationProps): JSX.Element {
6470
function getLocalizedDate(date: Date): string {
6571
return date.toLocaleDateString(localizationService.getCurrentLanguage(), {dateStyle: "medium"})
6672
}
73+
74+
function insertNewPageInPrint(index: number, language: ApplicationLanguage): ReactNode {
75+
if (props.index === index && localizationService.getCurrentLanguage() === language) {
76+
return (<PageBreak/>)
77+
}
78+
79+
return (<></>)
80+
}
6781
}

src/cv/components/employment-section/employment.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LabelledTypography } from "@/shared/components/labelled-typography";
22
import { PageBreak } from "@/shared/components/page-break";
33
import { EmploymentEntity } from "@/shared/entities/employment-entity";
44
import { EntityEmploymentLocalizationKeys } from "@/shared/localization/employment-localization";
5-
import { Language, LocalizationService } from "@/shared/services/localization-service";
5+
import { ApplicationLanguage, LocalizationService } from "@/shared/services/localization-service";
66
import { Paper, Typography } from "@mui/material";
77
import { ReactNode } from "react";
88

@@ -18,7 +18,6 @@ export function Employment(props: EmploymentProps): JSX.Element {
1818

1919
return (
2020
<>
21-
{insertNewPageInPrint("employerApps4All", Language.ENGLISH)}
2221
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
2322
<Typography color={'Highlight'}>
2423
{employedAsAt}
@@ -75,7 +74,7 @@ export function Employment(props: EmploymentProps): JSX.Element {
7574
return date.toLocaleDateString(localizationService.getCurrentLanguage(), {dateStyle: "medium"})
7675
}
7776

78-
function insertNewPageInPrint(employerKey: EntityEmploymentLocalizationKeys, language: Language): ReactNode {
77+
function insertNewPageInPrint(employerKey: EntityEmploymentLocalizationKeys, language: ApplicationLanguage): ReactNode {
7978
if (props.employmentEntity.employerKey === employerKey && localizationService.getCurrentLanguage() === language) {
8079
return (<PageBreak/>)
8180
}

src/cv/components/languages-section.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { LanguageEntity } from "@/shared/entities/language-entity";
22
import { EntityGenerationService } from "@/shared/services/entity-generation-service";
3-
import { LocalizationService } from "@/shared/services/localization-service";
4-
import { Box, Paper, Typography } from "@mui/material";
3+
import { ApplicationLanguage, LocalizationService } from "@/shared/services/localization-service";
4+
import { Paper, Typography } from "@mui/material";
55
import { Language } from "./language-section/language";
6-
import { Page, Pages, usePrinter } from "react-pdf-printer";
6+
import { Page, usePrinter } from "react-pdf-printer";
77
import { PageBreak } from "@/shared/components/page-break";
8+
import { ReactNode } from "react";
89

910
export function LanguagesSection(): JSX.Element {
1011
const localizationService: LocalizationService = LocalizationService.instance
@@ -14,6 +15,8 @@ export function LanguagesSection(): JSX.Element {
1415

1516
return (
1617
<>
18+
{insertNewPageInPrint(ApplicationLanguage.DANISH)}
19+
{insertNewPageInPrint(ApplicationLanguage.ENGLISH)}
1720
<Paper elevation={2} sx={{padding: '5px', margin: '5px'}}>
1821
{isPrinter ? getPrinterLayout() : getWebLayout()}
1922
</Paper>
@@ -57,4 +60,12 @@ export function LanguagesSection(): JSX.Element {
5760
function getUniqueKey(language: LanguageEntity): number {
5861
return Math.floor(language.importance * language.level * language.nameKey.length)
5962
}
63+
64+
function insertNewPageInPrint(language: ApplicationLanguage): ReactNode {
65+
if (localizationService.getCurrentLanguage() === language) {
66+
return (<PageBreak/>)
67+
}
68+
69+
return (<></>)
70+
}
6071
}

src/cv/components/project-section.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { ProjectEntity } from "@/shared/entities/project-entity"
2+
import { EntityGenerationService } from "@/shared/services/entity-generation-service"
3+
import { LocalizationService } from "@/shared/services/localization-service"
4+
import { Box, Paper, Typography } from "@mui/material"
5+
import React from "react"
6+
import { Page, Pages, usePrinter } from "react-pdf-printer"
7+
import { Project } from "./project-section/project"
8+
9+
export function ProjectSection(): JSX.Element {
10+
const localizationService: LocalizationService = LocalizationService.instance
11+
const entityLocalizationService = localizationService.getProjectLocalizationService()
12+
const projects: ProjectEntity[] = EntityGenerationService.instance.getProjectEntities()
13+
const { isPrinter } = usePrinter()
14+
15+
return (
16+
<Paper elevation={2} sx={{padding: '5px', margin: '5px'}}>
17+
{isPrinter ? getPrinterLayout() : getWebLayout()}
18+
</Paper>
19+
)
20+
21+
function getPrinterLayout(): JSX.Element {
22+
return (
23+
<>
24+
<Page>
25+
{getSectionStart()}
26+
</Page>
27+
<Box data-printer-divisible={false}>
28+
<Pages>
29+
{getProjectComponents()}
30+
</Pages>
31+
</Box>
32+
</>
33+
)
34+
}
35+
36+
function getWebLayout(): JSX.Element {
37+
return (
38+
<>
39+
{getSectionStart()}
40+
41+
{getProjectComponents()}
42+
</>
43+
)
44+
}
45+
46+
function getSectionStart(): React.ReactNode {
47+
return (<>
48+
<Typography variant="h4" display={'flex'} justifyContent={"center"}>
49+
{entityLocalizationService.getComponentText("sectionHeader")}
50+
</Typography>
51+
<Typography>
52+
{entityLocalizationService.getComponentText("sectionDescription")}
53+
</Typography>
54+
</>
55+
)
56+
}
57+
58+
function getProjectComponents(): React.ReactNode {
59+
return projects.map(entity => (
60+
<Project data-printer-divisible={isPrinter} projectEntity={entity} key={entity.importance} />
61+
))
62+
}
63+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ProjectEntity } from "@/shared/entities/project-entity"
2+
import { LocalizationService } from "@/shared/services/localization-service"
3+
import { Paper, Typography } from "@mui/material"
4+
5+
interface ProjectProps {
6+
projectEntity: ProjectEntity
7+
}
8+
9+
export function Project(props: ProjectProps): JSX.Element {
10+
const localizationService = LocalizationService.instance
11+
12+
return (<>
13+
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
14+
<Typography color={'Highlight'}>
15+
{localizationService.getProjectLocalizationService().getEntityText(props.projectEntity.titleKey)}
16+
</Typography>
17+
<Typography>
18+
{localizationService.getProjectLocalizationService().getEntityText(props.projectEntity.descriptionKey)}
19+
</Typography>
20+
</Paper>
21+
</>)
22+
}

src/cv/components/skills-section/skill.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PageBreak } from "@/shared/components/page-break";
22
import { SkillEntity, SkillName } from "@/shared/entities/skill-entity";
33
import { Paper, Rating, Typography } from "@mui/material";
44
import { ReactNode } from "react";
5-
import { Language, LocalizationService } from "@/shared/services/localization-service";
5+
import { ApplicationLanguage, LocalizationService } from "@/shared/services/localization-service";
66

77
interface SkillProps {
88
skillEntity: SkillEntity
@@ -13,7 +13,7 @@ export function Skill(props: SkillProps): JSX.Element {
1313

1414
return (
1515
<>
16-
{insertNewPageInPrint(SkillName.JAVA, Language.DANISH)}
16+
{/* {insertNewPageInPrint(SkillName.JAVA, Language.DANISH)} */}
1717
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
1818
<Typography>{props.skillEntity.name}</Typography>
1919
<Rating value={props.skillEntity.level} readOnly/>
@@ -22,7 +22,7 @@ export function Skill(props: SkillProps): JSX.Element {
2222

2323
)
2424

25-
function insertNewPageInPrint(skillName: SkillName, language: Language): ReactNode {
25+
function insertNewPageInPrint(skillName: SkillName, language: ApplicationLanguage): ReactNode {
2626
if (props.skillEntity.name === skillName && localizationService.getCurrentLanguage() === language) {
2727
return (<PageBreak/>)
2828
}

src/cv/print-cv.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ReferencesSection } from "./components/references-section";
99
import { SkillsSection } from "./components/skills-section";
1010
import { useRef } from "react";
1111
import { OverflowStack } from "@/shared/components/overflow-stack";
12+
import { ProjectSection } from "./components/project-section";
1213

1314
export function PrintCv(): JSX.Element {
1415
const documentRef = useRef<DocumentRef>(null);
@@ -27,6 +28,7 @@ export function PrintCv(): JSX.Element {
2728
<ProfileSection/>
2829
</Page>
2930
<EmploymentSection/>
31+
<ProjectSection/>
3032
<EducationSection/>
3133
<SkillsSection/>
3234
<Page>

src/cv/web-cv.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Header } from "@/header/header";
1111
import { OverflowStack } from "@/shared/components/overflow-stack";
1212
import { useRef } from "react";
1313
import { DocumentRef } from "react-pdf-printer";
14+
import { ProjectSection } from "./components/project-section";
1415

1516
export function WebCv(): JSX.Element {
1617
return (
@@ -22,6 +23,7 @@ export function WebCv(): JSX.Element {
2223
<Grid width={'69%'}>
2324
<ProfileSection/>
2425
<EmploymentSection/>
26+
<ProjectSection/>
2527
<EducationSection/>
2628
<ReferencesSection/>
2729
</Grid>

src/header/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button, ButtonGroup, Divider, Grid, Paper, Theme, ThemeProvider, Typography } from '@mui/material';
2-
import { Language, LocalizationService } from '../shared/services/localization-service';
2+
import { ApplicationLanguage, LocalizationService } from '../shared/services/localization-service';
33
import { CenteredBox } from '@/shared/components/centered-box';
44
import { RightAlignedBox } from '@/shared/components/right-aligned-box';
55
import { ThemeService } from '../shared/services/theme-service';
@@ -48,12 +48,12 @@ export function Header(): JSX.Element {
4848

4949
function setLanguageToDanish(): void {
5050
console.debug('Setting language to Danish')
51-
localizationService.setLanguage(Language.DANISH)
51+
localizationService.setLanguage(ApplicationLanguage.DANISH)
5252
}
5353

5454
function setLanguageToEnglish(): void {
5555
console.debug('Setting language to English')
56-
localizationService.setLanguage(Language.ENGLISH)
56+
localizationService.setLanguage(ApplicationLanguage.ENGLISH)
5757
}
5858

5959
async function printCv(): Promise<void> {

src/shared/entities/project-entity.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { EntityProjectLocalizationKeys } from "../localization/project-localization";
2+
import { Importance } from "./common";
3+
4+
export interface ProjectEntity extends Importance {
5+
descriptionKey: EntityProjectLocalizationKeys
6+
titleKey: EntityProjectLocalizationKeys
7+
}

0 commit comments

Comments
 (0)