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:
parent
347b70018d
commit
181149d49b
@ -135,7 +135,9 @@ export const Application = observer(() => {
|
|||||||
|
|
||||||
<section id="other">
|
<section id="other">
|
||||||
<SubTitle title="Start-up"/>
|
<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
|
{/* <FormSwitch
|
||||||
control={
|
control={
|
||||||
<Switcher
|
<Switcher
|
||||||
|
|||||||
@ -21,27 +21,27 @@
|
|||||||
|
|
||||||
import styles from "./switch.module.scss";
|
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> {
|
interface Props extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Switch({ children, ...settings }: Props) {
|
export function Switch({ children, onClick, ...settings }: Props) {
|
||||||
const id = `switch-${Date.now()}`;
|
const id = `switch-${Date.now()}`;
|
||||||
|
|
||||||
const onClick = () => {
|
const onLabelClick = () => {
|
||||||
if (settings.disabled) {
|
if (settings.disabled || !onClick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.onClick?.();
|
onClick();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label htmlFor={id} className={styles.Switch} onClick={onClick}>
|
<label htmlFor={id} className={styles.Switch} onClick={onLabelClick}>
|
||||||
{children}
|
{children}
|
||||||
<input type="checkbox" role="switch" id={id} {...settings} readOnly/>
|
<input type="checkbox" role="switch" id={id} {...settings}/>
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user