playbook_ui 7.3.0.pre.alpha8 → 7.3.0.pre.alpha9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -1
  3. data/app/pb_kits/playbook/data/menu.yml +1 -1
  4. data/app/pb_kits/playbook/index.js +1 -2
  5. data/app/pb_kits/playbook/pb_collapsible/_collapsible.html.erb +9 -0
  6. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +133 -0
  7. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +17 -0
  8. data/app/pb_kits/playbook/pb_collapsible/child_kits/_collapsible_content.html.erb +7 -0
  9. data/app/pb_kits/playbook/pb_collapsible/child_kits/_collapsible_main.html.erb +16 -0
  10. data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +15 -0
  11. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +21 -0
  12. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +24 -0
  13. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_dark.html.erb +10 -0
  14. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_dark.jsx +17 -0
  15. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.html.erb +10 -0
  16. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +17 -0
  17. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +9 -0
  18. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -0
  19. data/app/pb_kits/playbook/pb_collapsible/index.js +82 -0
  20. data/app/pb_kits/playbook/pb_collapsible/useToggler.js +10 -0
  21. data/app/pb_kits/playbook/pb_list/_list.jsx +2 -9
  22. data/app/pb_kits/playbook/vendor.js +3 -0
  23. data/lib/playbook/version.rb +1 -2
  24. metadata +19 -17
  25. data/app/pb_kits/playbook/pb_selectable_list/_item.jsx +0 -92
  26. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.html.erb +0 -11
  27. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.jsx +0 -47
  28. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +0 -17
  29. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list_item.html.erb +0 -18
  30. data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.html.erb +0 -13
  31. data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.jsx +0 -34
  32. data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.html.erb +0 -13
  33. data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.jsx +0 -38
  34. data/app/pb_kits/playbook/pb_selectable_list/docs/example.yml +0 -12
  35. data/app/pb_kits/playbook/pb_selectable_list/docs/index.js +0 -2
  36. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.rb +0 -24
  37. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e3e60d3152719e9078450a2e66bc9eedbf6e71db1a2cfe9abd998a865fdc448
4
- data.tar.gz: 5ef613bebcb8d926bd434614999601ef6c2b8c069aa8ecc790e4868792b2f9ad
3
+ metadata.gz: e18cba8566c2c3fe0b78079db8014edfd76e93b54c967e502658970aa557e6ff
4
+ data.tar.gz: 130729a0d901cecb68c59af7c4972962c3acea7892463a04c3c776510060d6e7
5
5
  SHA512:
6
- metadata.gz: 56ba60a4fe222051010e57a1df2c17c890dfc87cca02f82bb6b22d301c7d06bf78dde9ff58d0aa925f5ebcde9464af015a00941ba4b5a5d51335caa444f5bc0a
7
- data.tar.gz: 7bede8f9d4d12fd0c9c17e0c9874dd8485cbba9c5ff9a71ee4c29709928652e582f4a96d6c44f40fabc270db9da772a6557685b3b1da8e547b2090c5e497ce12
6
+ metadata.gz: 2144a7864670dee1d05de41453283ddb4feb2b130cf6140a7d0f4384dccd6eae245f602308279802c426b3194c917171ee1449a88230553d1c01447b816a4a0d
7
+ data.tar.gz: ddf9bd93160b222da814833dfb263f12fb00d1a820bcbe3895f717e321741359e90215605d7bfe87fb7d02a3dd26048cc1219722a1796d919a986e367c72062a
@@ -12,6 +12,7 @@
12
12
  @import 'pb_checkbox/checkbox';
13
13
  @import 'pb_circle_chart/circle_chart';
14
14
  @import 'pb_circle_icon_button/circle_icon_button';
15
+ @import 'pb_collapsible/collapsible';
15
16
  @import 'pb_contact/contact';
16
17
  @import 'pb_currency/currency';
17
18
  @import 'pb_dashboard_value/dashboard_value';
@@ -62,7 +63,6 @@
62
63
  @import 'pb_selectable_card/selectable_card';
63
64
  @import 'pb_selectable_card_icon/selectable_card_icon';
64
65
  @import 'pb_selectable_icon/selectable_icon';
65
- @import 'pb_selectable_list/selectable_list';
66
66
  @import 'pb_source/source';
67
67
  @import 'pb_star_rating/star_rating';
68
68
  @import 'pb_stat_change/stat_change';
@@ -13,6 +13,7 @@ kits:
13
13
  - circle_icon_button
14
14
  - card
15
15
  - checkbox
16
+ - collapsible
16
17
  - charts_and_graphs:
17
18
  - bar_graph
18
19
  - circle_chart
