Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .jest-results.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion components/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
],
"dependencies": {
"@hods/sass-base": "workspace:^0.1.13",
"@not-govuk/component-helpers": "^0.2.15"
"@not-govuk/component-helpers": "^0.2.15",
"@not-govuk/link": "^0.2.15"
},
"peerDependencies": {
"@not-govuk/docs-components": "^0.2.0",
Expand Down
10 changes: 5 additions & 5 deletions components/pagination/spec/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe('Pagination', () => {

let current;
beforeAll(() => {
expect(current = pagination.find('.hods-pagination__link--current')).toHaveLength(1);
expect(current = pagination.find('a.hods-pagination__link--current')).toHaveLength(1);
});

it('is on the correct page', () => {
expect(current.text()).toEqual('3');
});

it('should not have a link', () => {
expect(current.html()).toContain('href=""');
expect(current.html()).not.toContain('href=');
});

const summary = pagination.find('.hods-pagination__summary').text();
Expand Down Expand Up @@ -59,15 +59,15 @@ describe('Pagination', () => {

let current;
beforeAll(() => {
expect(current = pagination.find('.hods-pagination__link--current')).toHaveLength(1);
expect(current = pagination.find('a.hods-pagination__link--current')).toHaveLength(1);
});

it('is on the correct page', () => {
expect(current.text()).toEqual('1');
});

it('should not have a link', () => {
expect(current.html()).toContain('href=""');
expect(current.html()).not.toContain('href=');
});

const summary = pagination.find('.hods-pagination__summary').text();
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('Pagination', () => {

let current;
beforeAll(() => {
expect(current = pagination.find('.hods-pagination__link--current')).toHaveLength(0);
expect(current = pagination.find('a.hods-pagination__link--current')).toHaveLength(0);
});
});
});
60 changes: 55 additions & 5 deletions components/pagination/src/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC, createElement as h } from 'react';
import { StandardProps, classBuilder } from '@not-govuk/component-helpers';
import { A } from '@not-govuk/link';

import '../assets/Pagination.scss';

Expand Down Expand Up @@ -53,21 +54,26 @@ export const Pagination: FC<PaginationProps> = ({
<ul className={ classes('list-items') }>
{ page > 1 ?
<li className={ classes('item') } id="prevButton" key="prev">
<a className={ classes('link') } href={ page > 1 ? hl[1] : "" }>
<A className={ classes('link') } href={hl[1]}>
<span aria-hidden="true" role="presentation">&laquo;</span> Previous
</a>
</A>
</li>
: null }
{ it.map( i => (
<li className={ classes('item') } key={i}>
{ pages[i] < 1 || pages[i] > maxPages ? null : <a className={classes('link', pages[i] === page ? 'current' : undefined)} href={hl[i]}>{pages[i]}</a>}
{ pages[i] < 1 || pages[i] > maxPages
? null
: pages[i]!==page
? <A className={ classes('link') } href={ hl[i] }>{ pages[i] }</A>
: <a className={ classes('link', 'current') }>{ pages[i] }</a>
}
</li>
))}
{ resultsTo == results ? null :
<li className={ classes('item') } id="nextButton" key="next">
<a className={ classes('link') } href={ resultsTo == results ? "" : hl[3] }>
<A className={ classes('link') } href={hl[3]}>
Next <span aria-hidden="true" role="presentation">&raquo;</span>
</a>
</A>
</li>
}
</ul>
Expand All @@ -76,3 +82,47 @@ export const Pagination: FC<PaginationProps> = ({
};

export default Pagination;

// hods-pagination__link

/*


Expected substring: "href=\"\""
Received string: "href=\"/\""




{ it.map( i => (
<li className={ classes('item') } key={i}>
{ pages[i] < 1 || pages[i] > maxPages ? null : <a className={classes('link', pages[i] === page ? 'current' : undefined)} href={hl[i]}>{pages[i]}</a>}
</li>
))}


return (
<div className={ classes() }>
<div className={ classes('summary') }>Showing { resultsFrom } - { resultsTo } of { results } results</div>
<ul className={ classes('list-items') }>
{ page > 1 ?
<li className={ classes('item') } id="prevButton" key="prev">
<A href="#">Previous</A>
</li>
: null }
<li className={ classes('item') }>
<A href="#" classBlock="hods-pagination__link">1</A>
<A href="#" classBlock="hods-pagination__link">2</A>
<A href="#" classBlock="hods-pagination__link hods-pagination__link--current">3</A>
<A href="#" classBlock="hods-pagination__link">4</A>
<A href="#" classBlock="hods-pagination__link">5</A>
</li>
{ resultsTo == results ? null :
<li className={ classes('item') } id="nextButton" key="next">
<A href="#">Next</A>
</li>
}
</ul>
</div>
);
*/
Comment thread
daniel-ac-martin marked this conversation as resolved.
Outdated
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.