From 80a78e3dd4a512a0b6ee93c9129a7eff23770c84 Mon Sep 17 00:00:00 2001 From: Peter Marsh <118171430+pmarsh-scottlogic@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:23:47 +0100 Subject: [PATCH] 307 add visual focus to all clickable elements (#344) Makes focus indicators consistent, and adds them back in where they were disabled. --------- Co-authored-by: Chris Wilton-Magras --- .../components/ControlPanel/ControlPanel.css | 25 ++++-- .../components/ControlPanel/ControlPanel.tsx | 2 +- .../src/components/DefenceBox/DefenceBox.css | 2 +- .../src/components/DefenceBox/DefenceBox.tsx | 2 +- .../DefenceBox/DefenceMechanism.css | 87 ++++++++++--------- .../DefenceBox/DefenceMechanism.tsx | 82 +++++++++-------- 6 files changed, 106 insertions(+), 94 deletions(-) diff --git a/frontend/src/components/ControlPanel/ControlPanel.css b/frontend/src/components/ControlPanel/ControlPanel.css index 24effdda9..d4ac18f83 100644 --- a/frontend/src/components/ControlPanel/ControlPanel.css +++ b/frontend/src/components/ControlPanel/ControlPanel.css @@ -1,18 +1,29 @@ -#control-panel { +.control-panel { height: 100%; overflow-y: auto; padding: 30px; } -.control-collapsible-section { +.control-panel .control-collapsible-section { background-color: var(--control-body-background-colour); - margin-bottom: 12px; - border-radius: 8px; - overflow: hidden; + margin-bottom: 0.75rem; + border-radius: 0.5rem; } -.control-collapsible-section-header { +.control-panel .control-collapsible-section-header { background-color: var(--control-header-background-colour); - padding: 12px 14px; + padding: 0.75rem; + border-radius: 0.5rem; cursor: default; } + +.control-panel + .control-collapsible-section[open] + .control-collapsible-section-header { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.control-panel .control-collapsible-section-header:focus-visible { + border-radius: 0; +} diff --git a/frontend/src/components/ControlPanel/ControlPanel.tsx b/frontend/src/components/ControlPanel/ControlPanel.tsx index 43251f553..a275590e8 100644 --- a/frontend/src/components/ControlPanel/ControlPanel.tsx +++ b/frontend/src/components/ControlPanel/ControlPanel.tsx @@ -52,7 +52,7 @@ function ControlPanel({ } return ( -
+
{/* hide defence box on levels 1 and 2 */} {(currentLevel === LEVEL_NAMES.LEVEL_3 || currentLevel === LEVEL_NAMES.SANDBOX) && ( diff --git a/frontend/src/components/DefenceBox/DefenceBox.css b/frontend/src/components/DefenceBox/DefenceBox.css index ca8968e61..3e40f9777 100644 --- a/frontend/src/components/DefenceBox/DefenceBox.css +++ b/frontend/src/components/DefenceBox/DefenceBox.css @@ -1,3 +1,3 @@ -#defence-box { +.defence-box { position: relative; } diff --git a/frontend/src/components/DefenceBox/DefenceBox.tsx b/frontend/src/components/DefenceBox/DefenceBox.tsx index 72791bd24..6edee3c03 100644 --- a/frontend/src/components/DefenceBox/DefenceBox.tsx +++ b/frontend/src/components/DefenceBox/DefenceBox.tsx @@ -24,7 +24,7 @@ function DefenceBox({ ) => Promise; }) { return ( -
+
{defences.map((defence, index) => { return ( .info-box { - font-size: 0.875rem; - margin-top: 4px; +.defence-mechanism > * { + padding: 0.75rem; } -.validation-text { - font-size: 0.875rem; - font-weight: 600; +.defence-mechanism > summary { + position: relative; + font-size: 1rem; } /* @@ -26,24 +16,40 @@ */ /* The switch - the box around the slider */ -.switch { +.defence-mechanism label.switch { position: absolute; - display: inline-block; - width: 29px; - height: 13px; - right: 16px; - top: 15px; + width: 2rem; + height: 1rem; + right: 0.75rem; + top: 0.75rem; +} + +.defence-mechanism label.switch:focus-within { + outline-style: auto; + border-radius: 0.5rem; } /* Hide default HTML checkbox */ -.switch input { +.defence-mechanism label.switch > input { opacity: 0; width: 0; height: 0; } +.defence-mechanism label.switch > input:checked + .slider { + background-color: var(--main-toggle-on-colour); +} + +.defence-mechanism label.switch > input:focus + .slider { + box-shadow: 0 0 1px var(--main-toggle-on-colour); +} + +.defence-mechanism label.switch > input:checked + .slider:before { + transform: translateX(1rem); +} + /* The slider */ -.slider { +.defence-mechanism label.switch > .slider { position: absolute; cursor: pointer; top: 0; @@ -51,39 +57,36 @@ right: 0; bottom: 0; background-color: var(--main-toggle-off-colour); - -webkit-transition: 0.4s; transition: 0.4s; } -.slider:before { - position: absolute; +.defence-mechanism label.switch > .slider:before { content: ""; - height: 13px; - width: 13px; + position: absolute; + height: 1rem; + width: 1rem; background-color: var(--main-toggle-ball-colour); - -webkit-transition: 0.4s; transition: 0.4s; } -input:checked + .slider { - background-color: var(--main-toggle-on-colour); +/* Rounded sliders */ +.defence-mechanism label.switch > .slider.round { + border-radius: 0.5rem; } -input:focus + .slider { - box-shadow: 0 0 1px var(--main-toggle-on-colour); +.defence-mechanism label.switch > .slider.round:before { + border-radius: 50%; } -input:checked + .slider:before { - -webkit-transform: translateX(16px); - -ms-transform: translateX(16px); - transform: translateX(16px); +.defence-mechanism .info-box { + font-size: 0.875rem; } -/* Rounded sliders */ -.slider.round { - border-radius: 34px; +.defence-mechanism .info-box :first-child { + margin-top: 0; } -.slider.round:before { - border-radius: 50%; +.defence-mechanism .info-box .validation-text { + font-size: inherit; + font-weight: 600; } diff --git a/frontend/src/components/DefenceBox/DefenceMechanism.tsx b/frontend/src/components/DefenceBox/DefenceMechanism.tsx index 9dab0ae7d..6549b70ae 100644 --- a/frontend/src/components/DefenceBox/DefenceMechanism.tsx +++ b/frontend/src/components/DefenceBox/DefenceMechanism.tsx @@ -65,48 +65,46 @@ function DefenceMechanism({ } return ( -
-
- {defenceDetail.name} -
-

{defenceDetail.info}

- - {showConfigurations && - defenceDetail.config.map((config) => { - return ( - - ); - })} - - {isConfigured && - (configValidated ? ( -

- defence successfully configured -

- ) : ( -

- invalid input - configuration failed -

- ))} -
-
- -
+
+ + {defenceDetail.name} + + +
+

{defenceDetail.info}

+ {showConfigurations && + defenceDetail.config.map((config) => { + return ( + + ); + })} + {isConfigured && + (configValidated ? ( +

+ defence successfully configured +

+ ) : ( +

+ invalid input - configuration failed +

+ ))} +
+
); }