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/>
|
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 { JSX } from "preact/jsx-runtime";
|
||||||
|
import { NiceSelect } from "./styled/index";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: string;
|
value: string;
|
||||||
@ -27,14 +26,41 @@ interface Props {
|
|||||||
}
|
}
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
canBeNull?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SelectList({ name, value, list, onChange, label, description }: Props): JSX.Element {
|
export function SelectList({ name, value, list, canBeNull, onChange, label, description }: Props): JSX.Element {
|
||||||
return <select name={name} id="slct">
|
console.log("==>", name, value)
|
||||||
<option selected disabled>Choose an option</option>
|
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)
|
{Object.keys(list)
|
||||||
.filter((l) => l !== value)
|
.filter((l) => l !== value)
|
||||||
.map(key => <option value={key} key={key}>{list[key]}</option> )
|
.map(key => <option value={key} key={key}>{list[key]}</option>)
|
||||||
}
|
}
|
||||||
</select>
|
</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;
|
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>
|
<div>
|
||||||
<section style={{ height: 'calc(320px - 34px - 16px)', overflow: 'auto' }}>
|
<section style={{ height: 'calc(320px - 34px - 16px)', overflow: 'auto' }}>
|
||||||
<h2><i18n.Translate>Wallet</i18n.Translate></h2>
|
<h2><i18n.Translate>Wallet</i18n.Translate></h2>
|
||||||
{/* <SelectList
|
<SelectList
|
||||||
value={lang}
|
value={lang}
|
||||||
onChange={changeLang}
|
onChange={changeLang}
|
||||||
name="lang"
|
name="lang"
|
||||||
list={names}
|
list={names}
|
||||||
label={i18n.str`Lang`}
|
label={i18n.str`Language`}
|
||||||
description="(Choose your preferred lang)"
|
description="(Choose your preferred lang)"
|
||||||
/> */}
|
/>
|
||||||
<EditableText
|
<EditableText
|
||||||
value={deviceName}
|
value={deviceName}
|
||||||
onChange={setDeviceName}
|
onChange={setDeviceName}
|
||||||
|
Loading…
Reference in New Issue
Block a user