File tree Expand file tree Collapse file tree 3 files changed +65
-47
lines changed Expand file tree Collapse file tree 3 files changed +65
-47
lines changed Original file line number Diff line number Diff line change 1
1
<div class =" pagination-wrapper" >
2
- {{ #if @previous }}
3
- <div class =" previous-wrapper bg-none" >
4
- <LinkTo class =" pagination-link previous" @route ={{ @previous.route }} @model ={{ @previous.model }} >
5
- <span class =" pagination-text" >{{ @previous.text }} </span >
6
- </LinkTo >
2
+ {{ #if (has-block " previous" )}}
3
+ <div class =" previous-wrapper" >
4
+ {{ yield to =' previous' }}
7
5
</div >
8
6
{{ /if }}
9
7
10
- {{ #if @next }}
11
- <div class =" next-wrapper bg-none" >
12
- <LinkTo class =" pagination-link next" @route ={{ @next.route }} @model ={{ @next.model }} >
13
- <span class =" pagination-text" >{{ @next.text }} </span >
14
- </LinkTo >
8
+ {{ #if (has-block " next" )}}
9
+ <div class =" next-wrapper" >
10
+ {{ yield to =' next' }}
15
11
</div >
16
12
{{ /if }}
17
13
</div >
Original file line number Diff line number Diff line change 6
6
gap : 0px 40px ;
7
7
grid-template-areas :
8
8
"previous next" ;
9
- }
9
+ & > .previous-wrapper {
10
+ grid-area : previous;
11
+ & ::before {
12
+ content : "\2039" ;
13
+ }
10
14
11
- .previous-wrapper {
12
- grid-area : previous;
13
- }
15
+ & : hover ::before {
16
+ transform : translateX (-0.5em );
17
+ color : var (--color-link-hover );
18
+ }
19
+ }
14
20
15
- .next-wrapper {
16
- grid-area : next;
17
- text-align : right;
18
- }
21
+ & > .next-wrapper {
22
+ grid-area : next;
23
+ text-align : right;
24
+ & ::after {
25
+ content : "\203A" ;
26
+ }
19
27
20
- .pagination-link {
21
- & ::before ,
22
- & ::after {
23
- display : inline-block;
24
- font-weight : 700 ;
25
- margin : 0 0.5em ;
26
- transition : transform 0.3s ;
27
- }
28
- & : hover , & : focus , & : active {
29
- .pagination-text {
28
+ & : hover ::after {
29
+ transform : translateX (0.5em );
30
30
color : var (--color-link-hover );
31
31
}
32
32
}
33
- }
34
33
35
- .pagination-text {
36
- color : var (--color-link );
37
- background : no-repeat left bottom
38
- linear-gradient (var (--color-brand-40 ), var (--color-brand-40 ));
39
- background-size : 100% 0.1875rem ;
34
+ & > .previous-wrapper , & > .next-wrapper {
35
+ & ::before ,
36
+ & ::after {
37
+ color : var (--color-link );
38
+ display : inline-block;
39
+ font-weight : 700 ;
40
+ margin : 0 0.5em ;
41
+ transition : transform 0.3s ;
42
+ }
43
+ }
40
44
}
41
45
46
+
47
+
42
48
.previous {
43
49
& ::before {
44
50
content : "\2039" ;
Original file line number Diff line number Diff line change 1
1
# Pagination
2
2
3
- Adds back and forth pagination, when provided with a ` previous ` object and a ` next ` object. These objects should look like this:
4
- ``` js
5
- const object = {
6
- route: " String" ,
7
- model: {},
8
- text: " The text that will show in the pagination"
9
- }
10
- ```
3
+ Adds back and forth pagination, using ` named blocks ` . You insert your previous link into a ` <:previous></:previous> ` block and the next link into a ` <:next></:next> ` block. This will add the underline styling to the link and an animated arrow to your link.
11
4
12
5
## Usage
13
6
14
7
Add the following code to the template
15
8
16
9
``` handlebars
17
- <EsPagination @previous={{hash text="Older articles" route="prev"}} @next={{hash text="Newer articles" route="next"}}/>
10
+ <EsPagination>
11
+ <:previous>
12
+ <LinkTo @route="page" @model={{this.previousId}}>
13
+ Newer articles
14
+ </LinkTo>
15
+ </:previous>
16
+ <:next>
17
+ <LinkTo @route="page" @model={{this.nextId}}>
18
+ Older articles
19
+ </LinkTo>
20
+ </:next>
21
+ </EsPagination>
18
22
```
19
23
20
- The example below show what happens if you only provide the ` previous ` object when it's the last page you are on.
24
+ The example below show what happens if you only provide the ` previous ` block when it's the last page you are on.
21
25
22
26
``` handlebars
23
- <EsPagination @previous={{hash text="One before last article" route="prev"}}/>
27
+ <EsPagination>
28
+ <:previous>
29
+ <LinkTo @route="page" @model={{this.previousId}}>
30
+ Newer articles
31
+ </LinkTo>
32
+ </:previous>
33
+ </EsPagination>
24
34
```
25
- The example below show what happens if you only provide the ` next ` object when it's the first page you are on.
35
+ The example below show what happens if you only provide the ` next ` block when it's the first page you are on.
26
36
27
37
``` handlebars
28
- <EsPagination @next={{hash text="Second article" route="next"}}/>
38
+ <EsPagination>
39
+ <:next>
40
+ <LinkTo @route="page" @model={{this.nextId}}>
41
+ Older articles
42
+ </LinkTo>
43
+ </:next>
44
+ </EsPagination>
29
45
```
You can’t perform that action at this time.
0 commit comments