From fb12b26a6038dc6a7d42d354ebee41387fe3713f Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Thu, 20 May 2021 14:57:53 -0300 Subject: [PATCH] styles: make switch size responsive to font size --- app/assets/stylesheets/_sn.scss | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/_sn.scss b/app/assets/stylesheets/_sn.scss index b9d13c913..253373108 100644 --- a/app/assets/stylesheets/_sn.scss +++ b/app/assets/stylesheets/_sn.scss @@ -111,6 +111,10 @@ line-height: 2.25rem; } +.w-3.\5 { + width: 0.875rem; +} + .w-5 { width: 1.25rem; } @@ -127,6 +131,14 @@ height: 1px; } +.h-3.\5 { + height: 0.875rem; +} + +.h-4.\5 { + height: 1.125rem; +} + .h-5 { height: 1.25rem; } @@ -206,10 +218,6 @@ } } -$switch-width: 35px; -$switch-handle-size: 14px; -$border-width: 2px; - /** Lesser specificity will give priority to reach's styles */ [data-reach-custom-checkbox-container].sn-switch { @extend .duration-150; @@ -219,13 +227,14 @@ $border-width: 2px; @extend .bg-clip-padding; @extend .cursor-pointer; @extend .border-transparent; - width: $switch-width; - height: 22px; - border-style: solid; - border-width: $border-width; + @extend .w-8; + @extend .h-4.\5 ; + @extend .border-2; + @extend .border-solid; @extend .focus-within\:ring-info; @extend .focus-within\:outline-none; @extend .focus-within\:border-background; + box-sizing: content-box; } .sn-switch-handle { @@ -238,15 +247,15 @@ $border-width: 2px; @extend .transition-transform; @extend .duration-150; - left: $border-width; - width: $switch-handle-size; - height: $switch-handle-size; + left: 2px; + @extend .w-3.\5 ; + @extend .h-3.\5 ; top: 50%; transform: translate(0px, -50%); &.sn-switch-handle-right { transform: translate( - $switch-width - $switch-handle-size - ($border-width * 4), + calc(2rem - 1.125rem), -50% ); }