Skip to content

Commit

Permalink
Fixing keyboard navigation inside modals
Browse files Browse the repository at this point in the history
  • Loading branch information
4lejandrito committed Nov 8, 2022
1 parent 923b918 commit 200181d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
8 changes: 5 additions & 3 deletions packages/creepyface-site/src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ export default function Modal({
</div>
)}
>
<Button className="cancel" onClick={onClose}>
<Icon name="times" />
</Button>
<main id={id}>{children}</main>
{!barebones && (
<Button className="cancel" onClick={onClose}>
<Icon name="times" />
</Button>
)}
</ReactModal>
)
}
1 change: 1 addition & 0 deletions packages/creepyface-site/src/components/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function Video(props: {
return (
<div className="creepy video">
<video
tabIndex={-1}
playsInline
ref={videoRef}
autoPlay={true}
Expand Down
17 changes: 8 additions & 9 deletions packages/creepyface-site/src/scss/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
&:not(.link):not(.creepy) {
&:not(.custom) {
border-color: $color;
.light & {
border-color: currentColor;
}
}
&:disabled {
opacity: 0.5;
Expand All @@ -16,6 +19,11 @@
background: $color;
color: $background;
text-decoration: none;
.light & {
background: $color-text;
color: $color;
border-color: $color-text;
}
}
}
}
Expand Down Expand Up @@ -77,12 +85,3 @@ button,
right: -$spacing / 2;
}
}

.light button,
.light .button {
@include button($color-text, white);
}

.danger button {
@include button(white, $color-danger);
}
16 changes: 11 additions & 5 deletions packages/creepyface-site/src/scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $spacing: 1rem;
$color-main: #1abc9c;
$color-danger: #dc3545;
$color-text: var(--color-custom-primary, #{darken($color-main, 5%)});
$color-shadow: var(--color-custom-primary, #{rgba($color-main, 0.5)});
$color-background: var(--color-custom-secondary, #{darken($color-main, 8%)});
$color-gradient: var(--color-custom-secondary, #{darken($color-main, 5%)});
$main-creepyface-width: 8.5em;
Expand Down Expand Up @@ -54,6 +55,9 @@ $main-creepyface-height: math.div($main-creepyface-width * 45, 35);

@mixin link($color: white) {
color: $color;
.light & {
color: currentColor;
}
font-weight: bold;
display: inline-block;
outline: 0 !important;
Expand All @@ -64,17 +68,19 @@ $main-creepyface-height: math.div($main-creepyface-width * 45, 35);
}
&:focus-visible {
box-shadow: 0 0 0 0.2rem rgba($color, 0.5);
.light & {
box-shadow: 0 0 0 0.2rem $color-shadow;
}
.danger & {
box-shadow: 0 0 0 0.2rem rgba(white, 0.5) !important;
}
}
&:not(:disabled):hover {
text-decoration-line: underline;
color: $color;
color: inherit;
}
}

.danger a {
@include link(white);
}

%shadow {
box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.31);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/creepyface-site/src/scss/_modal.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.ReactModalPortal {
z-index: 1;
position: absolute;
height: 1px;
width: 1px;
.ReactModal__Overlay {
background-color: transparent !important;
display: flex;
Expand Down
6 changes: 0 additions & 6 deletions packages/creepyface-site/src/scss/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,4 @@ kbd {

a {
@include link;
.light & {
@include link($color-text);
}
.danger & {
@include link(white);
}
}

0 comments on commit 200181d

Please sign in to comment.