@@ -34,7 +35,6 @@ kits:
34
35
  - selectable_card
35
36
  - selectable_card_icon
36
37
  - selectable_icon
37
- - selectable_list
38
38
  - text_input
39
39
  - textarea
40
40
  - typeahead
@@ -15,6 +15,7 @@ export Card from './pb_card/_card.jsx'
15
15
  export Checkbox from './pb_checkbox/_checkbox.jsx'
16
16
  export CircleChart from './pb_circle_chart/_circle_chart.jsx'
17
17
  export CircleIconButton from './pb_circle_icon_button/_circle_icon_button.jsx'
18
+ export Collapsible from './pb_collapsible/_collapsible.jsx'
18
19
  export Contact from './pb_contact/_contact.jsx'
19
20
  export Currency from './pb_currency/_currency.jsx'
20
21
  export DashboardValue from './pb_dashboard_value/_dashboard_value.jsx'
@@ -68,8 +69,6 @@ export Select from './pb_select/_select.jsx'
68
69
  export SelectableCard from './pb_selectable_card/_selectable_card.jsx'
69
70
  export SelectableCardIcon from './pb_selectable_card_icon/_selectable_card_icon.jsx'
70
71
  export SelectableIcon from './pb_selectable_icon/_selectable_icon.jsx'
71
- export SelectableList from './pb_selectable_list/_selectable_list.jsx'
72
- export SelectableListItem from './pb_selectable_list/_item.jsx'
73
72
  export Source from './pb_source/_source.jsx'
74
73
  export StarRating from './pb_star_rating/_star_rating.jsx'
75
74
  export StatChange from './pb_stat_change/_stat_change.jsx'
