Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const DrawerContent: React.FC<{
) => {
return (
<ResourceCarousel
titleComponent="p"
titleComponent="h3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Small suggestion to help us avoid doing this again. Didn't cause any type errors.

diff --git a/frontends/main/src/page-components/ResourceCarousel/ResourceCarousel.tsx b/frontends/main/src/page-components/ResourceCarousel/ResourceCarousel.tsx
index a7ea37a1f..f5a897cdd 100644
--- a/frontends/main/src/page-components/ResourceCarousel/ResourceCarousel.tsx
+++ b/frontends/main/src/page-components/ResourceCarousel/ResourceCarousel.tsx
@@ -175,8 +175,11 @@ type ResourceCarouselProps = {
   "data-testid"?: string
   /**
    * Element type for the carousel title
+   *
+   * Note: This could allow wider elements, but we want to restrict it to
+   * headings for semantic purposes.
    */
-  titleComponent?: React.ElementType
+  titleComponent?: "h2" | "h3" | "h4" | "h5" | "h6"
   titleVariant?: TypographyProps["variant"]
   excludeResourceId?: number
 }
@@ -225,7 +228,7 @@ const ResourceCarousel: React.FC<ResourceCarouselProps> = ({
   title,
   className,
   isLoading,
-  titleComponent = "h4",
+  titleComponent,
   titleVariant = "h4",
   excludeResourceId,
 }) => {

titleVariant="subtitle1"
title={title}
config={[
Expand All @@ -132,7 +132,7 @@ const DrawerContent: React.FC<{
}
const similarResourcesCarousel = (
<ResourceCarousel
titleComponent="p"
titleComponent="h3"
titleVariant="subtitle1"
title="Similar Learning Resources"
config={[
Expand All @@ -154,7 +154,7 @@ const DrawerContent: React.FC<{
const topicCarousels = topics?.map((topic) => (
<ResourceCarousel
key={topic.id}
titleComponent="p"
titleComponent="h3"
titleVariant="subtitle1"
title={`Learning Resources in "${topic.name}"`}
config={TopicCarouselConfig(topic.name)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,22 @@ const TitleSection: React.FC<{

return (
<TitleContainer ref={ref}>
<Typography
variant="h4"
id={titleId}
width="100%"
color={theme.custom.colors.darkGray2}
>
<div id={titleId}>
<Typography
variant="subtitle2"
color={theme.custom.colors.silverGrayDark}
>
{type}
</Typography>
<span lang={resource?.runs?.[0]?.languages?.[0]}>{title}</span>
</Typography>
<Typography
variant="h4"
component="h2"
color={theme.custom.colors.darkGray2}
lang={resource?.runs?.[0]?.languages?.[0]}
>
{title}
</Typography>
</div>
<CloseButton
variant="text"
size="medium"
Expand Down
Loading