playbook_ui 11.15.0 → 11.16.0.pre.alpha.pagination.rails1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cffd8ae39a8b80f013b9bc0fca179e7cdd94be62b1bfcba8a786984fbe6bb15a
4
- data.tar.gz: 320820bff742b9b95b6d0867f81782eb6d20edee840ca1e65bd9ecc9fc96d805
3
+ metadata.gz: d1c2dd6e15de3851fa13af4d58c06b78448261e4dc2a973718ae53f518324638
4
+ data.tar.gz: 896cb320d58e4be679254fafdda40d7269f53161bcb1b417c6c5e2c725173de4
5
5
  SHA512:
6
- metadata.gz: 612b82bdc76521177c494de8203d6a64147a8dc2e6863ad0f28edef9eece3c410236ffa234220ed8c1d0ad69c5b857b8023fa2bf6d0680fec24054f8acd4bbde
7
- data.tar.gz: 24e96215afa640ea123786fb2a3656a91e5bff64e3a49b17598034230949be6b1e6671270cb1dee78edaf3563dee09dd09d5f1a7f6f5c9e1b7ba0c80173f5472
6
+ metadata.gz: 25c4283002f9b516e41e3f4a66e13fa1ddc71935c245001141357df87637500d5d9e87361bc35ccf6feee206ad0d8982701ea1d80390d5a937502657a8bc12d4
7
+ data.tar.gz: a87f20dc862b0f749fd3950a950596e97c8712a4ec130bf2856d3bd6f854fa41fcc3d3cedae27d043e3771d3d5c29a1b07f096831cac746f7d86ef1e220deadc
@@ -103,3 +103,5 @@
103
103
  @import './utilities/line_height';
104
104
  @import './utilities/display';
105
105
  @import './utilities/flexbox';
106
+
107
+ @import 'pb_pagination/pagination';
@@ -104,3 +104,4 @@ kits:
104
104
  - title_detail
105
105
  - user_badge
106
106
  - walkthrough
107
+ - pagination
@@ -53,9 +53,9 @@ export { default as LabelPill } from './pb_label_pill/_label_pill'
53
53
  export { default as LabelValue } from './pb_label_value/_label_value'
54
54
  export { default as Layout } from './pb_layout/_layout'
55
55
  export { default as Legend } from './pb_legend/_legend'
56
+ export { default as Lightbox } from './pb_lightbox/_lightbox'
56
57
  export { default as LineGraph } from './pb_line_graph/_line_graph'
57
58
  export { default as List } from './pb_list/_list'
58
- export { default as Lightbox } from './pb_lightbox/_lightbox'
59
59
  export { default as ListItem } from './pb_list/_list_item'
60
60
  export { default as LoadingInline } from './pb_loading_inline/_loading_inline'
61
61
  export { default as Message } from './pb_message/_message'
@@ -64,6 +64,7 @@ export { default as MultipleUsersStacked } from './pb_multiple_users_stacked/_mu
64
64
  export { default as Nav } from './pb_nav/_nav'
65
65
  export { default as NavItem } from './pb_nav/_item'
66
66
  export { default as OnlineStatus } from './pb_online_status/_online_status'
67
+ export { default as Pagination} from './pb_pagination/_pagination'
67
68
  export { default as Passphrase } from './pb_passphrase/_passphrase'
68
69
  export { default as PbReactPopover } from './pb_popover/_popover'
69
70
  export { default as Person } from './pb_person/_person'