@@ -0,0 +1,9 @@
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id) do %>
6
+ <% if object.children %>
7
+ <%= capture(&object.children) %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,133 @@
1
+ /* @flow */
2
+
3
+ import classnames from "classnames"
4
+ import { get } from "lodash"
5
+ import { Flex, FlexItem } from "../"
6
+ import React, { useState } from "react"
7
+ import AnimateHeight from "react-animate-height"
8
+ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props"
9
+ import { globalProps } from "../utilities/globalProps.js"
10
+
11
+ type CollapsibleProps = {
12
+ children: React.ChildrenArray<React.Element<typeof Main | Content>>,
13
+ aria?: object,
14
+ className?: string,
15
+ data?: object,
16
+ id?: string,
17
+ }
18
+
19
+ type CollapsibleMainProps = {
20
+ children: array<React.ReactNode> | React.ReactNode,
21
+ className?: string,
22
+ padding?: string,
23
+ }
24
+
25
+ type CollapsibleContentProps = {
26
+ children: array<React.ReactNode> | React.ReactNode | string,
27
+ className?: string,
28
+ padding?: string,
29
+ }
30
+
31
+ const Main = (props: CollapsibleMainProps) => {
32
+ const { children, className, padding = "sm" } = props
33
+ const mainCSS = buildCss("pb_collapsible_main_kit")
34
+ const mainSpacing = globalProps(props, { padding })
35
+
36
+ return (
37
+ <div className={classnames(mainCSS, className, mainSpacing)}>
38
+ {children}
39
+ </div>
40
+ )
41
+ }
42
+
43
+ const Content = (props: CollapsibleContentProps) => {
44
+ const { children, className, padding = "md" } = props
45
+ const contentCSS = buildCss("pb_collapsible_content_kit")
46
+ const contentSpacing = globalProps(props, { padding })
47
+
48
+ return (
49
+ <div className={classnames(contentCSS, className, contentSpacing)}>
50
+ {children}
51
+ </div>
52
+ )
53
+ }
54
+
55
+ const Collapsible = (props: CollapsibleProps) => {
56
+ const { aria = {}, className, children = [], data = {}, id } = props
57
+
58
+ const ariaProps = buildAriaProps(aria)
59
+ const dataProps = buildDataProps(data)
60
+ const classes = classnames(
61
+ buildCss("pb_collapsible"),
62
+ className,
63
+ globalProps(props)
64
+ )
65
+
66
+ const [height, setHeight] = useState(0)
67
+ const toggleExpand = () => {
68
+ setHeight(height === 0 ? "auto" : 0)
69
+ }
70
+
71
+ const collapsibleChildren =
72
+ typeof children === "object" && children.length ? children : [children]
73
+
74
+ console.log("CollapsibleChildren:", collapsibleChildren)
75
+
76
+ const subComponentTags = (tagName) => {
77
+ console.log("TagName:", tagName)
78
+ return collapsibleChildren
79
+ .filter((c) => get(c, "type.name") === tagName)
80
+ .map((child, i) => {
81
+ console.log("the child:", child)
82
+ return React.cloneElement(child, {
83
+ key: `${tagName.toLowerCase()}-${i}`,
84
+ })
85
+ })
86
+ }
87
+
88
+ const renderChevron = (height) => {
89
+ const direction = height === 0 ? "down" : "up"
90
+
91
+ return (
92
+ <div key={direction} style={{ verticalAlign: "middle" }}>
93
+ <i className={`far fa-2x fa-chevron-${direction} fa-fw`} />
94
+ </div>
95
+ )
96
+ }
97
+
98
+ const renderMain = () => {
99
+ const mainTags = subComponentTags("Main")
100
+
101
+ return (
102
+ <div onClick={toggleExpand}>
103
+ <Flex spacing='between' vertical='center'>
104
+ <FlexItem>{mainTags}</FlexItem>
105
+ <FlexItem>{renderChevron(height)}</FlexItem>
106
+ </Flex>
107
+ </div>
108
+ )
109
+ }
110
+
111
+ const renderContent = () => {
112
+ const nonMainChildren = collapsibleChildren.filter(
113
+ (child) => get(child, "type.name") !== "Main"
114
+ )
115
+ console.log("NonMainChildren:", nonMainChildren)
116
+ return (
117
+ <AnimateHeight duration={500} height={height} id='bottom-section'>
118
+ {nonMainChildren}
119
+ </AnimateHeight>
120
+ )
121
+ }
122
+
123
+ return (
124
+ <div {...ariaProps} {...dataProps} className={classes} id={id}>
125
+ {renderMain()}
126
+ {renderContent()}
127
+ </div>
128
+ )
129
+ }
130
+ Collapsible.Main = Main
131
+ Collapsible.Content = Content
132
+
133
+ export default Collapsible
@@ -0,0 +1,17 @@
1
+
2
+ [class^=pb_collapsible_kit] {
3
+
4
+ .toggle-content {
5
+ display: none;
6
+ height: 0;
7
+ padding-bottom: 0 !important;
8
+ padding-top: 0 !important;
9
+ overflow: hidden;
10
+ transition: height 500ms, padding 500ms ease-in-out;
11
+ }
12
+
13
+ .toggle-content.is-visible {
14
+ display: block;
15
+ height: auto;
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ aria: object.aria) do %>
6
+ <%= capture(&object.children) %>
7
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ aria: object.aria) do %>
6
+
7
+ <%= pb_rails("flex", props: {vertical: "center", spacing: "between"}) do %>
8
+ <%= pb_rails("flex/flex_item") do %>
9
+ <%= capture(&object.children) %>
10
+ <% end %>
11
+ <%= pb_rails("flex/flex_item") do %>
12
+ <i class="far fa-chevron-down"></i>
13
+ <i class="far fa-chevron-up" style="display: none"></i>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCollapsible
5
+ class Collapsible
6
+ include Playbook::Props
7
+
8
+ partial "pb_collapsible/collapsible"
9
+
10
+ def classname
11
+ generate_classname("pb_collapsible_kit")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCollapsible
5
+ class CollapsibleContent
6
+ include Playbook::Props
7
+
8
+ partial "pb_collapsible/child_kits/collapsible_content"
9
+
10
+ def data
11
+ Hash(values[:data]).merge(
12
+ collapsible_content: true
13
+ )
14
+ end
15
+
16
+ def classname
17
+ generate_classname("pb_collapsible_content_kit", "toggle-content", padding, separator: " ")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCollapsible
5
+ class CollapsibleMain
6
+ include Playbook::Props
7
+
8
+ partial "pb_collapsible/child_kits/collapsible_main"
9
+
10
+ def data
11
+ Hash(values[:data]).merge(
12
+ collapsible_main: true
13
+ )
14
+ end
15
+
16
+ def classname
17
+ generate_classname("pb_collapsible_main_kit", padding, separator: " ")
18
+ end
19
+
20
+
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ <%= pb_rails("collapsible", props: { dark: true }) do %>
2
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "sm", name: "dark-example" }) do %>
3
+ <%= pb_rails("body", props: { text: "Main Section", dark: true}) %>
4
+ <% end %>
5
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md" }) do %>
6
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis, risus a fringilla luctus, sapien eros sodales ex, quis molestie est nulla non turpis. Vestibulum aliquet at ipsum eget posuere. Morbi sed laoreet erat. Sed commodo posuere lectus, at porta nulla ornare a. Suspendisse quam est, sollicitudin ut enim sit amet, commodo placerat enim. Donec laoreet metus ac mauris pellentesque mattis. Pellentesque luctus vel mauris non aliquam. Mauris hendrerit mattis porttitor. Curabitur vehicula justo non ex consectetur commodo. Quisque posuere aliquet quam. Maecenas malesuada magna mauris, ac tempor metus euismod at.
7
+ <br><br>
8
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { Collapsible } from '../..'
3
+
4
+ const CollapsibleDark = () => (
5
+ <div>
6
+ <Collapsible>
7
+ <Collapsible.Main>
8
+ <div>{'Main Section'}</div>
9
+ </Collapsible.Main>
10
+ <Collapsible.Content>
11
+ <div>{'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit. Nulla facilisi. Vestibulum quis pretium nulla. Nulla ut accumsan velit. Duis varius urna sed sem tempor, sit amet fermentum nibh auctor. Praesent lorem arcu, egestas non ante quis, placerat pellentesque lectus.Vestibulum lacinia ipsum quis venenatis tristique. Vivamus suscipit, libero eu fringilla egestas, orci urna commodo arcu, vel gravida turpis ipsum molestie nibh. Donec cursus eu ante sagittis ultrices. Phasellus id sagittis risus. Mauris dapibus neque faucibus, tempor ligula vel, cursus ante. Donec faucibus gravida porta. Nullam egestas est quis aliquam feugiat. Sed eget metus diam. Cras eget placerat libero.'}</div>
12
+ </Collapsible.Content>
13
+ </Collapsible>
14
+ </div>
15
+ )
16
+
17
+ export default CollapsibleDark
@@ -0,0 +1,10 @@
1
+ <%= pb_rails("collapsible", props: { name: "default-example" }) do %>
2
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "sm", name: "default-main" }) do %>
3
+ <%= pb_rails("body", props: { text: "Main Section"}) %>
4
+ <% end %>
5
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md" }) do %>
6
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis, risus a fringilla luctus, sapien eros sodales ex, quis molestie est nulla non turpis. Vestibulum aliquet at ipsum eget posuere. Morbi sed laoreet erat. Sed commodo posuere lectus, at porta nulla ornare a. Suspendisse quam est, sollicitudin ut enim sit amet, commodo placerat enim. Donec laoreet metus ac mauris pellentesque mattis. Pellentesque luctus vel mauris non aliquam. Mauris hendrerit mattis porttitor. Curabitur vehicula justo non ex consectetur commodo. Quisque posuere aliquet quam. Maecenas malesuada magna mauris, ac tempor metus euismod at.
7
+ <br><br>
8
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { Collapsible } from '../..'
3
+
4
+ const CollapsibleDefault = () => (
5
+ <div>
6
+ <Collapsible>
7
+ <Collapsible.Main>
8
+ <div>{'Main Section'}</div>
9
+ </Collapsible.Main>
10
+ <Collapsible.Content>
11
+ <div>{'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit. Nulla facilisi. Vestibulum quis pretium nulla. Nulla ut accumsan velit. Duis varius urna sed sem tempor, sit amet fermentum nibh auctor. Praesent lorem arcu, egestas non ante quis, placerat pellentesque lectus.Vestibulum lacinia ipsum quis venenatis tristique. Vivamus suscipit, libero eu fringilla egestas, orci urna commodo arcu, vel gravida turpis ipsum molestie nibh. Donec cursus eu ante sagittis ultrices. Phasellus id sagittis risus. Mauris dapibus neque faucibus, tempor ligula vel, cursus ante. Donec faucibus gravida porta. Nullam egestas est quis aliquam feugiat. Sed eget metus diam. Cras eget placerat libero.'}</div>
12
+ </Collapsible.Content>
13
+ </Collapsible>
14
+ </div>
15
+ )
16
+
17
+ export default CollapsibleDefault
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - collapsible_default: Light
5
+ - collapsible_dark: Dark
6
+
7
+ react:
8
+ - collapsible_default: Light
9
+ - collapsible_dark: Dark
@@ -0,0 +1,2 @@
1
+ export { default as CollapsibleDefault } from './_collapsible_default.jsx'
2
+ export { default as CollapsibleDark } from './_collapsible_dark.jsx'
@@ -0,0 +1,82 @@
1
+ import PbEnhancedElement from '../pb_enhanced_element'
2
+
3
+ const MAIN_SELECTOR = '[data-collapsible-main]'
4
+ const CONTENT_SELECTOR = '[data-collapsible-content]'
5
+ const DOWN_ARROW_SELECTOR = '.fa-chevron-down'
6
+ const UP_ARROW_SELECTOR = '.fa-chevron-up'
7
+
8
+ export default class PbCollapsible extends PbEnhancedElement {
9
+ static get selector() {
10
+ return MAIN_SELECTOR
11
+ }
12
+
13
+ connect() {
14
+ this.element.addEventListener('click', () => {
15
+ this.toggle(this.target)
16
+ })
17
+ this.displayDownArrow()
18
+ }
19
+
20
+ get target() {
21
+ return this.element.parentNode.querySelector(CONTENT_SELECTOR)
22
+ }
23
+
24
+ // Show an element
25
+ show(elem) {
26
+ // Get the natural height of the element
27
+ const getHeight = () => {
28
+ elem.style.display = 'block' // Make it visible
29
+ const height = elem.scrollHeight + 'px' // Get it's height
30
+ elem.style.display = '' // Hide it again
31
+ return height
32
+ }
33
+
34
+ const height = getHeight() // Get the natural height
35
+ elem.classList.add('is-visible') // Make the element visible
36
+ elem.style.height = height // Update the max-height
37
+
38
+ // Once the transition is complete, remove the inline max-height so the content can scale responsively
39
+ window.setTimeout(() => {
40
+ elem.style.height = ''
41
+ }, 500)
42
+ }
43
+ // Hide an element
44
+ hide(elem) {
45
+ // Give the element a height to change from
46
+ elem.style.height = elem.scrollHeight + 'px'
47
+ // Set the height back to 0
48
+ window.setTimeout(() => {
49
+ elem.style.height = '0'
50
+ elem.style.paddingTop = '0'
51
+ elem.style.paddingBottom = '0'
52
+ }, 1)
53
+
54
+ // When the transition is complete, hide it
55
+ window.setTimeout(() => {
56
+ elem.classList.remove('is-visible')
57
+ }, 500)
58
+ }
59
+
60
+ // Toggle element visibility
61
+ toggle(elem) {
62
+ // If the element is visible, hide it
63
+ if (elem.classList.contains('is-visible')) {
64
+ this.hide(elem)
65
+ this.displayDownArrow()
66
+ return
67
+ }
68
+ // Otherwise, show it
69
+ this.show(elem)
70
+ this.displayUpArrow()
71
+ }
72
+
73
+ displayDownArrow() {
74
+ this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'inline-block'
75
+ this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'none'
76
+ }
77
+
78
+ displayUpArrow() {
79
+ this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
80
+ this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
81
+ }
82
+ }
@@ -0,0 +1,10 @@
1
+ /* @flow */
2
+
3
+ import { useState } from "react"
4
+
5
+ export const useToggler = (startValue: boolean = false) => {
6
+ const [show, toggle] = useState(startValue)
7
+ const toggler = () => toggle(!show)
8
+
9
+ return [show, toggler]
10
+ }
@@ -17,9 +17,7 @@ type ListProps = {
17
17
  ordered: boolean,
18
18
  role?: string,
19
19
  tabIndex?: string,
20
- text?: string,
21
20
  size?: string,
22
- variant?: string,
23
21
  xpadding: boolean,
24
22
  }
