playbook_ui 7.5.1 → 7.6.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/assets/images/sample_screenshot.svg +7 -0
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/data/menu.yml +1 -6
- data/app/pb_kits/playbook/index.js +2 -0
- data/app/pb_kits/playbook/pb_background/_background.html.erb +18 -12
- data/app/pb_kits/playbook/pb_background/_background.jsx +14 -10
- data/app/pb_kits/playbook/pb_background/docs/_background_dark.jsx +4 -6
- data/app/pb_kits/playbook/pb_background/docs/_background_gradient.jsx +4 -6
- data/app/pb_kits/playbook/pb_background/docs/_background_image.jsx +20 -22
- data/app/pb_kits/playbook/pb_background/docs/_background_light.jsx +4 -6
- data/app/pb_kits/playbook/pb_background/docs/_background_white.jsx +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.html.erb +1 -1
- data/app/pb_kits/playbook/pb_image/_image.html.erb +2 -1
- data/app/pb_kits/playbook/pb_image/_image.jsx +7 -1
- data/app/pb_kits/playbook/pb_image/_image.scss +41 -14
- data/app/pb_kits/playbook/pb_image/docs/_default_image.html.erb +12 -0
- data/app/pb_kits/playbook/pb_image/docs/_default_image.jsx +25 -3
- data/app/pb_kits/playbook/pb_image/docs/_rounded_image.html.erb +17 -0
- data/app/pb_kits/playbook/pb_image/docs/_rounded_image.jsx +36 -0
- data/app/pb_kits/playbook/pb_image/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_image/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_image/image.rb +16 -1
- data/app/pb_kits/playbook/pb_list/_list.jsx +9 -2
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_image.html.erb +27 -0
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_image.jsx +61 -0
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_image.md +1 -0
- data/app/pb_kits/playbook/pb_selectable_card/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_selectable_card/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_selectable_list/_item.jsx +90 -0
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.html.erb +11 -0
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.jsx +47 -0
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +17 -0
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list_item.html.erb +18 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.html.erb +27 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_checkbox.jsx +29 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.html.erb +27 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/_selectable_list_radio.jsx +29 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/example.yml +12 -0
- data/app/pb_kits/playbook/pb_selectable_list/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.rb +24 -0
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +28 -0
- data/lib/playbook/version.rb +1 -1
- metadata +25 -6
@@ -8,10 +8,25 @@ module Playbook
|
|
8
8
|
partial "pb_image/image"
|
9
9
|
|
10
10
|
prop :alt
|
11
|
+
prop :rounded, type: Playbook::Props::Boolean,
|
12
|
+
default: false
|
13
|
+
prop :size, type: Playbook::Props::Enum,
|
14
|
+
values: %w[xs sm md lg xl none],
|
15
|
+
default: "none"
|
11
16
|
prop :url
|
12
17
|
|
13
18
|
def classname
|
14
|
-
generate_classname("pb_image_kit lazyload blur_up")
|
19
|
+
generate_classname("pb_image_kit lazyload blur_up", size_class) + rounded_class
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def rounded_class
|
25
|
+
rounded ? " rounded" : ""
|
26
|
+
end
|
27
|
+
|
28
|
+
def size_class
|
29
|
+
size == "none" ? nil : size
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
@@ -17,7 +17,9 @@ type ListProps = {
|
|
17
17
|
ordered: boolean,
|
18
18
|
role?: string,
|
19
19
|
tabIndex?: string,
|
20
|
+
text?: string,
|
20
21
|
size?: string,
|
22
|
+
variant?: string,
|
21
23
|
xpadding: boolean,
|
22
24
|
}
|
23
25
|
|
@@ -36,6 +38,8 @@ const List = (props: ListProps) => {
|
|
36
38
|
size = '',
|
37
39
|
tabIndex,
|
38
40
|
xpadding = false,
|
41
|
+
variant,
|
42
|
+
text,
|
39
43
|
} = props
|
40
44
|
|
41
45
|
const layoutClass = {
|
@@ -44,6 +48,9 @@ const List = (props: ListProps) => {
|
|
44
48
|
default: '',
|
45
49
|
}
|
46
50
|
|
51
|
+
const childrenWithProps = React.Children.map(children, (child) => {
|
52
|
+
return React.cloneElement(child, { text, variant })
|
53
|
+
})
|
47
54
|
const ariaProps = buildAriaProps(aria)
|
48
55
|
const dataProps = buildDataProps(data)
|
49
56
|
const classes = classnames(
|
@@ -70,7 +77,7 @@ const List = (props: ListProps) => {
|
|
70
77
|
role={role}
|
71
78
|
tabIndex={tabIndex}
|
72
79
|
>
|
73
|
-
{
|
80
|
+
{childrenWithProps}
|
74
81
|
</ol>
|
75
82
|
<Else />
|
76
83
|
<ul
|
@@ -81,7 +88,7 @@ const List = (props: ListProps) => {
|
|
81
88
|
role={role}
|
82
89
|
tabIndex={tabIndex}
|
83
90
|
>
|
84
|
-
{
|
91
|
+
{childrenWithProps}
|
85
92
|
</ul>
|
86
93
|
</If>
|
87
94
|
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="pb--doc-demo-row">
|
2
|
+
|
3
|
+
<%= pb_rails("selectable_card", props: {
|
4
|
+
input_id: "selectable-image-default",
|
5
|
+
name: "selectable-image-default",
|
6
|
+
value: "selectable-image-default",
|
7
|
+
checked: true,
|
8
|
+
icon: true
|
9
|
+
}) do %>
|
10
|
+
<%= pb_rails("image", props: { rounded: true, size: "xl",url: "https://unsplash.it/500/400/?image=634" }) %>
|
11
|
+
<%= pb_rails("body", props: { tag: "span"}) do %>
|
12
|
+
Add text here
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= pb_rails("selectable_card", props: {
|
18
|
+
input_id: "selectable-image-xl",
|
19
|
+
name: "selectable-image-xl",
|
20
|
+
value: "selectable-image-xl",
|
21
|
+
checked: false,
|
22
|
+
icon: true
|
23
|
+
}) do %>
|
24
|
+
<%= pb_rails("image", props: { rounded: true, size: "xl", url: "https://unsplash.it/500/400/?image=634" }) %>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
</div>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import {
|
3
|
+
Body,
|
4
|
+
Image,
|
5
|
+
SelectableCard,
|
6
|
+
} from '../../'
|
7
|
+
|
8
|
+
class SelectableCardImage extends React.Component {
|
9
|
+
state = {
|
10
|
+
selectableImage: true,
|
11
|
+
unselectedImage: false,
|
12
|
+
}
|
13
|
+
|
14
|
+
handleSelect = (event) => {
|
15
|
+
this.setState({
|
16
|
+
[event.target.id]: event.target.checked,
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
20
|
+
render() {
|
21
|
+
return (
|
22
|
+
<div className="pb--doc-demo-row">
|
23
|
+
|
24
|
+
<SelectableCard
|
25
|
+
checked={this.state.selectableImage}
|
26
|
+
icon
|
27
|
+
inputId="selectableImage"
|
28
|
+
name="selectableImage"
|
29
|
+
onChange={this.handleSelect}
|
30
|
+
value="selectableImage"
|
31
|
+
>
|
32
|
+
<Image
|
33
|
+
rounded
|
34
|
+
size="xl"
|
35
|
+
url="https://unsplash.it/500/400/?image=634"
|
36
|
+
/>
|
37
|
+
|
38
|
+
<Body>{'Add text here'}</Body>
|
39
|
+
</SelectableCard>
|
40
|
+
|
41
|
+
<SelectableCard
|
42
|
+
checked={this.state.unselectedImage}
|
43
|
+
icon
|
44
|
+
inputId="unselectedImage"
|
45
|
+
name="unselectedImage"
|
46
|
+
onChange={this.handleSelect}
|
47
|
+
value="unselectedImage"
|
48
|
+
>
|
49
|
+
<Image
|
50
|
+
rounded
|
51
|
+
size="xl"
|
52
|
+
url="https://unsplash.it/500/400/?image=634"
|
53
|
+
/>
|
54
|
+
</SelectableCard>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
export default SelectableCardImage
|
@@ -0,0 +1 @@
|
|
1
|
+
Selectable Cards can pass images with optional text.
|
@@ -5,9 +5,11 @@ examples:
|
|
5
5
|
- selectable_card_single_select: Single Select
|
6
6
|
- selectable_card_block: Block
|
7
7
|
- selectable_card_options: With Options
|
8
|
+
- selectable_card_image: Image Example
|
8
9
|
|
9
10
|
|
10
11
|
react:
|
11
12
|
- selectable_card_default: Default
|
12
13
|
- selectable_card_single_select: Single Select
|
13
14
|
- selectable_card_block: Block
|
15
|
+
- selectable_card_image: Image Example
|
@@ -1,3 +1,4 @@
|
|
1
1
|
export { default as SelectableCardDefault } from './_selectable_card_default.jsx'
|
2
2
|
export { default as SelectableCardSingleSelect } from './_selectable_card_single_select.jsx'
|
3
3
|
export { default as SelectableCardBlock } from './_selectable_card_block.jsx'
|
4
|
+
export { default as SelectableCardImage } from './_selectable_card_image.jsx'
|
@@ -0,0 +1,90 @@
|
|
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 = 'checkbox',
|
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
|
+
>
|
55
|
+
<Choose>
|
56
|
+
<When condition={variant == 'checkbox'}>
|
57
|
+
<Checkbox
|
58
|
+
checked={checked}
|
59
|
+
id={id}
|
60
|
+
name={name}
|
61
|
+
onChange={onChange}
|
62
|
+
// eslint suppressor, text is needed to display on screen
|
63
|
+
text={label || (text && false)}
|
64
|
+
type="checkbox"
|
65
|
+
value={value}
|
66
|
+
{...props}
|
67
|
+
/>
|
68
|
+
{children}
|
69
|
+
</When>
|
70
|
+
<When condition={variant == 'radio'}>
|
71
|
+
<Radio
|
72
|
+
defaultChecked={defaultChecked}
|
73
|
+
id={id}
|
74
|
+
label={label}
|
75
|
+
name={name}
|
76
|
+
onChange={onChange}
|
77
|
+
type="radio"
|
78
|
+
value={value}
|
79
|
+
{...props}
|
80
|
+
/>
|
81
|
+
{children}
|
82
|
+
</When>
|
83
|
+
<Otherwise>{children}</Otherwise>
|
84
|
+
</Choose>
|
85
|
+
</div>
|
86
|
+
</ListItem>
|
87
|
+
)
|
88
|
+
}
|
89
|
+
|
90
|
+
export default SelectableListItem
|
@@ -0,0 +1,11 @@
|
|
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 %>
|
@@ -0,0 +1,47 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
+
}
|
@@ -0,0 +1,18 @@
|
|
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, input_options: object.input_options } ) %>
|
9
|
+
<% if object.children.present? %>
|
10
|
+
<%= capture(&object.children) %>
|
11
|
+
<% end %>
|
12
|
+
<% else %>
|
13
|
+
<%= pb_rails("checkbox", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
|
14
|
+
<% if object.children.present? %>
|
15
|
+
<%= capture(&object.children) %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= pb_rails("selectable_list",
|
2
|
+
props: {
|
3
|
+
variant: "checkbox",
|
4
|
+
items: [
|
5
|
+
{ text: "Mild",
|
6
|
+
input_options: {
|
7
|
+
value: "1",
|
8
|
+
name: "checkbox-name-1",
|
9
|
+
}
|
10
|
+
},
|
11
|
+
{ text: "Medium",
|
12
|
+
checked: true,
|
13
|
+
input_options: {
|
14
|
+
value: "2",
|
15
|
+
name: "checkbox-name-2",
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{ text: "Hot",
|
19
|
+
input_options: {
|
20
|
+
value: "3",
|
21
|
+
name: "checkbox-name-3",
|
22
|
+
}
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
26
|
+
)
|
27
|
+
%>
|
@@ -0,0 +1,29 @@
|
|
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="Mild"
|
10
|
+
name="checkbox-name-1"
|
11
|
+
value="1"
|
12
|
+
/>
|
13
|
+
<SelectableList.Item
|
14
|
+
checked
|
15
|
+
label="Medium"
|
16
|
+
name="checkbox-name-2"
|
17
|
+
value="2"
|
18
|
+
/>
|
19
|
+
<SelectableList.Item
|
20
|
+
label="Hot"
|
21
|
+
name="checkbox-name-3"
|
22
|
+
value="3"
|
23
|
+
/>
|
24
|
+
</SelectableList>
|
25
|
+
</div>
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
export default SelectableListDefault
|