File tree Expand file tree Collapse file tree 5 files changed +68
-49
lines changed
tests/integration/components Expand file tree Collapse file tree 5 files changed +68
-49
lines changed Original file line number Diff line number Diff line change 1
1
<div class =" pagination-wrapper" >
2
- {{ #if (has-block " previous" )}}
2
+ {{ #if (and ( has-block " previous" ) @ showPrevious )}}
3
3
<div class =" previous-wrapper" >
4
- {{ yield to =' previous' }}
4
+ <img alt =" left arrow" src =" /images/icons/arrow-icon.svg" />
5
+ <div >{{ yield to =' previous' }} </div >
5
6
</div >
6
7
{{ /if }}
7
8
8
- {{ #if (has-block " next" )}}
9
+ {{ #if (and ( has-block " next" ) @ showNext )}}
9
10
<div class =" next-wrapper" >
10
- {{ yield to =' next' }}
11
+ <div >{{ yield to =' next' }} </div >
12
+ <img alt =" right arrow" src =" /images/icons/arrow-icon.svg" />
11
13
</div >
12
14
{{ /if }}
13
15
</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
+ margin : var (--spacing-1 ) 0 ;
9
10
& > .previous-wrapper {
10
11
grid-area : previous;
11
- & :: before {
12
- content : "\2039" ;
12
+ & > img {
13
+ transform : rotate ( 90 deg ) ;
13
14
}
14
-
15
- & : hover ::before {
16
- transform : translateX (-0.5em );
17
- color : var (--color-link-hover );
15
+ & : hover > img {
16
+ transform : rotate (90deg ) translateY (0.5em );
18
17
}
19
18
}
20
19
21
20
& > .next-wrapper {
22
21
grid-area : next;
22
+ justify-content : end;
23
23
text-align : right;
24
- & :: after {
25
- content : "\203A" ;
24
+ & > img {
25
+ transform : rotate ( 270 deg ) ;
26
26
}
27
27
28
- & : hover ::after {
29
- transform : translateX (0.5em );
30
- color : var (--color-link-hover );
28
+ & : hover > img {
29
+ transform : rotate (270deg ) translateY (0.5em );
31
30
}
32
31
}
33
32
34
33
& > .previous-wrapper , & > .next-wrapper {
35
- & ::before ,
36
- & ::after {
37
- color : var (--color-link );
38
- display : inline-block;
39
- font-weight : 700 ;
34
+ display : flex;
35
+ align-items : center;
36
+ & > img {
40
37
margin : 0 0.5em ;
41
38
transition : transform 0.3s ;
42
39
}
43
40
}
44
41
}
45
-
46
-
47
-
48
- .previous {
49
- & ::before {
50
- content : "\2039" ;
51
- }
52
-
53
- & : hover ::before {
54
- transform : translateX (-0.5em );
55
- }
56
- }
57
-
58
- .next {
59
- & ::after {
60
- content : "\203A" ;
61
- }
62
-
63
- & : hover ::after {
64
- transform : translateX (0.5em );
65
- }
66
- }
Original file line number Diff line number Diff line change 1
1
# Pagination
2
2
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.
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. You will use the ` showPrevious ` and ` showNext ` prop to make sure the correct links are visible.
4
4
5
5
## Usage
6
6
7
7
Add the following code to the template
8
8
9
9
``` handlebars
10
- <EsPagination>
10
+ <EsPagination @showPrevious={{true}} @showNext={{true}} >
11
11
<:previous>
12
12
<LinkTo @route="page" @model={{this.previousId}}>
13
13
Newer articles
@@ -21,21 +21,32 @@ Add the following code to the template
21
21
</EsPagination>
22
22
```
23
23
24
- The example below show what happens if you only provide the ` previous ` block when it's the last page you are on .
24
+ To only show the previous you've to pass ` false ` to the ` showNext ` prop .
25
25
26
26
``` handlebars
27
- <EsPagination>
27
+ <EsPagination @showPrevious={{true}} @showNext={{false}} >
28
28
<:previous>
29
29
<LinkTo @route="page" @model={{this.previousId}}>
30
30
Newer articles
31
31
</LinkTo>
32
32
</:previous>
33
+ <:next>
34
+ <LinkTo @route="page" @model={{this.nextId}}>
35
+ Older articles
36
+ </LinkTo>
37
+ </:next>
33
38
</EsPagination>
34
39
```
35
- The example below show what happens if you only provide the ` next ` block when it's the first page you are on.
40
+
41
+ To only show the previous you've to pass ` false ` to the ` showPrevious ` prop.
36
42
37
43
``` handlebars
38
- <EsPagination>
44
+ <EsPagination @showPrevious={{false}} @showNext={{true}}>
45
+ <:previous>
46
+ <LinkTo @route="page" @model={{this.previousId}}>
47
+ Newer articles
48
+ </LinkTo>
49
+ </:previous>
39
50
<:next>
40
51
<LinkTo @route="page" @model={{this.nextId}}>
41
52
Older articles
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module('Integration | Component | es-pagination', function (hooks) {
8
8
9
9
test ( 'it renders' , async function ( assert ) {
10
10
await render ( hbs `
11
- <EsPagination>
11
+ <EsPagination @showPrevious={{true}} @showNext={{true}} >
12
12
<:previous>
13
13
Newer articles
14
14
</:previous>
@@ -20,4 +20,34 @@ module('Integration | Component | es-pagination', function (hooks) {
20
20
21
21
assert . dom ( this . element ) . hasText ( 'Newer articles Older articles' ) ;
22
22
} ) ;
23
+ test ( 'it renders only previous' , async function ( assert ) {
24
+ await render ( hbs `
25
+ <EsPagination @showPrevious={{true}} @showNext={{false}}>
26
+ <:previous>
27
+ Newer articles
28
+ </:previous>
29
+ <:next>
30
+ Older articles
31
+ </:next>
32
+ </EsPagination>
33
+ ` ) ;
34
+
35
+ assert . dom ( this . element ) . hasText ( 'Newer articles' ) ;
36
+ assert . dom ( this . element ) . doesNotIncludeText ( 'Older articles' ) ;
37
+ } ) ;
38
+ test ( 'it renders only next' , async function ( assert ) {
39
+ await render ( hbs `
40
+ <EsPagination @showPrevious={{false}} @showNext={{true}}>
41
+ <:previous>
42
+ Newer articles
43
+ </:previous>
44
+ <:next>
45
+ Older articles
46
+ </:next>
47
+ </EsPagination>
48
+ ` ) ;
49
+
50
+ assert . dom ( this . element ) . hasText ( 'Older articles' ) ;
51
+ assert . dom ( this . element ) . doesNotIncludeText ( 'Newer articles' ) ;
52
+ } ) ;
23
53
} ) ;
You can’t perform that action at this time.
0 commit comments