playbook_ui 4.6.1 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/data/menu.yml +2 -1
- data/app/pb_kits/playbook/index.js +1 -0
- data/app/pb_kits/playbook/packs/examples.js +2 -0
- data/app/pb_kits/playbook/packs/kits/pb_form_pill.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.html.erb +22 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +60 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +49 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.html.erb +4 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +11 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +12 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +19 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +10 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +23 -0
- data/app/pb_kits/playbook/pb_home_address_street/_city_emphasis.html.erb +40 -0
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.html.erb +6 -35
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +53 -17
- data/app/pb_kits/playbook/pb_home_address_street/_street_emphasis.html.erb +31 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.html.erb +27 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.jsx +36 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.md +2 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +11 -0
- data/app/pb_kits/playbook/pb_popover/_popover.jsx +102 -53
- data/app/pb_kits/playbook/pb_popover/docs/_description.md +13 -1
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_any.html.erb +19 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_any.jsx +40 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_inside.html.erb +14 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_inside.jsx +40 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_outside.html.erb +14 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_click_outside.jsx +40 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_default.jsx +18 -21
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.jsx +32 -34
- data/app/pb_kits/playbook/pb_popover/docs/_popover_portal.jsx +24 -26
- data/app/pb_kits/playbook/pb_popover/docs/_popover_with_button.jsx +24 -26
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +7 -1
- data/app/pb_kits/playbook/pb_popover/docs/index.js +3 -0
- data/app/pb_kits/playbook/pb_popover/index.js +51 -3
- data/app/pb_kits/playbook/pb_popover/popover.rb +4 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +24 -2
@@ -0,0 +1,31 @@
|
|
1
|
+
<%= pb_rails "title", props: {
|
2
|
+
classname: "pb_home_address_street_address",
|
3
|
+
size: 4,
|
4
|
+
text: object.address_house_style,
|
5
|
+
dark: object.dark
|
6
|
+
} %>
|
7
|
+
<%= pb_rails "title", props: {
|
8
|
+
classname: "pb_home_address_street_address",
|
9
|
+
size: 4,
|
10
|
+
text: object.address_house_style2,
|
11
|
+
dark: object.dark
|
12
|
+
} %>
|
13
|
+
<%= pb_rails "body", props: {
|
14
|
+
color: "light",
|
15
|
+
text: object.city_state_zip,
|
16
|
+
dark: object.dark
|
17
|
+
} %>
|
18
|
+
|
19
|
+
<% if object.home_id %>
|
20
|
+
<%= pb_rails("hashtag", props: {
|
21
|
+
text: "#{object.home_id}",
|
22
|
+
url: object.home_url || "#",
|
23
|
+
type: "home",
|
24
|
+
dark: object.dark,
|
25
|
+
classname: "home-hashtag"}) %>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<%= pb_rails "body", props: { color: "light", tag: "span", dark: object.dark } do %>
|
29
|
+
<small><%= object.territory %></small>
|
30
|
+
<% end %>
|
31
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= pb_rails("home_address_street", props: {
|
2
|
+
address: "70 Prospect Ave",
|
3
|
+
address_cont: "Apt M18",
|
4
|
+
city: "West Chester",
|
5
|
+
home_id: 8250263,
|
6
|
+
home_url: "https://powerhrg.com/",
|
7
|
+
house_style: "Colonial",
|
8
|
+
state: "PA",
|
9
|
+
zipcode: "19382",
|
10
|
+
territory: "PHL",
|
11
|
+
}) %>
|
12
|
+
|
13
|
+
<br>
|
14
|
+
<br>
|
15
|
+
|
16
|
+
<%= pb_rails("home_address_street", props: {
|
17
|
+
address: "70 Prospect Ave",
|
18
|
+
address_cont: "Apt M18",
|
19
|
+
city: "West Chester",
|
20
|
+
emphasis: "city",
|
21
|
+
home_id: 8250263,
|
22
|
+
home_url: "https://powerhrg.com/",
|
23
|
+
house_style: "Colonial",
|
24
|
+
state: "PA",
|
25
|
+
zipcode: "19382",
|
26
|
+
territory: "PHL",
|
27
|
+
}) %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { HomeAddressStreet } from '../../'
|
3
|
+
|
4
|
+
const HomeAddressStreetEmphasis = () => {
|
5
|
+
return (
|
6
|
+
<div>
|
7
|
+
<HomeAddressStreet
|
8
|
+
address="70 Prospect Ave"
|
9
|
+
addressCont="Apt M18"
|
10
|
+
city="West Chester"
|
11
|
+
homeId={8250263}
|
12
|
+
homeUrl="https://powerhrg.com/"
|
13
|
+
houseStyle="Colonial"
|
14
|
+
state="PA"
|
15
|
+
territory="PHL"
|
16
|
+
zipcode="19382"
|
17
|
+
/>
|
18
|
+
<br />
|
19
|
+
<br />
|
20
|
+
<HomeAddressStreet
|
21
|
+
address="70 Prospect Ave"
|
22
|
+
addressCont="Apt M18"
|
23
|
+
city="West Chester"
|
24
|
+
emphasis="city"
|
25
|
+
homeId={8250263}
|
26
|
+
homeUrl="https://powerhrg.com/"
|
27
|
+
houseStyle="Colonial"
|
28
|
+
state="PA"
|
29
|
+
territory="PHL"
|
30
|
+
zipcode="19382"
|
31
|
+
/>
|
32
|
+
</div>
|
33
|
+
)
|
34
|
+
}
|
35
|
+
|
36
|
+
export default HomeAddressStreetEmphasis
|
@@ -2,12 +2,14 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- home_address_street_default: Default
|
5
|
+
- home_address_street_emphasis: Emphasis
|
5
6
|
- home_address_street_modified: Modified
|
6
7
|
- home_address_street_dark: Dark
|
7
8
|
|
8
9
|
|
9
10
|
react:
|
10
11
|
- home_address_street_default: Default
|
12
|
+
- home_address_street_emphasis: Emphasis
|
11
13
|
- home_address_street_modified: Modified
|
12
14
|
- home_address_street_dark: Dark
|
13
15
|
|
@@ -1,3 +1,4 @@
|
|
1
1
|
export { default as HomeAddressStreetDefault } from './_home_address_street_default.jsx'
|
2
|
+
export { default as HomeAddressStreetEmphasis } from './_home_address_street_emphasis.jsx'
|
2
3
|
export { default as HomeAddressStreetModified } from './_home_address_street_modified.jsx'
|
3
4
|
export { default as HomeAddressStreetDark } from './_home_address_street_dark.jsx'
|
@@ -10,6 +10,9 @@ module Playbook
|
|
10
10
|
prop :address
|
11
11
|
prop :address_cont
|
12
12
|
prop :city
|
13
|
+
prop :emphasis, type: Playbook::Props::Enum,
|
14
|
+
values: %w[street city],
|
15
|
+
default: "street"
|
13
16
|
prop :home_id, type: Playbook::Props::Number
|
14
17
|
prop :home_url
|
15
18
|
prop :house_style
|
@@ -26,6 +29,14 @@ module Playbook
|
|
26
29
|
"#{city.titleize}, #{state} #{zipcode}"
|
27
30
|
end
|
28
31
|
|
32
|
+
def city_state
|
33
|
+
"#{city.titleize}, #{state}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def zip
|
37
|
+
zipcode.to_s
|
38
|
+
end
|
39
|
+
|
29
40
|
def address_house_style
|
30
41
|
"#{address.titleize} #{separator} #{house_style}"
|
31
42
|
end
|
@@ -10,14 +10,20 @@ import {
|
|
10
10
|
Reference as PopperReference,
|
11
11
|
} from 'react-popper'
|
12
12
|
|
13
|
-
import {
|
13
|
+
import {
|
14
|
+
buildCss,
|
15
|
+
noop,
|
16
|
+
} from '../utilities/props'
|
17
|
+
|
14
18
|
import { Card } from '../'
|
15
19
|
|
16
20
|
type PbPopoverProps = {
|
17
21
|
className?: String,
|
22
|
+
closeOnClick?: 'outside' | 'inside',
|
18
23
|
offset?: Boolean,
|
19
24
|
reference: PopperReference,
|
20
25
|
show?: Boolean,
|
26
|
+
shouldClosePopover?: () => Boolean,
|
21
27
|
} & PopperProps
|
22
28
|
|
23
29
|
const POPOVER_OFFSET_Y = {
|
@@ -65,57 +71,100 @@ const Popover = ({
|
|
65
71
|
</Popper>
|
66
72
|
)
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
74
|
+
export default class PbReactPopover extends React.Component<PbPopoverProps> {
|
75
|
+
static defaultProps = {
|
76
|
+
modifiers: {},
|
77
|
+
offset: false,
|
78
|
+
placement: 'left',
|
79
|
+
portal: 'body',
|
80
|
+
show: false,
|
81
|
+
shouldClosePopover: noop,
|
82
|
+
usePortal: false,
|
83
|
+
}
|
84
|
+
|
85
|
+
componentDidMount() {
|
86
|
+
const { closeOnClick, shouldClosePopover } = this.props
|
87
|
+
|
88
|
+
if (!closeOnClick) return
|
89
|
+
|
90
|
+
document.body.addEventListener('click', ({ target }) => {
|
91
|
+
const targetIsPopover = target.closest('[class^=popover_tooltip]') !== null
|
92
|
+
const targetIsReference = target.closest('.pb_popover_reference_wrapper') !== null
|
93
|
+
|
94
|
+
if (targetIsReference) return
|
95
|
+
|
96
|
+
switch (closeOnClick) {
|
97
|
+
case 'outside':
|
98
|
+
if (!targetIsPopover) {
|
99
|
+
shouldClosePopover(true)
|
100
|
+
}
|
101
|
+
break
|
102
|
+
case 'inside':
|
103
|
+
if (targetIsPopover) {
|
104
|
+
shouldClosePopover(true)
|
105
|
+
}
|
106
|
+
break
|
107
|
+
case 'any':
|
108
|
+
shouldClosePopover(true)
|
109
|
+
break
|
110
|
+
}
|
111
|
+
})
|
112
|
+
}
|
113
|
+
|
114
|
+
props: PbPopoverProps
|
115
|
+
|
116
|
+
render() {
|
117
|
+
const {
|
118
|
+
className,
|
119
|
+
children,
|
120
|
+
modifiers,
|
121
|
+
offset,
|
122
|
+
placement,
|
123
|
+
portal,
|
124
|
+
reference,
|
125
|
+
referenceElement,
|
126
|
+
show,
|
127
|
+
usePortal,
|
128
|
+
} = this.props
|
129
|
+
|
130
|
+
const popoverComponent = (
|
131
|
+
<Popover
|
132
|
+
className={className}
|
133
|
+
modifiers={modifiers}
|
134
|
+
offset={offset}
|
135
|
+
placement={placement}
|
136
|
+
referenceElement={referenceElement}
|
137
|
+
show={show}
|
138
|
+
>
|
139
|
+
{children}
|
140
|
+
</Popover>
|
141
|
+
)
|
142
|
+
|
143
|
+
return (
|
144
|
+
<PopperManager>
|
145
|
+
<If condition={reference && !referenceElement}>
|
146
|
+
<PopperReference>
|
147
|
+
{({ ref }) => (
|
148
|
+
<span
|
149
|
+
className="pb_popover_reference_wrapper"
|
150
|
+
ref={ref}
|
151
|
+
>
|
152
|
+
<reference.type
|
153
|
+
{...reference.props}
|
154
|
+
/>
|
155
|
+
</span>
|
156
|
+
)}
|
157
|
+
</PopperReference>
|
158
|
+
</If>
|
159
|
+
<If condition={usePortal}>
|
160
|
+
{ReactDOM.createPortal(
|
161
|
+
popoverComponent,
|
162
|
+
document.querySelector(portal)
|
106
163
|
)}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
)}
|
114
|
-
<Else />
|
115
|
-
{popoverComponent}
|
116
|
-
</If>
|
117
|
-
</PopperManager>
|
118
|
-
)
|
164
|
+
<Else />
|
165
|
+
{popoverComponent}
|
166
|
+
</If>
|
167
|
+
</PopperManager>
|
168
|
+
)
|
169
|
+
}
|
119
170
|
}
|
120
|
-
|
121
|
-
export default PbReactPopover
|
@@ -1 +1,13 @@
|
|
1
|
-
A popover is a way to toggle content on top of other content. It can be used for small texts, small forms, or even dropdowns.
|
1
|
+
A `popover` is a way to toggle content on top of other content. It can be used for small texts, small forms, or even dropdowns. By default, popover will toggle open/closed by simply clicking the trigger element.
|
2
|
+
|
3
|
+
### Enhancements
|
4
|
+
|
5
|
+
In addition, you may also choose to enable enhanced functionality so that the popover may be toggled by clicking outside of the "trigger element" and/or popover itself.
|
6
|
+
|
7
|
+
#### Usecase #1 - Close on click into popover content
|
8
|
+
|
9
|
+
You are building a single page application where clicking into the popover itself triggers some asynchronous actions which mutate the UI instantaneously. As a result, may want the popover to automatically close after a selection has been made from the popover contents.
|
10
|
+
|
11
|
+
#### Usecase #2 - Close only on click outside of popover content
|
12
|
+
|
13
|
+
You are building an custom in-page results filter list which is contained inside of the popover's content area. Since the filter list contains 5 filters, you may want to keep the popover open so that users may select multiple filters then only close the popover when users click outside of the popover.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= pb_rails("button", props: {
|
2
|
+
text: "Click me then click anywhere",
|
3
|
+
variant: "secondary",
|
4
|
+
id: 'any-popover-1'
|
5
|
+
}) %>
|
6
|
+
|
7
|
+
<%= pb_rails("popover", props: {
|
8
|
+
close_on_click: "any",
|
9
|
+
trigger_element_id: "any-popover-1",
|
10
|
+
tooltip_id: "any-tooltip-1",
|
11
|
+
position: 'right',
|
12
|
+
offset: false
|
13
|
+
}) do %>
|
14
|
+
Whoa. I'm a popover that can be closed by clicking anywhere.
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import {
|
3
|
+
Button,
|
4
|
+
PbReactPopover,
|
5
|
+
} from '../..'
|
6
|
+
|
7
|
+
const PopoverClickAny = () => {
|
8
|
+
const [showPopover, setShowPopover] = useState(false)
|
9
|
+
|
10
|
+
const handleTogglePopover = () => {
|
11
|
+
setShowPopover(!showPopover)
|
12
|
+
}
|
13
|
+
|
14
|
+
const handleShouldClosePopover = (shouldClosePopover) => {
|
15
|
+
setShowPopover(!shouldClosePopover)
|
16
|
+
}
|
17
|
+
|
18
|
+
const popoverTrigger = (
|
19
|
+
<Button
|
20
|
+
onClick={handleTogglePopover}
|
21
|
+
text="Button Secondary"
|
22
|
+
variant="secondary"
|
23
|
+
/>
|
24
|
+
)
|
25
|
+
|
26
|
+
return (
|
27
|
+
<PbReactPopover
|
28
|
+
closeOnClick="any"
|
29
|
+
offset
|
30
|
+
placement="bottom"
|
31
|
+
reference={popoverTrigger}
|
32
|
+
shouldClosePopover={handleShouldClosePopover}
|
33
|
+
show={showPopover}
|
34
|
+
>
|
35
|
+
{'Whoa. I\'m a popover.'}
|
36
|
+
</PbReactPopover>
|
37
|
+
)
|
38
|
+
}
|
39
|
+
|
40
|
+
export default PopoverClickAny
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= pb_rails("button", props: { text: "Click me then click the popover", variant: "secondary", id: 'inside-popover-1' }) %>
|
2
|
+
<%= pb_rails("popover", props: {
|
3
|
+
close_on_click: "inside",
|
4
|
+
trigger_element_id: "inside-popover-1",
|
5
|
+
tooltip_id: "inside-tooltip-1",
|
6
|
+
position: 'right',
|
7
|
+
offset: false
|
8
|
+
}) do %>
|
9
|
+
Whoa. I'm a popover that can be closed by clicking inside of me.
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import {
|
3
|
+
Button,
|
4
|
+
PbReactPopover,
|
5
|
+
} from '../..'
|
6
|
+
|
7
|
+
const PopoverClickInside = () => {
|
8
|
+
const [showPopover, setShowPopover] = useState(false)
|
9
|
+
|
10
|
+
const handleTogglePopover = () => {
|
11
|
+
setShowPopover(!showPopover)
|
12
|
+
}
|
13
|
+
|
14
|
+
const handleShouldClosePopover = (shouldClosePopover) => {
|
15
|
+
setShowPopover(!shouldClosePopover)
|
16
|
+
}
|
17
|
+
|
18
|
+
const popoverTrigger = (
|
19
|
+
<Button
|
20
|
+
onClick={handleTogglePopover}
|
21
|
+
text="Button Secondary"
|
22
|
+
variant="secondary"
|
23
|
+
/>
|
24
|
+
)
|
25
|
+
|
26
|
+
return (
|
27
|
+
<PbReactPopover
|
28
|
+
closeOnClick="inside"
|
29
|
+
offset
|
30
|
+
placement="bottom"
|
31
|
+
reference={popoverTrigger}
|
32
|
+
shouldClosePopover={handleShouldClosePopover}
|
33
|
+
show={showPopover}
|
34
|
+
>
|
35
|
+
{'Whoa. I\'m a popover.'}
|
36
|
+
</PbReactPopover>
|
37
|
+
)
|
38
|
+
}
|
39
|
+
|
40
|
+
export default PopoverClickInside
|