25
23
 
@@ -38,8 +36,6 @@ const List = (props: ListProps) => {
38
36
  size = '',
39
37
  tabIndex,
40
38
  xpadding = false,
41
- variant,
42
- text,
43
39
  } = props
44
40
 
45
41
  const layoutClass = {
@@ -48,9 +44,6 @@ const List = (props: ListProps) => {
48
44
  default: '',
49
45
  }
50
46
 
51
- const childrenWithProps = React.Children.map(children, (child) => {
52
- return React.cloneElement(child, { text, variant })
53
- })
54
47
  const ariaProps = buildAriaProps(aria)
55
48
  const dataProps = buildDataProps(data)
56
49
  const classes = classnames(
@@ -77,7 +70,7 @@ const List = (props: ListProps) => {
77
70
  role={role}
78
71
  tabIndex={tabIndex}
79
72
  >
80
- {childrenWithProps}
73
+ {children}
81
74
  </ol>
82
75
  <Else />
83
76
  <ul
@@ -88,7 +81,7 @@ const List = (props: ListProps) => {
88
81
  role={role}
89
82
  tabIndex={tabIndex}
90
83
  >
91
- {childrenWithProps}
84
+ {children}
92
85
  </ul>
93
86
  </If>
94
87
  </div>
@@ -12,6 +12,9 @@ window.datePickerHelper = datePickerHelper
12
12
  // Lazy image loading
13
13
  import 'lazysizes'
14
14
 
15
+ import PbCollapsible from './pb_collapsible'
16
+ PbCollapsible.start()
17
+
15
18
  import PbPopover from './pb_popover'
16
19
  PbPopover.start()
17
20
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  module Playbook
4
- VERSION = "7.3.0.pre.alpha8"
3
+ VERSION = "7.3.0.pre.alpha9"
5
4
  end
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: 7.3.0.pre.alpha8
4
+ version: 7.3.0.pre.alpha9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-21 00:00:00.000000000 Z
12
+ date: 2020-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -625,6 +625,22 @@ files:
625
625
  - app/pb_kits/playbook/pb_circle_icon_button/docs/_footer.md
626
626
  - app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml
627
627
  - app/pb_kits/playbook/pb_circle_icon_button/docs/index.js
628
+ - app/pb_kits/playbook/pb_collapsible/_collapsible.html.erb
629
+ - app/pb_kits/playbook/pb_collapsible/_collapsible.jsx
630
+ - app/pb_kits/playbook/pb_collapsible/_collapsible.scss
631
+ - app/pb_kits/playbook/pb_collapsible/child_kits/_collapsible_content.html.erb
632
+ - app/pb_kits/playbook/pb_collapsible/child_kits/_collapsible_main.html.erb
633
+ - app/pb_kits/playbook/pb_collapsible/collapsible.rb
634
+ - app/pb_kits/playbook/pb_collapsible/collapsible_content.rb
635
+ - app/pb_kits/playbook/pb_collapsible/collapsible_main.rb
636
+ - app/pb_kits/playbook/pb_collapsible/docs/_collapsible_dark.html.erb
637
+ - app/pb_kits/playbook/pb_collapsible/docs/_collapsible_dark.jsx
638
+ - app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.html.erb
639
+ - app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx
640
+ - app/pb_kits/playbook/pb_collapsible/docs/example.yml
641
+ - app/pb_kits/playbook/pb_collapsible/docs/index.js
642
+ - app/pb_kits/playbook/pb_collapsible/index.js
643
+ - app/pb_kits/playbook/pb_collapsible/useToggler.js
628
644
  - app/pb_kits/playbook/pb_contact/_contact.html.erb
629
645
  - app/pb_kits/playbook/pb_contact/_contact.jsx
630
646
  - app/pb_kits/playbook/pb_contact/_contact.scss
@@ -1462,19 +1478,6 @@ files:
1462
1478
  - app/pb_kits/playbook/pb_selectable_icon/docs/example.yml
1463
1479
  - app/pb_kits/playbook/pb_selectable_icon/docs/index.js
1464
1480
  - app/pb_kits/playbook/pb_selectable_icon/selectable_icon.rb
1465
- - app/pb_kits/playbook/pb_selectable_list/_item.jsx
1466
- - app/pb_kits/playbook/pb_selectable_list/_selectable_list.html.erb
1467
- - app/pb_kits/playbook/pb_selectable_list/_selectable_list.jsx
1468
- - app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss
1469
- - app/pb_kits/playbook/pb_selectable_list/_selectable_list_item.html.erb
1470
- - app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.html.erb
1471
- - app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.jsx
1472
- - app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.html.erb
1473
- - app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.jsx
1474
- - app/pb_kits/playbook/pb_selectable_list/docs/example.yml
1475
- - app/pb_kits/playbook/pb_selectable_list/docs/index.js
1476
- - app/pb_kits/playbook/pb_selectable_list/selectable_list.rb
1477
- - app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb
1478
1481
  - app/pb_kits/playbook/pb_source/_source.html.erb
1479
1482
  - app/pb_kits/playbook/pb_source/_source.jsx
1480
1483
  - app/pb_kits/playbook/pb_source/_source.scss
@@ -1883,8 +1886,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1883
1886
  - !ruby/object:Gem::Version
1884
1887
  version: 1.3.1
1885
1888
  requirements: []
1886
- rubyforge_project:
1887
- rubygems_version: 2.7.3
1889
+ rubygems_version: 3.1.4
1888
1890
  signing_key:
1889
1891
  specification_version: 4
1890
1892
  summary: Playbook Design System
@@ -1,92 +0,0 @@
1
- /* @flow */
2
- import React, { Node } from 'react'
3
- import classnames from 'classnames'
4
- import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps.js'
6
- import { Checkbox, ListItem, Radio } from '..'
7
-
8
- type SelectableListItemProps = {
9
- aria?: object,
10
- children: array<Node> | Node,
11
- checked?: boolean,
12
- className?: string,
13
- data?: object,
14
- defaultChecked?: boolean,
15
- id?: string,
16
- label?: string,
17
- text?: string,
18
- name?: string,
19
- value?: string,
20
- variant?: string,
21
- onChange: (boolean)=>void,
22
- }
23
-
24
- const SelectableListItem = ({
25
- aria = {},
26
- checked = false,
27
- children,
28
- className,
29
- data = {},
30
- defaultChecked,
31
- id,
32
- label,
33
- text,
34
- name = '',
35
- value = '',
36
- variant,
37
- onChange = () => {},
38
- ...props
39
- }: SelectableListItemProps) => {
40
- const ariaProps = buildAriaProps(aria)
41
- const dataProps = buildDataProps(data)
42
- const classes = classnames(
43
- buildCss('pb_selectable_list_item_kit'),
44
- globalProps(props),
45
- className
46
- )
47
-
48
- return (
49
- <ListItem {...props}>
50
- <div
51
- {...ariaProps}
52
- {...dataProps}
53
- className={classes}
54
- htmlFor={id}
55
- >
56
- <Choose>
57
- <When condition={variant == 'checkbox'}>
58
- <Checkbox
59
- checked={checked}
60
- id={id}
61
- name={name}
62
- onChange={onChange}
63
- // eslint suppressor, text is needed to display on screen
64
- text={label || (text && false)}
65
- type="checkbox"
66
- value={value}
67
- {...props}
68
- />
69
- {children}
70
- </When>
71
- <When condition={variant == 'radio'}>
72
- <Radio
73
- defaultChecked={defaultChecked}
74
- id={id}
75
- label={label}
76
- name={name}
77
- onChange={onChange}
78
- type="radio"
79
- value={value}
80
- {...props}
81
- />
82
- {children}
83
- </When>
84
- <Otherwise>{children}</Otherwise>
85
- </Choose>
86
-
87
- </div>
88
- </ListItem>
89
- )
90
- }
91
-
92
- export default SelectableListItem
@@ -1,11 +0,0 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
6
- <%= pb_rails("list") do %>
7
- <% object.items.each do |item| %>
8
- <%= pb_rails("selectable_list/selectable_list_item", props: item.merge(variant: object.variant) )%>
9
- <% end %>
10
- <% end %>
11
- <% end %>
@@ -1,47 +0,0 @@
1
- /* @flow */
2
- import React from 'react'
3
- import classnames from 'classnames'
4
- import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps.js'
6
- import { List } from '..'
7
- import SelectableListItem from './_item.jsx'
8
-
9
- type SelectableListProps = {
10
- aria?: object,
11
- children?: Node,
12
- className?: string,
13
- data?: object,
14
- id?: string,
15
- variant?: 'checkbox' | 'radio',
16
- }
17
-
18
- const SelectableList = (props: SelectableListProps) => {
19
- const {
20
- aria = {},
21
- children,
22
- className,
23
- data = {},
24
- id,
25
- } = props
26
-
27
- const ariaProps = buildAriaProps(aria)
28
- const classes = classnames(buildCss('pb_selectable_list_kit'), globalProps(props), className)
29
- const dataProps = buildDataProps(data)
30
-
31
- return (
32
- <div
33
- {...ariaProps}
34
- {...dataProps}
35
- className={classes}
36
- id={id}
37
- >
38
- <List {...props}>
39
- {children}
40
- </List>
41
- </div>
42
- )
43
- }
44
-
45
- SelectableList.Item = SelectableListItem
46
-
47
- export default SelectableList
@@ -1,17 +0,0 @@
1
- @import "../tokens/colors";
2
- @import "../tokens/spacing";
3
-
4
- [class^=pb_selectable_list]{
5
- margin-bottom: 0px;
6
- [class^=pb_item_kit] {
7
- &:hover {
8
- background-color: $bg_light;
9
- }
10
- }
11
- [class^=pb_radio_kit] {
12
- margin-left: $space_xs;
13
- }
14
- [class^=pb_checkbox_kit] {
15
- margin-left: $space_xs;
16
- }
17
- }
@@ -1,18 +0,0 @@
1
- <%= content_tag(:li,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
6
- <% puts object.variant %>
7
- <% if object.variant == "radio"%>
8
- <%= pb_rails("radio", props: { text: object.text, checked: object.checked } ) %>
9
- <% if object.children.present? %>
10
- <%= capture(&object.children) %>
11
- <% end %>
12
- <% else %>
13
- <%= pb_rails("checkbox", props: { text: object.text, checked: object.checked } ) %>
14
- <% if object.children.present? %>
15
- <%= capture(&object.children) %>
16
- <% end %>
17
- <% end %>
18
- <% end %>
@@ -1,13 +0,0 @@
1
- <%= pb_rails("selectable_list",
2
- props: {
3
- variant: "checkbox",
4
- items: [
5
- { text: "Monday", name: "custum1" },
6
- { text: "Tuesday", name: "custum2", checked: true },
7
- { text: "Wednesday", name: "custum3" },
8
- { text: "Thursday", name: "custum4" },
9
- { text: "Friday", name: "custum5" },
10
- ]
11
- }
12
- )
13
- %>
@@ -1,34 +0,0 @@
1
- import React from 'react'
2
- import { SelectableList } from '../..'
3
-
4
- const SelectableListDefault = () => {
5
- return (
6
- <div>
7
- <SelectableList variant="checkbox">
8
- <SelectableList.Item
9
- label="Monday"
10
- name="custom1"
11
- />
12
- <SelectableList.Item
13
- checked
14
- label="Tuesday"
15
- name="custom2"
16
- />
17
- <SelectableList.Item
18
- label="Wednesday"
19
- name="custom3"
20
- />
21
- <SelectableList.Item
22
- label="Thursday"
23
- name="custom4"
24
- />
25
- <SelectableList.Item
26
- label="Friday"
27
- name="custom5"
28
- />
29
- </SelectableList>
30
- </div>
31
- )
32
- }
33
-
34
- export default SelectableListDefault
@@ -1,13 +0,0 @@
1
- <%= pb_rails("selectable_list",
2
- props: {
3
- variant: "radio",
4
- items: [
5
- { text: "Monday", name: "custum1" },
6
- { text: "Tuesday", name: "custum2", checked: true },
7
- { text: "Wednesday", name: "custum3" },
8
- { text: "Thursday", name: "custum4" },
9
- { text: "Friday", name: "custum5" },
10
- ]
11
- }
12
- )
13
- %>
@@ -1,38 +0,0 @@
1
- import React from 'react'
2
- import { SelectableList } from '../..'
3
-
4
- const SelectableListDefault = () => {
5
- return (
6
- <div>
7
- <SelectableList variant="radio">
8
- <SelectableList.Item
9
- defaultChecked={false}
10
- label="Monday"
11
- name="custom1"
12
- />
13
- <SelectableList.Item
14
- defaultChecked
15
- label="Tuesday"
16
- name="custom1"
17
- />
18
- <SelectableList.Item
19
- defaultChecked={false}
20
- label="Wednesday"
21
- name="custom1"
22
- />
23
- <SelectableList.Item
24
- defaultChecked={false}
25
- label="Thursday"
26
- name="custom1"
27
- />
28
- <SelectableList.Item
29
- defaultChecked={false}
30
- label="Friday"
31
- name="custom1"
32
- />
33
- </SelectableList>
34
- </div>
35
- )
36
- }
37
-
38
- export default SelectableListDefault
@@ -1,12 +0,0 @@
1
- examples:
2
-
3
- rails:
4
- - selectable_list_checkbox: Selectable List Checkbox
5
- - selectable_list_radio: Selectable List Radio
6
-
7
-
8
- react:
9
- - selectable_list_checkbox: Selectable List Checkbox
10
- - selectable_list_radio: Selectable List Radio
11
-
12
-
@@ -1,2 +0,0 @@
1
- export { default as SelectableListCheckbox } from './_selectable_list_checkbox.jsx'
2
- export { default as SelectableListRadio } from './_selectable_list_radio.jsx'
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Playbook
4
- module PbSelectableList
5
- class SelectableList
6
- include Playbook::Props
7
-
8
- partial "pb_selectable_list/selectable_list"
9
-
10
- prop :variant, type: Playbook::Props::Enum,
11
- values: %w[radio checkbox],
12
- default: "radio"
13
-
14
- prop :text, type: Playbook::Props::String
15
-
16
- prop :items, type: Playbook::Props::Array,
17
- default: []
18
-
19
- def classname
20
- generate_classname("pb_selectable_list_kit")
21
- end
22
- end
23
- end
24
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Playbook
4
- module PbSelectableList
5
- class SelectableListItem
6
- include Playbook::Props
7
-
8
- prop :tabindex
9
-
10
- prop :checked, type: Playbook::Props::Boolean,
11
- default: false
12
- prop :name, type: Playbook::Props::String,
13
- default: "radio_name"
14
- prop :text, type: Playbook::Props::String
15
- prop :value, type: Playbook::Props::String,
16
- default: "radio_text"
17
-
18
- prop :variant, type: Playbook::Props::Enum,
19
- values: %w[radio checkbox],
20
- default: "radio"
21
-
22
- partial "pb_selectable_list/selectable_list_item"
23
-
24
- def classname
25
- generate_classname("pb_selectable_list_item_kit")
26
- end
27
- end
28
- end
29
- end