diff --git a/.changeset/popular-rivers-warn.md b/.changeset/popular-rivers-warn.md new file mode 100644 index 00000000000..9e94618d6b6 --- /dev/null +++ b/.changeset/popular-rivers-warn.md @@ -0,0 +1,5 @@ +--- +'@primer/react': major +--- + +Remove support for `activeClassName` for Breadcrumb, SubNav, TabNav, UnderlineNav diff --git a/docs/content/Breadcrumbs.mdx b/docs/content/Breadcrumbs.mdx index 93f5df36824..023e734a444 100644 --- a/docs/content/Breadcrumbs.mdx +++ b/docs/content/Breadcrumbs.mdx @@ -18,11 +18,6 @@ Breadcrumbs are used to show taxonomical context on pages that are many levels d - Do not have a section-level navigation - May need the ability to quickly go back to the previous (parent) page -To use Breadcrumbs with [react-router](https://github.com/ReactTraining/react-router) or -[react-router-dom](https://www.npmjs.com/package/react-router-dom), pass -`as={NavLink}` and omit the `selected` prop. -This ensures that the NavLink gets `activeClassName='selected'` - ## Examples ```jsx live diff --git a/docs/content/SubNav.mdx b/docs/content/SubNav.mdx index 849fb8bb29d..018c1defbe9 100644 --- a/docs/content/SubNav.mdx +++ b/docs/content/SubNav.mdx @@ -6,13 +6,6 @@ status: Alpha import data from '../../src/SubNav/SubNav.docs.json' -Use the SubNav component for navigation on a dashboard-type interface with another set of navigation components above it. This helps distinguish navigation hierarchy. - -To use SubNav with [react-router](https://github.com/ReactTraining/react-router) or -[react-router-dom](https://www.npmjs.com/package/react-router-dom), pass -`as={NavLink}` and omit the `selected` prop. -This ensures that the NavLink gets `activeClassName='selected'` - **Attention:** Make sure to properly label your `SubNav` with an `aria-label` to provide context about the type of navigation contained in `SubNav`. ## Examples diff --git a/docs/content/TabNav.mdx b/docs/content/TabNav.mdx index 8eba20c5339..de41bc0e5c9 100644 --- a/docs/content/TabNav.mdx +++ b/docs/content/TabNav.mdx @@ -6,11 +6,6 @@ status: Alpha import data from '../../src/TabNav/TabNav.docs.json' -To use TabNav with [react-router](https://github.com/ReactTraining/react-router) or -[react-router-dom](https://www.npmjs.com/package/react-router-dom), pass -`as={NavLink}` and omit the `selected` prop. -This ensures that the NavLink gets `activeClassName='selected'` - **Attention:** Make sure to properly label your `TabNav` with an `aria-label` to provide context about the type of navigation contained in `TabNav`. ## Examples diff --git a/docs/content/UnderlineNav.mdx b/docs/content/UnderlineNav.mdx index ed666ca0cc4..f4edb989885 100644 --- a/docs/content/UnderlineNav.mdx +++ b/docs/content/UnderlineNav.mdx @@ -12,11 +12,6 @@ Use the UnderlineNav component to style navigation with a minimal underlined sel UnderlineNav is deprecated and will be replaced by the draft `UnderlineNav` in the next major release. See [the draft UnderlineNav's docs](/drafts/UnderlineNav2) for more details. -To use UnderlineNav with [react-router](https://github.com/ReactTraining/react-router) or -[react-router-dom](https://www.npmjs.com/package/react-router-dom), pass -`as={NavLink}` and omit the `selected` prop. -This ensures that the NavLink gets `activeClassName='selected'` - **Attention:** Make sure to properly label your `UnderlineNav` with an `aria-label` to provide context about the type of navigation contained in `UnderlineNav`. ## Examples diff --git a/src/Breadcrumbs/Breadcrumbs.tsx b/src/Breadcrumbs/Breadcrumbs.tsx index f479d7c04ec..b5e644c5d62 100644 --- a/src/Breadcrumbs/Breadcrumbs.tsx +++ b/src/Breadcrumbs/Breadcrumbs.tsx @@ -59,7 +59,6 @@ type StyledBreadcrumbsItemProps = { } & SxProp const BreadcrumbsItem = styled.a.attrs(props => ({ - activeClassName: typeof props.to === 'string' ? 'selected' : undefined, className: classnames(props.selected && SELECTED_CLASS, props.className), 'aria-current': props.selected ? 'page' : null, }))` diff --git a/src/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx b/src/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx index 0513b89e809..b3f2a90b240 100644 --- a/src/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx +++ b/src/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx @@ -20,9 +20,4 @@ describe('Breadcrumbs.Item', () => { it('respects the "selected" prop', () => { expect(render()).toMatchSnapshot() }) - - it('adds activeClassName={SELECTED_CLASS} when it gets a "to" prop', () => { - const Link = ({theme: _ignoredTheme, ...props}: Record) =>
- expect(render()).toMatchSnapshot() - }) }) diff --git a/src/Breadcrumbs/__tests__/__snapshots__/BreadcrumbsItem.test.tsx.snap b/src/Breadcrumbs/__tests__/__snapshots__/BreadcrumbsItem.test.tsx.snap index 39ec4605f7d..4a5dfe6b84f 100644 --- a/src/Breadcrumbs/__tests__/__snapshots__/BreadcrumbsItem.test.tsx.snap +++ b/src/Breadcrumbs/__tests__/__snapshots__/BreadcrumbsItem.test.tsx.snap @@ -1,32 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Breadcrumbs.Item adds activeClassName={SELECTED_CLASS} when it gets a "to" prop 1`] = ` -.c0 { - color: #0969da; - display: inline-block; - font-size: 14px; - -webkit-text-decoration: none; - text-decoration: none; -} - -.c0:hover { - -webkit-text-decoration: underline; - text-decoration: underline; -} - -.c0.selected { - color: #1F2328; - pointer-events: none; -} - -
-`; - exports[`Breadcrumbs.Item renders consistently 1`] = ` .c0 { color: #0969da; diff --git a/src/SubNav/SubNav.tsx b/src/SubNav/SubNav.tsx index 7995e40d47b..d5a1b6cf2ab 100644 --- a/src/SubNav/SubNav.tsx +++ b/src/SubNav/SubNav.tsx @@ -63,7 +63,6 @@ type StyledSubNavLinkProps = { } & SxProp const SubNavLink = styled.a.attrs(props => ({ - activeClassName: typeof props.to === 'string' ? 'selected' : undefined, className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className), }))` padding-left: ${get('space.3')}; diff --git a/src/TabNav/TabNav.tsx b/src/TabNav/TabNav.tsx index e3d46809af4..afe764961a7 100644 --- a/src/TabNav/TabNav.tsx +++ b/src/TabNav/TabNav.tsx @@ -81,7 +81,6 @@ export type TabNavLinkProps = React.DetailedHTMLProps(props => ({ - activeClassName: typeof props.to === 'string' ? 'selected' : undefined, className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className), role: 'tab', 'aria-selected': !!props.selected, diff --git a/src/UnderlineNav/UnderlineNav.tsx b/src/UnderlineNav/UnderlineNav.tsx index efd5afacd22..7d06505711b 100644 --- a/src/UnderlineNav/UnderlineNav.tsx +++ b/src/UnderlineNav/UnderlineNav.tsx @@ -70,7 +70,6 @@ type StyledUnderlineNavLinkProps = { } & SxProp const UnderlineNavLink = styled.a.attrs(props => ({ - activeClassName: typeof props.to === 'string' ? 'selected' : undefined, className: classnames(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className), }))` padding: ${get('space.3')} ${get('space.2')}; diff --git a/src/__tests__/SubNavLink.test.tsx b/src/__tests__/SubNavLink.test.tsx index a7c535bb65c..68194d90b5d 100644 --- a/src/__tests__/SubNavLink.test.tsx +++ b/src/__tests__/SubNavLink.test.tsx @@ -22,9 +22,4 @@ describe('SubNav.Link', () => { it('respects the "selected" prop', () => { expect(render()).toMatchSnapshot() }) - - it('adds activeClassName={SELECTED_CLASS} when it gets a "to" prop', () => { - const Link = ({theme: _ignoredTheme, ...props}: Record) =>
- expect(render()).toMatchSnapshot() - }) }) diff --git a/src/__tests__/UnderlineNavLink.test.tsx b/src/__tests__/UnderlineNavLink.test.tsx index 402735743b3..2ffc99f3e37 100644 --- a/src/__tests__/UnderlineNavLink.test.tsx +++ b/src/__tests__/UnderlineNavLink.test.tsx @@ -22,9 +22,4 @@ describe('UnderlineNav.Link', () => { it('respects the "selected" prop', () => { expect(render()).toMatchSnapshot() }) - - it('adds activeClassName={SELECTED_CLASS} when it gets a "to" prop', () => { - const Link = ({theme: _ignoredTheme, ...props}: Record) =>
- expect(render()).toMatchSnapshot() - }) }) diff --git a/src/__tests__/__snapshots__/SubNavLink.test.tsx.snap b/src/__tests__/__snapshots__/SubNavLink.test.tsx.snap index 8e37ba389fc..f71727364e0 100644 --- a/src/__tests__/__snapshots__/SubNavLink.test.tsx.snap +++ b/src/__tests__/__snapshots__/SubNavLink.test.tsx.snap @@ -1,72 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SubNav.Link adds activeClassName={SELECTED_CLASS} when it gets a "to" prop 1`] = ` -.c0 { - padding-left: 16px; - padding-right: 16px; - font-weight: 500; - font-size: 14px; - line-height: 20px; - min-height: 34px; - color: #1F2328; - text-align: center; - -webkit-text-decoration: none; - text-decoration: none; - border-top: 1px solid #d0d7de; - border-bottom: 1px solid #d0d7de; - border-right: 1px solid #d0d7de; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c0:first-of-type { - border-top-left-radius: 6px; - border-bottom-left-radius: 6px; - border-left: 1px solid #d0d7de; -} - -.c0:last-of-type { - border-top-right-radius: 6px; - border-bottom-right-radius: 6px; -} - -.c0:hover, -.c0:focus { - -webkit-text-decoration: none; - text-decoration: none; - background-color: #f6f8fa; - -webkit-transition: background-color 0.2s ease; - transition: background-color 0.2s ease; -} - -.c0:hover .SubNav-octicon, -.c0:focus .SubNav-octicon { - color: #656d76; -} - -.c0.selected { - color: #ffffff; - background-color: #0969da; - border-color: #0969da; -} - -.c0.selected .SubNav-octicon { - color: #ffffff; -} - -
-`; - exports[`SubNav.Link renders consistently 1`] = ` .c0 { padding-left: 16px; diff --git a/src/__tests__/__snapshots__/UnderlineNavLink.test.tsx.snap b/src/__tests__/__snapshots__/UnderlineNavLink.test.tsx.snap index 728670dcac0..aaed08f5179 100644 --- a/src/__tests__/__snapshots__/UnderlineNavLink.test.tsx.snap +++ b/src/__tests__/__snapshots__/UnderlineNavLink.test.tsx.snap @@ -1,65 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`UnderlineNav.Link adds activeClassName={SELECTED_CLASS} when it gets a "to" prop 1`] = ` -.c0 { - padding: 16px 8px; - margin-right: 16px; - font-size: 14px; - line-height: 1.5; - color: #1F2328; - text-align: center; - border-bottom: 2px solid transparent; - -webkit-text-decoration: none; - text-decoration: none; -} - -.c0:hover, -.c0:focus { - color: #1F2328; - -webkit-text-decoration: none; - text-decoration: none; - border-bottom-color: rgba(175,184,193,0.2); - -webkit-transition: border-bottom-color 0.2s ease; - transition: border-bottom-color 0.2s ease; -} - -.c0:hover .PRC-UnderlineNav-octicon, -.c0:focus .PRC-UnderlineNav-octicon { - color: #656d76; -} - -.c0.PRC-selected { - color: #1F2328; - border-bottom-color: #fd8c73; -} - -.c0.PRC-selected .PRC-UnderlineNav-octicon { - color: #1F2328; -} - -.c0:focus:not(:disabled) { - box-shadow: none; - outline: 2px solid #0969da; - outline-offset: -8px; -} - -.c0:focus:not(:disabled):not(:focus-visible) { - outline: solid 1px transparent; -} - -.c0:focus-visible:not(:disabled) { - box-shadow: none; - outline: 2px solid #0969da; - outline-offset: -8px; -} - -
-`; - exports[`UnderlineNav.Link renders consistently 1`] = ` .c0 { padding: 16px 8px;