Enhance language selection (#538)
* Enhance language selection * remove top/left margin to limit unusable canvas area Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
ee68af0fd3
commit
54f9c296b5
@ -10,23 +10,18 @@ export function LanguageList<T>({
|
|||||||
currentLanguage: string;
|
currentLanguage: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ul>
|
<React.Fragment>
|
||||||
{languages.map((language, idx) => (
|
<select
|
||||||
<li
|
className="language-select"
|
||||||
key={idx}
|
onChange={({ target }) => onClick(target.value)}
|
||||||
className={currentLanguage === language.lng ? "current" : ""}
|
value={currentLanguage}
|
||||||
>
|
>
|
||||||
<a
|
{languages.map(language => (
|
||||||
href="/"
|
<option key={language.lng} value={language.lng}>
|
||||||
onClick={e => {
|
|
||||||
onClick(language.lng);
|
|
||||||
e.preventDefault();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{language.label}
|
{language.label}
|
||||||
</a>
|
</option>
|
||||||
</li>
|
))}
|
||||||
))}
|
</select>
|
||||||
</ul>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1309,15 +1309,13 @@ export class App extends React.Component<any, AppState> {
|
|||||||
document.documentElement.style.cursor = hitElement ? "move" : "";
|
document.documentElement.style.cursor = hitElement ? "move" : "";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="langBox">
|
<LanguageList
|
||||||
<LanguageList
|
onClick={lng => {
|
||||||
onClick={lng => {
|
i18n.changeLanguage(lng);
|
||||||
i18n.changeLanguage(lng);
|
}}
|
||||||
}}
|
languages={languages}
|
||||||
languages={languages}
|
currentLanguage={parseDetectedLang(i18n.language)}
|
||||||
currentLanguage={parseDetectedLang(i18n.language)}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -184,29 +184,35 @@ button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.langBox {
|
.language-select {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
min-width: 5.5rem;
|
||||||
|
height: 2rem;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
ul {
|
padding: 0.5em;
|
||||||
margin: 0;
|
background-color: #e9ecef;
|
||||||
padding: 0;
|
border-radius: var(--space-factor);
|
||||||
|
border: none;
|
||||||
|
font-size: 0.8em;
|
||||||
|
outline: none;
|
||||||
|
appearance: none;
|
||||||
|
background-image: url("https://free-use.s3-us-west-2.amazonaws.com/up-sort.svg");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: right 0.7em top 50%, 0 0;
|
||||||
|
background-size: 0.65em auto, 100%;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
box-shadow: 0 0 0 2px #a5d8ff;
|
||||||
}
|
}
|
||||||
ul > li {
|
|
||||||
list-style: none;
|
&:hover {
|
||||||
display: inline-block;
|
background-color: #ced4da;
|
||||||
padding: 4px;
|
|
||||||
}
|
}
|
||||||
li > a,
|
|
||||||
li > a:visited {
|
&:active {
|
||||||
text-decoration: none;
|
background-color: #ced4da;
|
||||||
color: gray;
|
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
|
||||||
li.current > a,
|
|
||||||
li.current > a:visited {
|
|
||||||
color: black;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user