1
0
mirror of synced 2025-12-25 02:17:36 -05:00

a11y: add title text for view all links (#24193)

* Add optional 'view all' title text in the context

* Use viewAllTitleText in ArticleList

* Set viewAllTitleText for sections with 'view all' links
This commit is contained in:
Robert Sese
2022-01-10 19:30:10 -06:00
committed by GitHub
parent 3d2a641f6f
commit d31d6a5b4e
3 changed files with 15 additions and 2 deletions

View File

@@ -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

View File

@@ -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>
)}

View File

@@ -20,6 +20,7 @@ export const FeaturedArticles = () => {
<ArticleList
title={section.label}
viewAllHref={section.viewAllHref}
{...(section.viewAllHref ? { viewAllTitleText: `All ${section.label}` } : {})}
articles={section.articles}
/>
</div>
@@ -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,