From ba32c12b9cd1a112549b461a446b98b8a2d58ecd Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 11 Sep 2025 11:32:33 +0200 Subject: [PATCH] [CB-5023] Add vizualization for focus on switchers (#3677) * dbeaver/pro#4862 adds focus on switches * fixes border radius * less border-radius * applies hack with borders and position to save border radius and offset * removes variable * fix: applies focus only for tab * removes focus on ESC button * removes onkeydown * cleanup --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../FormControls/Checkboxes/Switch.module.css | 92 ++++++++++++------- .../src/FormControls/Checkboxes/Switch.tsx | 4 +- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.module.css b/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.module.css index 6592a0de39..757e43d5a7 100644 --- a/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.module.css +++ b/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.module.css @@ -5,46 +5,72 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -.switchControl { - composes: theme-switch from global; -} -.disabled { - composes: theme-switch--disabled mdc-switch--disabled from global; -} +@layer components { + .field { + --dbv-kit-control-outline-offset: -8px; + position: relative; -.checked { - composes: theme-switch--checked mdc-switch--checked from global; -} + &::before { + content: ''; + position: absolute; + top: var(--dbv-kit-control-outline-offset); + left: var(--dbv-kit-control-outline-offset); + right: var(--dbv-kit-control-outline-offset); + bottom: var(--dbv-kit-control-outline-offset); + border-radius: var(--dbv-kit-control-border-radius); + border: var(--dbv-kit-control-outline-width) solid transparent; -.switchControlTrack { - composes: theme-switch__track from global; -} + pointer-events: none; + } -.switchInput { - composes: theme-switch_native-control from global; -} + &:has(.switchInput:focus-visible)::before { + border-color: var(--dbv-kit-control-outline-color); + border-width: var(--dbv-kit-control-outline-width); + } + } -.switchControlUnderlay { - composes: theme-switch__thumb-underlay from global; -} + .switchControl { + composes: theme-switch from global; + } -.switchControlThumb { - composes: theme-switch__thumb from global; -} + .disabled { + composes: theme-switch--disabled mdc-switch--disabled from global; + } -.switchBody { - display: flex; - align-items: center; - composes: theme-typography--body1 from global; + .checked { + composes: theme-switch--checked mdc-switch--checked from global; + } - & .fieldLabel { - cursor: pointer; - user-select: none; - display: block; - padding-left: 18px; - min-width: 50px; - white-space: pre-wrap; - font-weight: 500; + .switchControlTrack { + composes: theme-switch__track from global; + } + + .switchInput { + composes: theme-switch_native-control from global; + } + + .switchControlUnderlay { + composes: theme-switch__thumb-underlay from global; + } + + .switchControlThumb { + composes: theme-switch__thumb from global; + } + + .switchBody { + display: flex; + align-items: center; + composes: theme-typography--body1 from global; + + & .fieldLabel { + cursor: pointer; + user-select: none; + display: block; + padding-left: 18px; + min-width: 50px; + white-space: pre-wrap; + font-weight: 500; + } } } diff --git a/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.tsx b/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.tsx index 4149698582..31da7bc792 100644 --- a/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.tsx +++ b/webapp/packages/core-blocks/src/FormControls/Checkboxes/Switch.tsx @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2025 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ export const Switch: SwitchType = observer(function Switch({ } return ( - +