Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add focus styles to Pagination component #5082

Merged
merged 3 commits into from
Oct 8, 2024
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
5 changes: 5 additions & 0 deletions .changeset/large-glasses-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Add focus styles to Pagination component
14 changes: 11 additions & 3 deletions packages/react/src/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Box from '../Box'
import {get} from '../constants'
import type {SxProp} from '../sx'
import sx from '../sx'
import getGlobalFocusStyles from '../internal/utils/getGlobalFocusStyles'
import {buildComponentData, buildPaginationModel} from './model'
import type {ResponsiveValue} from '../hooks/useResponsiveValue'
import {viewportRanges} from '../hooks/useResponsiveValue'
Expand Down Expand Up @@ -56,7 +55,10 @@ const Page = styled.a`
transition-duration: 0.1s;
}

${getGlobalFocusStyles(0)};
&:focus-visible {
outline: 2px solid ${get('colors.accent.emphasis')};
outline-offset: -2px;
}

&:active {
border-color: ${get('colors.border.muted')};
Expand All @@ -74,6 +76,12 @@ const Page = styled.a`
border-color: transparent;
}

&[aria-current]:focus-visible {
outline: 2px solid ${get('colors.accent.emphasis')};
outline-offset: -2px;
box-shadow: inset 0 0 0 3px ${get('colors.fg.onEmphasis')};
}

&[aria-disabled],
&[aria-disabled]:hover {
margin: 0 2px;
Expand Down Expand Up @@ -196,7 +204,7 @@ const PaginationContainer = styled.nav<SxProp>`
.TablePaginationSteps[data-hidden-viewport-ranges*='${viewportRangeKey}'] > *:first-child {
margin-inline-end: 0;
}

.TablePaginationSteps[data-hidden-viewport-ranges*='${viewportRangeKey}'] > *:last-child {
margin-inline-start: 0;
}
Expand Down
Loading