-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: english version of 2024 questions
- Loading branch information
Showing
26 changed files
with
9,736 additions
and
154 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,99 @@ | ||
@import "shared.css"; | ||
|
||
#version-picker { | ||
display: flex; | ||
position: relative; | ||
margin: 0; | ||
color: var(--darkblue2); | ||
width: 5rem; | ||
height: 2rem; | ||
background-color: var(--white); | ||
border-radius: 0.5rem; | ||
border: 1px solid var(--darkblue1); | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
|
||
&.open { | ||
border-bottom-left-radius: 0; | ||
border-bottom-right-radius: 0; | ||
|
||
& #version-picker-popup { | ||
display: block; | ||
} | ||
} | ||
|
||
&:hover { | ||
background-color: var(--grey1); | ||
} | ||
|
||
@media (max-width: 48rem) { | ||
width: 4.7rem; | ||
} | ||
} | ||
|
||
#version-picker-content { | ||
flex-grow: 1; | ||
|
||
@media (max-width: 48rem) { | ||
& img { | ||
margin-right: 0; | ||
} | ||
|
||
& span { | ||
display: none; | ||
} | ||
} | ||
} | ||
|
||
#version-picker-indicator { | ||
display: flex; | ||
font-size: 1.5rem; | ||
width: 1rem; | ||
margin: 0.25rem 0.5rem; | ||
color: var(--blue3); | ||
|
||
& svg { | ||
display: block; | ||
} | ||
} | ||
|
||
#version-picker-popup { | ||
display: none; | ||
position: absolute; | ||
top: 2rem; | ||
right: 0; | ||
border: 1px solid var(--darkblue1); | ||
background-color: var(--white); | ||
margin-top: -2px; | ||
margin-right: -1px; | ||
padding: 0; | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
min-width: 100%; | ||
list-style: none; | ||
z-index: 5; | ||
|
||
& li { | ||
&[aria-selected=true] { | ||
background-color: var(--grey2); | ||
} | ||
|
||
&:hover { | ||
border-radius: 0.25rem; | ||
background-color: var(--grey3); | ||
} | ||
} | ||
} | ||
|
||
#version-picker-popup img, #version-picker-content img { | ||
height: 1.325rem; | ||
border-radius: 0.25rem; | ||
margin-right: 0.25rem; | ||
} | ||
|
||
#version-picker-popup li, #version-picker-content { | ||
padding: 0.25rem; | ||
line-height: 1.375rem; | ||
display: flex; | ||
align-content: center; | ||
} |
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,87 @@ | ||
import React, { | ||
FunctionComponent, MouseEvent, KeyboardEvent, ReactElement, useState, | ||
} from "react"; | ||
import "./VersionPicker.css"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faAngleDown } from "@fortawesome/free-solid-svg-icons"; | ||
import classNames from "classnames"; | ||
import { useTranslation } from "react-i18next"; | ||
import { ItemProps } from "./Item"; | ||
import { useRulesTestData } from "../context/TestDataContext"; | ||
import { AVAILABLE_LANGUAGES } from "../model/TestDataManager"; | ||
|
||
interface Props { | ||
children: Array<ReactElement<ItemProps>>; | ||
} | ||
|
||
const VersionPicker: FunctionComponent<Props> = ({ children }) => { | ||
const [open, setOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
const { version, setVersion } = useRulesTestData(); | ||
|
||
const handleTogglePopup = (event: MouseEvent) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
|
||
setOpen(!open); | ||
}; | ||
|
||
const handleKeyDown = (event: KeyboardEvent) => { | ||
if (event.keyCode === 32) { | ||
setOpen(!open); | ||
} else if (open) { | ||
if (event.keyCode === 27 || event.keyCode === 9) { | ||
setOpen(false); | ||
} else { | ||
return; | ||
} | ||
} else if (event.keyCode === 40) { | ||
setOpen(true); | ||
} else { | ||
return; | ||
} | ||
|
||
event.preventDefault(); | ||
}; | ||
|
||
let content = null; | ||
const items = React.Children.map(children, (item: ReactElement<ItemProps>) => { | ||
const isSelected = item.props.code === version; | ||
if (isSelected) { | ||
content = item.props.children; | ||
} | ||
|
||
return React.cloneElement(item, { | ||
selected: isSelected, | ||
onClick: () => setVersion!(item.props.code as keyof typeof AVAILABLE_LANGUAGES), | ||
}); | ||
}); | ||
|
||
const className = classNames({ | ||
open, | ||
}); | ||
|
||
return ( | ||
<div | ||
id="version-picker" | ||
className={className} | ||
role="listbox" | ||
aria-label={t("app.language")} | ||
tabIndex={0} | ||
onClick={handleTogglePopup} | ||
onKeyDown={handleKeyDown} | ||
> | ||
<div id="version-picker-content"> | ||
{content} | ||
</div> | ||
<div id="version-picker-indicator"> | ||
<FontAwesomeIcon icon={faAngleDown} /> | ||
</div> | ||
<ul id="version-picker-popup"> | ||
{items} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default VersionPicker; |
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
Oops, something went wrong.