@@ -0,0 +1,68 @@
1
+ @import "tokens/colors";
2
+ @import "tokens/typography";
3
+ @import "tokens/border_radius";
4
+ @import "tokens/shadows";
5
+
6
+ .pb_pagination {
7
+ display: inline-block;
8
+ border-radius: $border_rad_light;
9
+ border: 1px solid $border_light;
10
+ background-color: $white;
11
+ padding: 3px 0px 3.6px 0px;
12
+ li {
13
+ display: inline;
14
+ > a, li > span {
15
+ padding: 7px 13px;
16
+ text-decoration: none;
17
+ margin-left: -1px;
18
+ border: 0 !important;
19
+ }}
20
+ li:first-child > a, li:first-child > span {
21
+ padding: 7px 13px;
22
+ margin-left: .5px;
23
+ border-right: 1px solid $border_light !important;
24
+ z-index: 2;
25
+ }
26
+ li:last-child > a, li:last-child > span {
27
+ padding: 7px 13px;
28
+ margin-right: .5px;
29
+ border-left: 1px solid $border_light !important;
30
+ z-index: 2;
31
+ }
32
+ a {
33
+ color: $text_lt_default !important;
34
+ font-size: $text_small;
35
+ font-weight: $regular;
36
+ border: none;
37
+
38
+ &:hover {
39
+ background-color: $active_light;
40
+ color: $primary !important;
41
+ border-radius: $border_rad_light;
42
+ }
43
+
44
+ &:focus {
45
+ outline: 1px solid $primary !important;
46
+ border-radius: $border_rad_light;
47
+ outline-offset: -1px;
48
+ }
49
+ }
50
+ .active > span {
51
+ background-color: $primary !important;
52
+ border-radius: $border_rad_light;
53
+ color: #fff;
54
+ padding: 7px 10px;
55
+ border: 0 !important;
56
+ text-decoration: none;
57
+ font-weight: $bold;
58
+ font-size: $text_small;
59
+
60
+ &:hover {
61
+ box-shadow: $shadow_deeper;
62
+ }
63
+ }
64
+ .disabled > span {
65
+ padding: 7px 10px;
66
+ font-size: $text_small;
67
+ }
68
+ }
@@ -0,0 +1,41 @@
1
+
2
+
3
+ /* @flow */
4
+
5
+ import React from 'react'
6
+ import classnames from 'classnames'
7
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
+ import { globalProps } from '../utilities/globalProps'
9
+
10
+ type PaginationProps = {
11
+ aria?: { [key: string]: string },
12
+ className?: string,
13
+ data?: { [key: string]: string },
14
+ id?: string,
15
+ }
16
+
17
+ const Pagination = (props: PaginationProps) => {
18
+ const {
19
+ aria = {},
20
+ className,
21
+ data = {},
22
+ id,
23
+ } = props
24
+
25
+ const ariaProps = buildAriaProps(aria)
26
+ const dataProps = buildDataProps(data)
27
+ const classes = classnames(buildCss('pb_pagination'), globalProps(props), className)
28
+
29
+ return (
30
+ <div
31
+ {...ariaProps}
32
+ {...dataProps}
33
+ className={classes}
34
+ id={id}
35
+ >
36
+ {className}
37
+ </div>
38
+ )
39
+ }
40
+
41
+ export default Pagination
@@ -0,0 +1,28 @@
1
+ <% @data = [{
2
+ first_name: 'Jon',
3
+ last_name: 'Ron',
4
+ email: "jon@mail.com",
5
+ id: 1,
6
+ }, {
7
+ first_name: 'Sam',
8
+ last_name: 'Bob',
9
+ email: "sam@mail.com",
10
+ id: 2,
11
+ }, {
12
+ first_name: 'Nick',
13
+ last_name: 'Jack',
14
+ email: "nick@mail.com",
15
+ id: 3,
16
+ }, {
17
+ first_name: 'Jake',
18
+ last_name: 'Wade',
19
+ email: "jon@mail.com",
20
+ id: 4,
21
+ }, {
22
+ first_name: 'Blake',
23
+ last_name: 'Chad',
24
+ email: "jon@mail.com",
25
+ id: 5,
26
+ }] %>
27
+
28
+ <%= pb_rails("pagination", props: { data: @data}) %>
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import Pagination from '../_pagination'
3
+
4
+ const PaginationDefault = (props) => (
5
+ <div>
6
+ <Pagination
7
+ {...props}
8
+ />
9
+ </div>
10
+ )
11
+
12
+ export default PaginationDefault
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - pagination_default: Default
5
+
6
+
7
+ # react:
8
+ # - pagination_default: Default
9
+
@@ -0,0 +1 @@
1
+ export { default as PaginationDefault } from './_pagination_default.jsx'
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id) do %>
6
+ <%= will_paginate object.page_data, renderer: Playbook::Pagination::Rails %>
7
+ <% end %>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "will_paginate/array"
4
+ module Playbook
5
+ module PbPagination
6
+ class Pagination < ::Playbook::KitBase
7
+ prop :data, type: Playbook::Props::Array,
8
+ default: []
9
+ def page_data
10
+ data.paginate(page: params[:page], per_page: 1)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ import { renderKit } from '../utilities/test-utils'
2
+
3
+ import { Pagination } from '../'
4
+
5
+ /* See these resources for more testing info:
6
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
7
+ - https://jestjs.io/docs/en/using-matchers
8
+ */
9
+
10
+ test('generated scaffold test - update me', () => {
11
+ const props = {
12
+ data: { testid: 'default' }
13
+ }
14
+
15
+ const kit = renderKit(Pagination , props)
16
+ expect(kit).toBeInTheDocument()
17
+ })
@@ -60,6 +60,7 @@ import * as MultipleUsers from 'pb_multiple_users/docs'
60
60
  import * as MultipleUsersStacked from 'pb_multiple_users_stacked/docs'
61
61
  import * as Nav from 'pb_nav/docs'
62
62
  import * as OnlineStatus from 'pb_online_status/docs'
63
+ import * as Pagination from 'pb_pagination/docs'
63
64
  import * as Passphrase from 'pb_passphrase/docs'
64
65
  import * as PbReactPopover from 'pb_popover/docs'
65
66
  import * as Person from 'pb_person/docs'
