Skip to content

Commit

Permalink
#1378 Use specific aria props in LocalizedLink (#1379)
Browse files Browse the repository at this point in the history
* Rename aria to ariaProps on LocalizedLink

avoids name colision with future react prop while allowing for flexibility in what aria props are passed

* Update CHANGELOG to document change

* Use aria attributes with the -

* Define aria-current type with AriaAttributes
  • Loading branch information
akegan committed Jun 30, 2021
1 parent b199736 commit 969baa8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ All notable changes to this project will be documented in this file. The format
- Fixed:

- Correct LinkButton and other styles in Storybook ([#1309](https://github.com/bloom-housing/bloom/pull/1309)) (Jared White & Jesse James Arnold)
- Fix aria reserved for future use warning ([#1378](https://github.com/bloom-housing/bloom/issues/1378)) (Andrea Egan)

## 1.0.0 / 2021-05-21

Expand Down
8 changes: 5 additions & 3 deletions ui-components/src/config/NavigationContext.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { createContext, FunctionComponent } from "react"
import React, { AriaAttributes, createContext, FunctionComponent } from "react"
import { UrlObject } from "url"

type Url = UrlObject | string

export interface LinkProps {
href: string
aria?: Record<string, string>
"aria-label"?: string
"aria-current"?: AriaAttributes["aria-current"]
className?: string
tabIndex?: number
}
Expand Down Expand Up @@ -36,7 +37,8 @@ export const NavigationContext = createContext<NavigationContextProps>({
e.preventDefault()
alert(`You clicked: ${props.href}`)
}}
{...props.aria}
{...(props["aria-label"] ? { "aria-label": props["aria-label"] } : {})}
{...(props["aria-current"] ? { "aria-current": props["aria-current"] } : {})}
>
{props.children}
</a>
Expand Down
2 changes: 1 addition & 1 deletion ui-components/src/headers/SiteHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const SiteHeader = (props: SiteHeaderProps) => {
<LocalizedLink
className={`navbar-item logo ${logoClass} ${getLogoWidthClass()}`}
href="/"
aria={{ "aria-label": "homepage" }}
aria-label="homepage"
>
<div
className={`logo__lockup ${getLogoWidthClass()} ${
Expand Down
2 changes: 1 addition & 1 deletion ui-components/src/navigation/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const BreadcrumbLink = (props: { href: string; children: React.ReactNode; curren
<li>
<LocalizedLink
className={props.current ? "is-active" : undefined}
aria={props.current ? { "aria-current": "page" } : undefined}
aria-current={props.current ? "page" : undefined}
href={props.href}
>
{props.children}
Expand Down
2 changes: 1 addition & 1 deletion ui-components/src/navigation/TabNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const TabNavItem = (props: TabNavItemProps) => {
>
<LocalizedLink
className={props.current ? "is-active" : undefined}
aria={props.current ? { "aria-current": "page" } : undefined}
aria-current={props.current ? "page" : undefined}
href={props.href}
tabIndex={props.current ? 0 : -1}
>
Expand Down

0 comments on commit 969baa8

Please sign in to comment.