1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

onClick fine-tunings

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-12-25 20:43:52 +03:00
parent 347b70018d
commit 181149d49b
2 changed files with 10 additions and 8 deletions

View File

@ -135,7 +135,9 @@ export const Application = observer(() => {
<section id="other">
<SubTitle title="Start-up"/>
<Switch checked={userStore.openAtLogin}>Automatically start Lens on login</Switch>
<Switch checked={userStore.openAtLogin} onChange={v => userStore.openAtLogin = v.target.checked}>
Automatically start Lens on login
</Switch>
{/* <FormSwitch
control={
<Switcher

View File

@ -21,27 +21,27 @@
import styles from "./switch.module.scss";
import React, { DetailedHTMLProps, InputHTMLAttributes } from "react";
import React, { DetailedHTMLProps, InputHTMLAttributes } from "react";
interface Props extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
onClick?: () => void;
}
export function Switch({ children, ...settings }: Props) {
export function Switch({ children, onClick, ...settings }: Props) {
const id = `switch-${Date.now()}`;
const onClick = () => {
if (settings.disabled) {
const onLabelClick = () => {
if (settings.disabled || !onClick) {
return;
}
settings.onClick?.();
onClick();
};
return (
<label htmlFor={id} className={styles.Switch} onClick={onClick}>
<label htmlFor={id} className={styles.Switch} onClick={onLabelClick}>
{children}
<input type="checkbox" role="switch" id={id} {...settings} readOnly/>
<input type="checkbox" role="switch" id={id} {...settings}/>
</label>
);
}