Skip to content

Commit

Permalink
a11y: add title text for view all links (github#24193)
Browse files Browse the repository at this point in the history
* Add optional 'view all' title text in the context

* Use viewAllTitleText in ArticleList

* Set viewAllTitleText for sections with 'view all' links
  • Loading branch information
rsese authored Jan 11, 2022
1 parent 3d2a641 commit d31d6a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/context/ProductLandingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type ProductLandingContextT = {
featuredArticles: Array<{
label: string // Guides
viewAllHref?: string // If provided, adds a "View All ->" to the header
viewAllTitleText?: string // Adds 'title' attribute text for the "View All" href
articles: Array<FeaturedLink>
}>
changelogUrl?: string
Expand Down
14 changes: 12 additions & 2 deletions components/landing/ArticleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ import { BumpLink } from 'components/ui/BumpLink'
export type ArticleListPropsT = {
title?: string
viewAllHref?: string
viewAllTitleText?: string
articles: Array<FeaturedLink>
}

export const ArticleList = ({ title, viewAllHref, articles }: ArticleListPropsT) => {
export const ArticleList = ({
title,
viewAllHref,
viewAllTitleText,
articles,
}: ArticleListPropsT) => {
return (
<>
{title && (
<div className="mb-4 d-flex flex-items-baseline">
<h3 className={cx('f4 text-semibold')}>{title}</h3>
{viewAllHref && (
<Link href={viewAllHref} className="ml-4">
<Link
href={viewAllHref}
className="ml-4"
{...(viewAllTitleText ? { title: viewAllTitleText } : {})}
>
View all <ArrowRightIcon size={14} className="v-align-middle" />
</Link>
)}
Expand Down
2 changes: 2 additions & 0 deletions components/landing/FeaturedArticles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const FeaturedArticles = () => {
<ArticleList
title={section.label}
viewAllHref={section.viewAllHref}
{...(section.viewAllHref ? { viewAllTitleText: `All ${section.label}` } : {})}
articles={section.articles}
/>
</div>
Expand All @@ -31,6 +32,7 @@ export const FeaturedArticles = () => {
<ArticleList
title={t('whats_new')}
viewAllHref={changelogUrl}
viewAllTitleText="All ChangeLog posts"
articles={(whatsNewChangelog || []).map((link) => {
return {
title: link.title,
Expand Down

0 comments on commit d31d6a5

Please sign in to comment.