-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Pagination): add caption properties
- Loading branch information
Showing
15 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
packages/vkui/src/components/Pagination/Pagination.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
import * as React from 'react'; | ||
import { baselineComponent } from '../../testing/utils'; | ||
import { Pagination } from './Pagination'; | ||
|
||
describe('Pagination', () => { | ||
baselineComponent(Pagination); | ||
baselineComponent(Pagination, undefined, 'with only icon'); | ||
|
||
baselineComponent( | ||
(props) => <Pagination {...props} navigationButtonsStyle="caption" />, | ||
undefined, | ||
'with only caption', | ||
); | ||
|
||
baselineComponent( | ||
(props) => <Pagination {...props} navigationButtonsStyle="both" />, | ||
undefined, | ||
'with both', | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
.../vkui/src/components/Pagination/PaginationNavigationButton/PaginationNavigationButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as React from 'react'; | ||
import { Button } from '../../Button/Button'; | ||
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden'; | ||
|
||
export interface PaginationNavigationButtonProps { | ||
type: 'prev' | 'next'; | ||
style: 'icon' | 'caption' | 'both'; | ||
caption: React.ReactNode; | ||
Icon: React.ComponentType; | ||
a11yLabel: React.ReactNode; | ||
disabled?: boolean; | ||
onClick(): void; | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
export const PaginationNavigationButton = ({ | ||
type, | ||
style, | ||
caption: captionProp, | ||
Icon, | ||
a11yLabel, | ||
disabled, | ||
onClick, | ||
}: PaginationNavigationButtonProps) => { | ||
const icon: React.ReactElement | null = | ||
style !== 'caption' ? ( | ||
<> | ||
<VisuallyHidden>{a11yLabel}</VisuallyHidden> | ||
<Icon /> | ||
</> | ||
) : null; | ||
const caption: React.ReactElement | null = | ||
style === 'caption' ? ( | ||
<> | ||
<VisuallyHidden>{a11yLabel}</VisuallyHidden> | ||
<span aria-hidden="true">{captionProp}</span> | ||
</> | ||
) : style !== 'icon' ? ( | ||
<span aria-hidden="true">{captionProp}</span> | ||
) : null; | ||
|
||
return ( | ||
<Button | ||
size="l" | ||
before={type === 'prev' ? icon : null} | ||
after={type === 'next' ? icon : null} | ||
appearance={style === 'caption' ? 'neutral' : 'accent'} | ||
mode="tertiary" | ||
disabled={disabled} | ||
onClick={onClick} | ||
> | ||
{caption} | ||
</Button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ents/Pagination/__image_snapshots__/pagination-android-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nts/Pagination/__image_snapshots__/pagination-android-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...components/Pagination/__image_snapshots__/pagination-ios-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...omponents/Pagination/__image_snapshots__/pagination-ios-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...onents/Pagination/__image_snapshots__/pagination-vkcom-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nents/Pagination/__image_snapshots__/pagination-vkcom-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ponents/Pagination/__image_snapshots__/pagination-vkcom-firefox-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...onents/Pagination/__image_snapshots__/pagination-vkcom-firefox-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...mponents/Pagination/__image_snapshots__/pagination-vkcom-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ponents/Pagination/__image_snapshots__/pagination-vkcom-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.