-
Notifications
You must be signed in to change notification settings - Fork 12
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
Task #227 - Pagination component #831
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f679756
pagination component
DjidjaleskaSandra b405fdc
custom query args
DjidjaleskaSandra 3b2695f
missing schema added
DjidjaleskaSandra a91ce68
simple pagination
DjidjaleskaSandra e6ef721
style
DjidjaleskaSandra 0434d5f
style
DjidjaleskaSandra c01bb50
add correct namespace
DjidjaleskaSandra c793023
optimize the code
DjidjaleskaSandra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/component.json", | ||
"componentName": "pagination", | ||
"title": "Pagination", | ||
"componentClass": "pagination", | ||
"components": { | ||
"icon": "icon" | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
blocks/init/src/Blocks/components/pagination/pagination-style.scss
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,54 @@ | ||
.pagination { | ||
--pagination-scoped-radius-size: calc(var(--base-font-size) * 2.7rem); | ||
--pagination-scoped-color: var(--global-colors-black); | ||
--pagination-scoped-background-color: transparent; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
@include media(tablet up) { | ||
justify-content: center; | ||
} | ||
|
||
> * { | ||
margin: 0 calc(var(--base-font-size) * 0.5rem); | ||
font-size: calc(var(--base-font-size) * 1.7rem); | ||
line-height: 1.5; | ||
color: var(--pagination-scoped-color); | ||
transition: color 0.3s ease-out; | ||
|
||
span { | ||
width: var(--pagination-scoped-radius-size); | ||
height: var(--pagination-scoped-radius-size); | ||
border-radius: calc(var(--base-font-size) * 0.4rem); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: var(--pagination-scoped-background-color); | ||
} | ||
} | ||
|
||
&__prev { | ||
.icon{ | ||
transform: rotate(180deg); | ||
} | ||
} | ||
|
||
&__link{ | ||
text-decoration: none; | ||
|
||
&:hover { | ||
color: var(--global-colors-primary700); | ||
} | ||
} | ||
|
||
.current { | ||
color: var(--global-colors-white); | ||
|
||
span { | ||
--pagination-scoped-background-color: var(--global-colors-primary500); | ||
--pagination-scoped-color: var(--global-colors-white); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
blocks/init/src/Blocks/components/pagination/pagination.php
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,53 @@ | ||
<?php | ||
|
||
/** | ||
* Template for the Pagination Component. | ||
* | ||
* @package %g_namespace% | ||
*/ | ||
|
||
use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers; | ||
|
||
$manifest = Helpers::getManifestByDir(__DIR__); | ||
|
||
$componentClass = $manifest['componentClass'] ?? ''; | ||
$additionalClass = $attributes['additionalClass'] ?? ''; | ||
$blockClass = $attributes['blockClass'] ?? ''; | ||
$selectorClass = $attributes['selectorClass'] ?? $componentClass; | ||
|
||
$paginationClass = Helpers::classnames([ | ||
$componentClass, | ||
Helpers::selector($blockClass, $blockClass, $selectorClass), | ||
$additionalClass | ||
]); | ||
|
||
$paginationPrevClass = Helpers::selector($componentClass, $componentClass, 'prev'); | ||
$paginationNextClass = Helpers::selector($componentClass, $componentClass, 'next'); | ||
$paginationLinkClass = Helpers::selector($componentClass, $componentClass, 'link'); | ||
|
||
$icon = Helpers::render( | ||
'icon', | ||
Helpers::props('icon', $attributes, [ | ||
'blockClass' => $componentClass, | ||
'selectorClass' => 'icon', | ||
]) | ||
); | ||
?> | ||
|
||
<div class="<?php echo esc_attr($paginationClass); ?>"> | ||
<?php | ||
$pagination_links = paginate_links( | ||
[ | ||
'before_page_number' => '<span>', | ||
'after_page_number' => '</span>', | ||
'prev_text' => '<span class="' . $paginationPrevClass . '" aria-label = ' . __('Previous', '%g_textdomain%') . '>' . $icon . '</span>', | ||
'next_text' => '<span class="' . $paginationNextClass . '"aria-label = ' . __('Next', '%g_textdomain%') . '>' . $icon . '</span>', | ||
] | ||
); | ||
|
||
// Add custom css classes. | ||
$pagination_links = str_replace('<a', '<a class="' . $paginationLinkClass . '"', $pagination_links); | ||
|
||
echo $pagination_links; | ||
?> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a no no, as this could possibly break something. If you need to add custom selectors you can use
type='array'
and create your own layout but this is an overkill so adding a CSS selector toa
I fine in this applicationhttps://developer.wordpress.org/reference/functions/paginate_links/