@@ -157,6 +158,7 @@ WebpackerReact.setup({
157
158
  ...MultipleUsersStacked,
158
159
  ...Nav,
159
160
  ...OnlineStatus,
161
+ ...Pagination,
160
162
  ...Passphrase,
161
163
  ...PbReactPopover,
162
164
  ...Person,
@@ -19,6 +19,7 @@ require "playbook/flex"
19
19
  require "playbook/flex_grow"
20
20
  require "playbook/flex_shrink"
21
21
  require "playbook/order"
22
+ require "playbook/pagination_renderer"
22
23
 
23
24
  module Playbook
24
25
  class KitBase < ViewComponent::Base
@@ -43,6 +44,7 @@ module Playbook
43
44
  include Playbook::FlexGrow
44
45
  include Playbook::FlexShrink
45
46
  include Playbook::Order
47
+ include Playbook::Pagination
46
48
 
47
49
  prop :id
48
50
  prop :data, type: Playbook::Props::Hash, default: {}
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "will_paginate/view_helpers/action_view"
4
+
5
+ module Playbook
6
+ module Pagination
7
+ class Rails < WillPaginate::ActionView::LinkRenderer
8
+ def container_attributes
9
+ { class: "pb_pagination pagination" }
10
+ end
11
+
12
+ def page_number(page)
13
+ if page == current_page
14
+ tag("li", tag("span", page), class: "active")
15
+ else
16
+ tag("li", link(page, page, rel: rel_value(page)))
17
+ end
18
+ end
19
+
20
+ def previous_or_next_page(page, text, classname)
21
+ if page
22
+ tag("li", link(text, page), class: classname)
23
+ else
24
+ tag("li", tag("span", text), class: "%s disabled")
25
+ end
26
+ end
27
+
28
+ def gap
29
+ tag("li", tag("span", "&hellip;"), class: "disabled")
30
+ end
31
+
32
+ def previous_page
33
+ num = @collection.current_page > 1 && @collection.current_page - 1
34
+ previous_or_next_page(num, "<i class='far fa-chevron-left fa-xs'></i>", "prev")
35
+ end
36
+
37
+ def next_page
38
+ num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
39
+ previous_or_next_page(num, "<i class='far fa-chevron-right fa-xs'></i>", "next")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "11.14.0"
5
- VERSION = "11.15.0"
4
+ PREVIOUS_VERSION = "11.15.0"
5
+ VERSION = "11.16.0.pre.alpha.pagination.rails1"
6
6
  end
data/lib/playbook.rb CHANGED
@@ -12,6 +12,7 @@ require "playbook/pb_doc_helper"
12
12
  require "playbook/kit_base"
13
13
  require "playbook/kit_resolver"
14
14
  require "playbook/markdown"
15
+ require "playbook/pagination_renderer"
15
16
 
16
17
  module Playbook
17
18
  ROOT_PATH = Pathname.new(File.join(__dir__, ".."))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.15.0
4
+ version: 11.16.0.pre.alpha.pagination.rails1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -269,6 +269,20 @@ dependencies:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
271
  version: 1.2018.9
272
+ - !ruby/object:Gem::Dependency
273
+ name: will_paginate
274
+ requirement: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '3.3'
279
+ type: :development
280
+ prerelease: false
281
+ version_requirements: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '3.3'
272
286
  description: Playbook Design System. Built for Nitro, but powering all.
273
287
  email:
274
288
  - nitroux@powerhrg.com
@@ -1460,6 +1474,15 @@ files:
1460
1474
  - app/pb_kits/playbook/pb_online_status/docs/index.js
1461
1475
  - app/pb_kits/playbook/pb_online_status/online_status.html.erb
1462
1476
  - app/pb_kits/playbook/pb_online_status/online_status.rb
1477
+ - app/pb_kits/playbook/pb_pagination/_pagination.scss
1478
+ - app/pb_kits/playbook/pb_pagination/_pagination.tsx
1479
+ - app/pb_kits/playbook/pb_pagination/docs/_pagination_default.html.erb
1480
+ - app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx
1481
+ - app/pb_kits/playbook/pb_pagination/docs/example.yml
1482
+ - app/pb_kits/playbook/pb_pagination/docs/index.js
1483
+ - app/pb_kits/playbook/pb_pagination/pagination.html.erb
1484
+ - app/pb_kits/playbook/pb_pagination/pagination.rb
1485
+ - app/pb_kits/playbook/pb_pagination/pagination.test.jsx
1463
1486
  - app/pb_kits/playbook/pb_passphrase/_passphrase.jsx
1464
1487
  - app/pb_kits/playbook/pb_passphrase/_passphrase.scss
1465
1488
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb
@@ -2321,6 +2344,7 @@ files:
2321
2344
  - lib/playbook/markdown/template_handler.rb
2322
2345
  - lib/playbook/number_spacing.rb
2323
2346
  - lib/playbook/order.rb
2347
+ - lib/playbook/pagination_renderer.rb
2324
2348
  - lib/playbook/pb_doc_helper.rb
2325
2349
  - lib/playbook/pb_forms_helper.rb
2326
2350
  - lib/playbook/pb_kit_helper.rb
@@ -2359,9 +2383,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
2359
2383
  version: '0'
2360
2384
  required_rubygems_version: !ruby/object:Gem::Requirement
2361
2385
  requirements:
2362
- - - ">="
2386
+ - - ">"
2363
2387
  - !ruby/object:Gem::Version
2364
- version: '0'
2388
+ version: 1.3.1
2365
2389
  requirements: []
2366
2390
  rubygems_version: 3.3.7
2367
2391
  signing_key: