-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/OPHKIOS-108' into feature/OPHKIOS-114
- Loading branch information
Showing
54 changed files
with
1,270 additions
and
83 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
18 changes: 18 additions & 0 deletions
18
backend/vkt/src/main/java/fi/oph/vkt/api/dto/PublicExaminerDTO.java
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,18 @@ | ||
package fi.oph.vkt.api.dto; | ||
|
||
import fi.oph.vkt.model.type.ExamLanguage; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.NonNull; | ||
|
||
@Builder | ||
public record PublicExaminerDTO( | ||
@NonNull @NotNull Long id, | ||
@NonNull @NotNull String lastName, | ||
@NonNull @NotNull String firstName, | ||
@NonNull @NotNull List<ExamLanguage> languages, | ||
@NonNull @NotNull List<PublicMunicipalityDTO> municipalities, | ||
@NonNull @NotNull List<LocalDate> examDates | ||
) {} |
8 changes: 8 additions & 0 deletions
8
backend/vkt/src/main/java/fi/oph/vkt/api/dto/PublicMunicipalityDTO.java
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,8 @@ | ||
package fi.oph.vkt.api.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.NonNull; | ||
|
||
@Builder | ||
public record PublicMunicipalityDTO(@NonNull @NotNull String fi, @NonNull @NotNull String sv) {} |
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
35 changes: 35 additions & 0 deletions
35
backend/vkt/src/main/java/fi/oph/vkt/service/PublicExaminerService.java
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,35 @@ | ||
package fi.oph.vkt.service; | ||
|
||
import fi.oph.vkt.api.dto.PublicExaminerDTO; | ||
import fi.oph.vkt.api.dto.PublicMunicipalityDTO; | ||
import fi.oph.vkt.model.type.ExamLanguage; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PublicExaminerService { | ||
|
||
public List<PublicExaminerDTO> listExaminers() { | ||
final PublicMunicipalityDTO helsinki = PublicMunicipalityDTO.builder().fi("Helsinki").sv("Helsingfors").build(); | ||
final PublicMunicipalityDTO espoo = PublicMunicipalityDTO.builder().fi("Espoo").sv("Esbo").build(); | ||
final PublicMunicipalityDTO vantaa = PublicMunicipalityDTO.builder().fi("Vantaa").sv("Vanda").build(); | ||
final PublicMunicipalityDTO kauniainen = PublicMunicipalityDTO.builder().fi("Kauniainen").sv("Grankulla").build(); | ||
final List<PublicExaminerDTO> examiners = new ArrayList<>(); | ||
examiners.add( | ||
PublicExaminerDTO | ||
.builder() | ||
.id(1L) | ||
.lastName("Laine") | ||
.firstName("Eemeli") | ||
.languages(List.of(ExamLanguage.FI)) | ||
.municipalities(List.of(helsinki, espoo, vantaa, kauniainen)) | ||
.examDates(List.of()) | ||
.build() | ||
); | ||
|
||
return examiners; | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
frontend/packages/shared/src/components/MobileNavigationMenu/MobileNavigationMenu.scss
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,30 @@ | ||
@use '../../styles/abstracts/colors'; | ||
|
||
button.navigation-menu-toggle { | ||
background-color: colors.$color-primary; | ||
border: 0; | ||
} | ||
|
||
.navigation-menu-contents { | ||
ul { | ||
list-style-type: none; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1rem; | ||
} | ||
|
||
li { | ||
> a { | ||
text-decoration: none; | ||
} | ||
padding: 1rem; | ||
} | ||
|
||
li.active { | ||
p { | ||
color: colors.$color-secondary; | ||
font-weight: 700; | ||
} | ||
border-left: 2px solid colors.$color-secondary; | ||
} | ||
} |
164 changes: 164 additions & 0 deletions
164
frontend/packages/shared/src/components/MobileNavigationMenu/MobileNavigationMenu.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 |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { FocusTrap } from '@mui/base/FocusTrap'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import MenuIcon from '@mui/icons-material/Menu'; | ||
import { ClickAwayListener, Divider, Paper } from '@mui/material'; | ||
import { Fragment, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { Color } from '../../enums'; | ||
import { NavigationLinksProps } from '../NavigationLinks/NavigationLinks'; | ||
import { Text } from '../Text/Text'; | ||
|
||
import './MobileNavigationMenu.scss'; | ||
|
||
const MobileNavigationMenuToggle = ({ | ||
openStateLabel, | ||
openStateAriaLabel, | ||
closedStateLabel, | ||
closedStateAriaLabel, | ||
isOpen, | ||
setIsOpen, | ||
}: { | ||
openStateLabel: string; | ||
openStateAriaLabel: string; | ||
closedStateLabel: string; | ||
closedStateAriaLabel: string; | ||
isOpen: boolean; | ||
setIsOpen: (state: boolean) => void; | ||
}) => { | ||
const handleClick = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
return ( | ||
<button | ||
tabIndex={0} | ||
className="navigation-menu-toggle rows align-items-center" | ||
onClick={handleClick} | ||
> | ||
{isOpen && ( | ||
<> | ||
<CloseIcon | ||
color={Color.Secondary} | ||
fontSize="large" | ||
aria-hidden={true} | ||
/> | ||
<Text aria-label={openStateAriaLabel} fontSize={12}> | ||
{openStateLabel} | ||
</Text> | ||
</> | ||
)} | ||
{!isOpen && ( | ||
<> | ||
<MenuIcon | ||
color={Color.Secondary} | ||
fontSize="large" | ||
aria-hidden={true} | ||
/> | ||
<Text aria-label={closedStateAriaLabel} fontSize={12}> | ||
{closedStateLabel} | ||
</Text> | ||
</> | ||
)} | ||
</button> | ||
); | ||
}; | ||
|
||
interface MobileNavigationMenuProps extends NavigationLinksProps { | ||
closeMenu: () => void; | ||
} | ||
|
||
export const MobileNavigationMenuContents = ({ | ||
navigationAriaLabel, | ||
links, | ||
closeMenu, | ||
}: MobileNavigationMenuProps) => { | ||
const handleClickAway = (e: MouseEvent | TouchEvent) => { | ||
// Prevent event default so that when user clicks on menu close button (outside actual menu contents), | ||
// the menu isn't immediately opened again. | ||
e.preventDefault(); | ||
closeMenu(); | ||
}; | ||
|
||
const handleEsc = (e: React.KeyboardEvent) => { | ||
if (e.key === 'Escape') { | ||
closeMenu(); | ||
} | ||
}; | ||
|
||
return ( | ||
<FocusTrap open={true}> | ||
<Paper | ||
onKeyDown={handleEsc} | ||
role="presentation" | ||
tabIndex={-1} | ||
elevation={3} | ||
> | ||
<nav | ||
className="navigation-menu-contents" | ||
aria-label={navigationAriaLabel} | ||
> | ||
<ClickAwayListener onClickAway={handleClickAway}> | ||
<ul className="gapped-sm"> | ||
{links.map((l, i) => ( | ||
<Fragment key={i}> | ||
{i > 0 && <Divider />} | ||
<li key={i} className={l.active ? 'active' : undefined}> | ||
<Link | ||
to={l.href} | ||
aria-current={l.active && 'page'} | ||
onClick={closeMenu} | ||
> | ||
<Text>{l.label}</Text> | ||
</Link> | ||
</li> | ||
</Fragment> | ||
))} | ||
</ul> | ||
</ClickAwayListener> | ||
</nav> | ||
</Paper> | ||
</FocusTrap> | ||
); | ||
}; | ||
|
||
export const MobileNavigationMenuWithPortal = ({ | ||
navigationAriaLabel, | ||
openStateLabel, | ||
openStateAriaLabel, | ||
closedStateLabel, | ||
closedStateAriaLabel, | ||
links, | ||
portalContainer, | ||
}: { | ||
openStateLabel: string; | ||
openStateAriaLabel: string; | ||
closedStateLabel: string; | ||
closedStateAriaLabel: string; | ||
portalContainer: HTMLElement; | ||
} & NavigationLinksProps) => { | ||
const [isMenuOpen, setIsMenuOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<MobileNavigationMenuToggle | ||
openStateAriaLabel={openStateAriaLabel} | ||
openStateLabel={openStateLabel} | ||
closedStateAriaLabel={closedStateAriaLabel} | ||
closedStateLabel={closedStateLabel} | ||
isOpen={isMenuOpen} | ||
setIsOpen={() => setIsMenuOpen(true)} | ||
/> | ||
{isMenuOpen && | ||
createPortal( | ||
<MobileNavigationMenuContents | ||
navigationAriaLabel={navigationAriaLabel} | ||
links={links} | ||
closeMenu={() => setIsMenuOpen(false)} | ||
/>, | ||
portalContainer, | ||
)} | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
li { | ||
padding-bottom: 2rem; | ||
|
||
> a { | ||
text-decoration: none; | ||
} | ||
|
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 |
---|---|---|
|
@@ -26,6 +26,6 @@ | |
}, | ||
"dependencies": { | ||
"reduxjs-toolkit-persist": "^7.2.1", | ||
"shared": "npm:@opetushallitus/[email protected].4" | ||
"shared": "npm:@opetushallitus/[email protected].5" | ||
} | ||
} |
Oops, something went wrong.