Skip to content

Commit 0b72b05

Browse files
authored
Drawer/chat accessibility fixes (#2214)
* Chevron icon to close / slide up * Rotating open/close chevron * Upgrade Smoot Design * Fix to wait for render cycle before scroll to top * Upgrade smoot-design
1 parent a06ae69 commit 0b72b05

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

frontends/main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@emotion/cache": "^11.13.1",
1515
"@emotion/styled": "^11.11.0",
1616
"@mitodl/course-search-utils": "3.3.2",
17-
"@mitodl/smoot-design": "^6.1.0",
17+
"@mitodl/smoot-design": "^6.2.2",
1818
"@next/bundle-analyzer": "^14.2.15",
1919
"@remixicon/react": "^4.2.0",
2020
"@sentry/nextjs": "^9.0.0",

frontends/main/src/page-components/LearningResourceExpanded/AiChatSyllabusSlideDown.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React, { useRef, useEffect } from "react"
22
import { Typography, styled } from "ol-components"
33
import { Button } from "@mitodl/smoot-design"
4-
import {
5-
RiSparkling2Line,
6-
RiArrowDownSLine,
7-
RiCloseLine,
8-
} from "@remixicon/react"
4+
import { RiSparkling2Line, RiArrowDownSLine } from "@remixicon/react"
95
import type { AiChatProps } from "@mitodl/smoot-design/ai"
106
import { LearningResource } from "api"
117
import { AiChat } from "@mitodl/smoot-design/ai"
@@ -74,31 +70,21 @@ const StyledButton = styled(Button)<{ open: boolean }>(({ theme, open }) => ({
7470
"&&": {
7571
":hover": {
7672
backgroundColor: theme.custom.colors.white,
77-
borderColor: open
78-
? theme.custom.colors.darkGray1
79-
: theme.custom.colors.silverGray,
80-
"svg:last-child": {
81-
backgroundColor: open ? theme.custom.colors.darkGray1 : "transparent",
82-
},
73+
borderColor: theme.custom.colors.silverGray,
8374
},
8475
},
76+
"svg:last-child": {
77+
transform: open ? "rotate(-180deg)" : "rotate(0deg)",
78+
transition: "transform 0.3s ease-in-out",
79+
},
8580
}))
8681

87-
const OpenChevron = styled(RiArrowDownSLine)(({ theme }) => ({
82+
const Chevron = styled(RiArrowDownSLine)(({ theme }) => ({
8883
fill: theme.custom.colors.mitRed,
8984
position: "absolute",
9085
right: "9px",
9186
}))
9287

93-
const CloseButton = styled(RiCloseLine)(({ theme }) => ({
94-
fill: theme.custom.colors.white,
95-
position: "absolute",
96-
right: "0",
97-
padding: "9px",
98-
boxSizing: "content-box",
99-
backgroundColor: theme.custom.colors.silverGray,
100-
}))
101-
10288
const StyledAiChat = styled(AiChat)<{
10389
topPosition: number
10490
}>(({ topPosition }) => ({
@@ -146,7 +132,7 @@ export const AiChatSyllabusOpener = ({
146132
<Typography variant="body1">
147133
Ask<strong>TIM</strong> about this course
148134
</Typography>
149-
{open ? <CloseButton /> : <OpenChevron />}
135+
<Chevron />
150136
</StyledButton>
151137
</Opener>
152138
)

frontends/main/src/page-components/LearningResourceExpanded/LearningResourceExpanded.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ const LearningResourceExpanded: React.FC<LearningResourceExpandedProps> = ({
174174
outerContainerRef.current.scrollTo(0, 0)
175175
}
176176
if (scrollElement) {
177-
scrollElement.scrollTop = 0
177+
requestAnimationFrame(() => {
178+
scrollElement.scrollTop = 0
179+
})
178180
}
179181
}, [resourceId, scrollElement])
180182

yarn.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)