add language selector
This commit is contained in:
parent
c9a6f3d454
commit
74b2d2fec5
@ -14,9 +14,8 @@
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
import { VNode } from "preact";
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
import { JSX } from "preact/jsx-runtime";
|
||||
import { NiceSelect } from "./styled/index";
|
||||
|
||||
interface Props {
|
||||
value: string;
|
||||
@ -27,14 +26,41 @@ interface Props {
|
||||
}
|
||||
name: string;
|
||||
description?: string;
|
||||
canBeNull?: boolean;
|
||||
}
|
||||
|
||||
export function SelectList({ name, value, list, onChange, label, description }: Props): JSX.Element {
|
||||
return <select name={name} id="slct">
|
||||
<option selected disabled>Choose an option</option>
|
||||
{Object.keys(list)
|
||||
.filter((l) => l !== value)
|
||||
.map(key => <option value={key} key={key}>{list[key]}</option> )
|
||||
}
|
||||
</select>
|
||||
export function SelectList({ name, value, list, canBeNull, onChange, label, description }: Props): JSX.Element {
|
||||
console.log("==>", name, value)
|
||||
return <div>
|
||||
<label
|
||||
htmlFor={`text-${name}`}
|
||||
style={{ marginLeft: "0.5em", fontWeight: "bold" }}
|
||||
> {label}</label>
|
||||
<NiceSelect>
|
||||
<select name={name} onChange={(e) => {
|
||||
console.log(e.currentTarget.value, value)
|
||||
onChange(e.currentTarget.value)
|
||||
}}>
|
||||
<option selected>
|
||||
{list[value]}
|
||||
</option>
|
||||
{Object.keys(list)
|
||||
.filter((l) => l !== value)
|
||||
.map(key => <option value={key} key={key}>{list[key]}</option>)
|
||||
}
|
||||
</select>
|
||||
</NiceSelect>
|
||||
{description && <span
|
||||
style={{
|
||||
color: "#383838",
|
||||
fontSize: "smaller",
|
||||
display: "block",
|
||||
marginLeft: "2em",
|
||||
}}
|
||||
>
|
||||
{description}
|
||||
</span>}
|
||||
|
||||
</div>
|
||||
|
||||
}
|
||||
|
@ -263,4 +263,49 @@ export const PopupNavigation = styled.div`
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
`;
|
||||
|
||||
export const NiceSelect = styled.div`
|
||||
|
||||
& > select {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
-ms-appearance: none;
|
||||
appearance: none;
|
||||
outline: 0;
|
||||
box-shadow: none;
|
||||
background-image: none;
|
||||
background-color: white;
|
||||
|
||||
flex: 1;
|
||||
padding: 0.5em 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 10em;
|
||||
overflow: hidden;
|
||||
border-radius: .25em;
|
||||
|
||||
&::after {
|
||||
content: '\u25BC';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 0.5em 1em;
|
||||
cursor: pointer;
|
||||
pointer-events: none;
|
||||
-webkit-transition: .25s all ease;
|
||||
-o-transition: .25s all ease;
|
||||
transition: .25s all ease;
|
||||
}
|
||||
|
||||
&:hover::after {
|
||||
/* color: #f39c12; */
|
||||
}
|
||||
|
||||
&::-ms-expand {
|
||||
display: none;
|
||||
}
|
||||
`
|
||||
|
@ -70,14 +70,14 @@ export function SettingsView({ lang, changeLang, deviceName, setDeviceName, perm
|
||||
<div>
|
||||
<section style={{ height: 'calc(320px - 34px - 16px)', overflow: 'auto' }}>
|
||||
<h2><i18n.Translate>Wallet</i18n.Translate></h2>
|
||||
{/* <SelectList
|
||||
<SelectList
|
||||
value={lang}
|
||||
onChange={changeLang}
|
||||
name="lang"
|
||||
list={names}
|
||||
label={i18n.str`Lang`}
|
||||
label={i18n.str`Language`}
|
||||
description="(Choose your preferred lang)"
|
||||
/> */}
|
||||
/>
|
||||
<EditableText
|
||||
value={deviceName}
|
||||
onChange={setDeviceName}
|
||||
|
Loading…
Reference in New Issue
Block a user