Skip to content

Commit

Permalink
fix: remove focus outline artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Apr 9, 2021
1 parent e12b9ec commit 369b748
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 16 deletions.
3 changes: 1 addition & 2 deletions app/assets/javascripts/components/SearchOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function SearchOptions({ appState }: Props) {
open={open}
onChange={() => {
const { height } = buttonRef.current.getBoundingClientRect();
const extraVerticalBreathingRoom = 4;
setOptionsPanelTop(height + extraVerticalBreathingRoom);
setOptionsPanelTop(height);
setOpen((prevOpen) => !prevOpen);
}}
>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/notes/notes-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
aria-role="button"
)
search-options(
class="ml-2 h-20px"
class="ml-2"
app-state='self.appState'
)
no-account-warning(
Expand Down
92 changes: 80 additions & 12 deletions app/assets/stylesheets/_sn.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,62 @@
/* Components and utilities that have yet to be extracted to StyleKit. */
/* Components and utilities that are good candidates for extraction to StyleKit. */

.outline-none {
outline: none;
}

.border-2 {
border-width: 2px;
}

.border-background {
border-color: var(--sn-stylekit-background-color);
}

.focus-within\:border-background:focus-within {
border-color: var(--sn-stylekit-background-color);
}

.border-transparent {
border-color: var(--sn-stylekit-background-color);
}

.bg-clip-padding {
background-clip: padding-box;
}

.ring-info {
box-shadow: 0 0 0 2px var(--sn-stylekit-info-color);
}

.focus\:ring-info:focus {
@extend .ring-info;
}

.focus-within\:ring-info:focus-within {
@extend .ring-info;
}

.border-transparent {
border-color: transparent;
}

/**
* A button that is just an icon. Separated from .sn-button because there
* is almost no style overlap.
*/
.sn-icon-button {
@extend .border-2;
@extend .border-transparent;
@extend .bg-clip-padding;
@extend .m-0;
@extend .p-0;
@extend .bg-transparent;
@extend .cursor-pointer;
@extend .rounded-full;
@extend .color-neutral;
@extend .focus\:outline-none;
@extend .focus\:ring-info;
}

.sn-dropdown {
@extend .absolute;
Expand All @@ -17,43 +75,53 @@
right: 0;
}

&[data-state="collapsed"] {
&[data-state='collapsed'] {
display: none;
}
}

$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;
@extend .ease-out;
@extend .rounded-full;
@extend .transition-background;
width: 31px;
height: 18px;

@extend .bg-clip-padding;
@extend .cursor-pointer;
@extend .focus-within\:padded-ring-info;
@extend .border-transparent;
width: $switch-width;
height: 22px;
border-style: solid;
border-width: $border-width;
@extend .focus-within\:ring-info;
@extend .focus-within\:outline-none;
@extend .focus-within\:border-background;
}

.sn-switch-handle {
@extend .absolute;
@extend .block;
left: 2px;
width: 14px;
height: 14px;
top: 50%;

@extend .bg-default;
@extend .rounded-full;

@extend .ease-out;
@extend .transition-transform;
@extend .duration-150;

left: $border-width;
width: $switch-handle-size;
height: $switch-handle-size;
top: 50%;
transform: translate(0px, -50%);

&.sn-switch-handle-right {
transform: translate(31px - 18px, -50%);
transform: translate(
$switch-width - $switch-handle-size - ($border-width * 4),
-50%
);
}
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/_stylekit-sub.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ button.sk-a {
min-height: 24px;
}

*:focus-visible {
outline: none;
}

*:focus {
outline: none;
box-shadow: 0 0 0 2px var(--sn-stylekit-info-color);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"pug-loader": "^2.4.0",
"sass-loader": "^8.0.2",
"serve-static": "^1.14.1",
"sn-stylekit": "github:standardnotes/StyleKit#cd0b2f90e2d21818639baa28b1f6bc7991a8f6be",
"sn-stylekit": "github:standardnotes/StyleKit#c64573b229ac9154e480cde3b5fdab78c75b3530",
"ts-loader": "^8.0.17",
"typescript": "^4.1.5",
"typescript-eslint": "0.0.1-alpha.0",
Expand Down

0 comments on commit 369b748

Please sign in to comment.