Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

686 add skip to topbottom links to chat #846

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, you don't need opacity or clip-path here, as those are their default values.

}

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does & #129033; &nbsp mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those'll be the arrow icons, as unicode escape codes. There are a heap of arrows available, impossible to choose!

https://www.w3schools.com/charsets/ref_utf_arrows.asp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbsp = non-breaking space

</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
Loading