Skip to content

Commit

Permalink
686 add skip to topbottom links to chat (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinrichs-scottlogic authored and chriswilty committed Apr 8, 2024
1 parent 5b8637b commit d984cbf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
46 changes: 44 additions & 2 deletions frontend/src/components/ChatBox/ChatBox.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.chat-box {
position: relative;
display: flex;
flex-direction: column;
gap: 1rem;
Expand All @@ -8,13 +9,13 @@
}

.chat-box .footer {
position: relative;
display: flex;
flex-direction: column;
gap: 1.25rem;
box-sizing: border-box;
width: 100%;
padding: 0.5rem 2rem 1.5rem;
padding: 2rem;
padding: 1rem 2rem;
}

.chat-box .footer label {
Expand Down Expand Up @@ -67,6 +68,47 @@
outline-offset: 0.1rem;
}

.chat-box .skip-link {
position: absolute;
left: 0;
width: 100%;
height: auto;
padding: 0.5rem 0;
background-color: var(--accent-background-colour);
color: var(--main-text-colour);
outline-offset: -0.25rem;
font-weight: 600;
text-align: center;
text-decoration: none;
opacity: 1;
transition: opacity 0.2s ease-in-out;
clip-path: none;
}

@media (prefers-reduced-motion: reduce) {
.chat-box .skip-link {
transition: none;
}
}

.chat-box .skip-link.skip-to-top {
top: -1.5rem;
}

.chat-box .skip-link.skip-to-bottom {
top: 0.125rem;
}

.chat-box .skip-link:not(:focus, :active) {
position: absolute;
overflow: hidden;
width: 1px;
height: 1px;
white-space: nowrap;
opacity: 0.1;
clip-path: inset(50%);
}

@media only screen and (width <= 70.5rem) {
.chat-box .footer {
gap: 0.5rem;
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/components/ChatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,19 @@ function ChatBox({
}

return (
<div className="chat-box">
<div className="chat-box" id="chat-box">
<a
className="skip-to-bottom skip-link "
id="skip-to-bottom"
href="#chat-box-input"
>
<span aria-hidden>&#129035;&nbsp;</span>skip to chat input
</a>
<ChatBoxFeed messages={messages} />
<div className="footer">
<a className="skip-to-top skip-link " href="#skip-to-bottom">
<span aria-hidden>&#129033;&nbsp;</span>skip to top of chat
</a>
<div className="messages">
<ChatBoxInput
content={chatInput}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/ChatBox/ChatBoxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function ChatBoxInput({
characterLimit={CHARACTER_LIMIT}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={true}
id="chat-box-input"
/>
</label>
);
Expand Down

0 comments on commit d984cbf

Please sign in to comment.