diff --git a/app/components/pagination/numbered.njk b/app/components/pagination/numbered.njk new file mode 100644 index 000000000..3c8d82fb2 --- /dev/null +++ b/app/components/pagination/numbered.njk @@ -0,0 +1,395 @@ +{% set html_style = 'background-color: #f0f4f5;' %} +{% set title = 'Pagination' %} +{% from 'components/pagination/macro.njk' import pagination %} +{% extends 'layout.njk' %} + +{% block body %} + +
+
+ +
+
+ +

3 pages

+ + {{ pagination({ + nextUrl: "#", + items: [ + { + number: 1, + href: "#", + current: true + }, + { + number: 2, + href: "#" + }, + { + number: 3, + href: "#" + } + ] + }) }} + + {{ pagination({ + previousUrl: "#", + nextUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + number: 2, + current: true, + href: "#" + }, + { + number: 3, + href: "#" + } + ] + }) }} + + + {{ pagination({ + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + number: 2, + href: "#" + }, + { + number: 3, + href: "#", + current: true + } + ] + }) }} + +

10 pages

+ + {{ pagination({ + nextUrl: "#", + items: [ + { + number: 1, + href: "#", + current: true + }, + { + number: 2, + href: "#" + }, + { + number: 3, + href: "#" + }, + { + number: 4, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + number: 2, + href: "#", + current: true + }, + { + number: 3, + href: "#" + }, + { + number: 4, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + number: 2, + href: "#" + }, + { + number: 3, + href: "#", + current: true + }, + { + number: 4, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + number: 2, + href: "#" + }, + { + number: 3, + href: "#" + }, + { + number: 4, + href: "#", + current: true + }, + { + number: 5, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 4, + href: "#" + }, + { + number: 5, + href: "#", + current: true + }, + { + number: 6, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 5, + href: "#" + }, + { + number: 6, + href: "#", + current: true + }, + { + number: 7, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 6, + href: "#" + }, + { + number: 7, + href: "#", + current: true + }, + { + number: 8, + href: "#" + }, + { + ellipsis: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 7, + href: "#" + }, + { + number: 8, + href: "#", + current: true + }, + { + number: 9, + href: "#" + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + nextUrl: "#", + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 8, + href: "#" + }, + { + number: 9, + href: "#", + current: true + }, + { + number: 10, + href: "#" + } + ] + }) }} + + {{ pagination({ + previousUrl: "#", + items: [ + { + number: 1, + href: "#" + }, + { + ellipsis: true + }, + { + number: 8, + href: "#" + }, + { + number: 9, + href: "#" + }, + { + number: 10, + href: "#", + current: true + } + ] + }) }} +
+
+ +
+
+ +{% endblock %} diff --git a/app/components/pagination/index.njk b/app/components/pagination/previous-and-next.njk similarity index 100% rename from app/components/pagination/index.njk rename to app/components/pagination/previous-and-next.njk diff --git a/app/pages/examples.njk b/app/pages/examples.njk index 857e28214..88d984df5 100644 --- a/app/pages/examples.njk +++ b/app/pages/examples.njk @@ -104,7 +104,8 @@
  • Label
  • Label with bold text
  • Label as page heading
  • -
  • Pagination
  • +
  • Pagination: previous and next
  • +
  • Pagination: numbered pages
  • Radios
  • Radios inline
  • Radios disabled
  • @@ -131,7 +132,7 @@
  • Warning callout
  • Warning callout with custom heading
  • - + {% endblock %} {% block footer %} diff --git a/packages/components/pagination/_pagination.scss b/packages/components/pagination/_pagination.scss index cf7b139f0..5c1677e90 100644 --- a/packages/components/pagination/_pagination.scss +++ b/packages/components/pagination/_pagination.scss @@ -9,6 +9,7 @@ * to understand in print context. */ +// Previous and next pages variant .nhsuk-pagination { @include nhsuk-responsive-margin(7, "top"); @include nhsuk-responsive-margin(7, "bottom"); @@ -131,3 +132,109 @@ display: block; text-decoration: underline; } + +// Numbered pages variant +.nhsuk-pagination--numbered { + @include clearfix(); +} + +// In a numbered list, the previous link, numbered page links, +// and next link should all line up +.nhsuk-pagination--numbered__prev, +.nhsuk-pagination--numbered__next, +.nhsuk-pagination--numbered__item { + @include nhsuk-font(19); + box-sizing: border-box; + position: relative; + min-width: 45px; + min-height: 45px; + padding: nhsuk-spacing(2) nhsuk-spacing(2); + text-align: center; + margin: 0; + float: left; +} + +.nhsuk-pagination--numbered__link:visited:hover, +.nhsuk-pagination--numbered__item a:hover { + color: $nhsuk-link-hover-color; +} + +.nhsuk-pagination--numbered__prev:hover, +.nhsuk-pagination--numbered__next:hover, +.nhsuk-pagination--numbered__item:hover { + background-color: $color_nhsuk-grey-4; + color: $color_nhsuk-blue; +} + +// Container for the list of numbered items +.nhsuk-pagination__list--numbered { + margin: 0; + padding: 0; + list-style: none; +} + +// Current number +.nhsuk-pagination--numbered__item--current, +.nhsuk-pagination--numbered__item--current:hover { + background-color: $color_nhsuk-blue; + font-weight: $nhsuk-font-bold; + + .nhsuk-pagination--numbered__link { + color: $color_nhsuk-white; + } + + .nhsuk-pagination--numbered__link:focus { + color: $color_nhsuk-black; + } +} + +.nhsuk-pagination--numbered__item--ellipses { + font-weight: $nhsuk-font-bold; + color: $nhsuk-secondary-text-color; + + &:hover { + background-color: transparent; + } +} + +.nhsuk-pagination--numbered__link { + min-width: nhsuk-spacing(3); + vertical-align: middle; + color: $color_nhsuk-blue; + + // Increase the touch area for the link to the parent element. + @media screen { + &::after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + } + } +} + +.nhsuk-pagination--numbered .nhsuk-icon { + margin-top: 0; + margin-bottom: -12px; + fill: $color_nhsuk-blue; +} + +.nhsuk-pagination--numbered__link:visited .nhsuk-icon { + fill: $nhsuk-link-visited-color; +} + +.nhsuk-pagination--numbered__link:hover .nhsuk-icon { + fill: $nhsuk-link-hover-color; +} + +.nhsuk-pagination--numbered .nhsuk-icon__arrow-left { + margin-left: -13px; + margin-right: nhsuk-spacing(2); +} + +.nhsuk-pagination--numbered .nhsuk-icon__arrow-right { + margin-left: nhsuk-spacing(2); + margin-right: -13px; +} diff --git a/packages/components/pagination/template.njk b/packages/components/pagination/template.njk index 3712fe5ba..b68569915 100644 --- a/packages/components/pagination/template.njk +++ b/packages/components/pagination/template.njk @@ -1,32 +1,107 @@ {% from "../../macros/attributes.njk" import nhsukAttributes %} -