From 9ead8efee654b32e607897b3ee51fd27d28f4873 Mon Sep 17 00:00:00 2001 From: Anton SHEPILOV Date: Tue, 7 May 2024 15:16:34 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84Remove=20on-focus=20border=20for=20?= =?UTF-8?q?the=20select=20and=20radiobutton=20inputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/atoms/input/input-checkbox-slider.tsx | 30 ++++++++++++------- .../src/app/atoms/input/input-select.tsx | 8 ++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tdrive/frontend/src/app/atoms/input/input-checkbox-slider.tsx b/tdrive/frontend/src/app/atoms/input/input-checkbox-slider.tsx index 8a18fd13..dc658dc7 100644 --- a/tdrive/frontend/src/app/atoms/input/input-checkbox-slider.tsx +++ b/tdrive/frontend/src/app/atoms/input/input-checkbox-slider.tsx @@ -1,17 +1,27 @@ +import { isUndefined } from "lodash"; + interface CheckboxSliderProps extends React.InputHTMLAttributes { checked?: boolean; disabled?: boolean; + noFocusBorder?: boolean; } /** Just classes up a checkbox to look like a slider. Deviates from onChange etc for * compatibility with `InputHTMLAttributes`, to expose eg. id to use with htmlFor. */ -export const CheckboxSlider = (props: CheckboxSliderProps) => - ; +export const CheckboxSlider = (props: CheckboxSliderProps) => { + let styles = {}; + const noFocus = isUndefined(props.noFocusBorder) ? true : props.noFocusBorder; + if (noFocus) styles = {boxShadow: "none", borderColor: "inherit"}; + + return ( + ) +} diff --git a/tdrive/frontend/src/app/atoms/input/input-select.tsx b/tdrive/frontend/src/app/atoms/input/input-select.tsx index 0557c50a..f9573e74 100644 --- a/tdrive/frontend/src/app/atoms/input/input-select.tsx +++ b/tdrive/frontend/src/app/atoms/input/input-select.tsx @@ -1,4 +1,4 @@ -import _ from 'lodash'; +import _, { isUndefined } from "lodash"; import { defaultInputClassName, errorInputClassName, ThemeName } from './input-text'; export type SelectSize = 'md' | 'lg' | 'sm'; @@ -9,6 +9,7 @@ interface InputProps extends Omit, size?: SelectSize; className?: string; children?: React.ReactNode; + noFocusBorder?: boolean; } export function Select(props: InputProps) { @@ -21,8 +22,13 @@ export function Select(props: InputProps) { else if (props.size === 'sm') inputClassName = inputClassName + ' text-sm h-7 py-0 px-3'; else inputClassName = inputClassName + ' text-base h-9 py-1'; + let styles = {}; + const noFocus = isUndefined(props.noFocusBorder) ? true : props.noFocusBorder; + if (noFocus) styles = {boxShadow: "none", borderColor: "inherit"}; + return (