playbook_ui 12.38.0.pre.alpha.playbook123801077 → 12.39.0.pre.alpha.PLAY966collapsiblenav41115
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +6 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -3
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +10 -9
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_color.jsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +4 -8
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.jsx +5 -5
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +75 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.md +3 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +7 -6
- data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +274 -17
- data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +7 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +232 -132
- data/app/pb_kits/playbook/pb_nav/_mixins.scss +14 -0
- data/app/pb_kits/playbook/pb_nav/_nav.tsx +17 -1
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +6 -7
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +85 -58
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +58 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +23 -0
- data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_custom_icons.jsx → _collapsible_nav_emphasize.jsx} +14 -5
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +5 -3
- data/app/pb_kits/playbook/pb_nav/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +20 -4
- data/app/pb_kits/playbook/pb_nav/item.rb +89 -3
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +3 -1
- data/app/pb_kits/playbook/pb_nav/nav.rb +13 -0
- data/app/pb_kits/playbook/pb_nav/navTypes.ts +25 -0
- data/app/pb_kits/playbook/pb_select/_select.scss +76 -0
- data/app/pb_kits/playbook/pb_select/_select.tsx +9 -5
- data/app/pb_kits/playbook/pb_select/docs/_select_attributes.html.erb +26 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_attributes.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.html.erb +36 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.jsx +50 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -9
- data/app/pb_kits/playbook/pb_select/select.rb +14 -0
- data/app/pb_kits/playbook/pb_select/select.test.js +17 -0
- data/dist/playbook-rails.js +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +17 -3
@@ -0,0 +1,58 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { Nav, NavItem, useCollapsible } from "../.."
|
3
|
+
|
4
|
+
const CollapsibleNavCustom = (props) => {
|
5
|
+
const navItems = ["Overview", "Albums", "Similar Artists"]
|
6
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
7
|
+
const collapsibles = navItems.map(() => useCollapsible(true))
|
8
|
+
|
9
|
+
const handleMainClick = (index) => {
|
10
|
+
collapsibles.forEach(([, , setCollapsed], idx) => {
|
11
|
+
if (idx === index) {
|
12
|
+
setCollapsed(false)
|
13
|
+
} else {
|
14
|
+
setCollapsed(true)
|
15
|
+
}
|
16
|
+
})
|
17
|
+
}
|
18
|
+
|
19
|
+
return (
|
20
|
+
<>
|
21
|
+
<Nav variant='subtle'>
|
22
|
+
{navItems.map((text, index) => {
|
23
|
+
const [collapsed] = collapsibles[index]
|
24
|
+
return (
|
25
|
+
<NavItem
|
26
|
+
collapsed={collapsed}
|
27
|
+
collapsible
|
28
|
+
collapsibleTrail
|
29
|
+
fontWeight="bolder"
|
30
|
+
iconLeft="chevron-down"
|
31
|
+
id={`collapsible-nav-item-${index + 1}`}
|
32
|
+
key={index}
|
33
|
+
link="#"
|
34
|
+
onClick={() => handleMainClick(index)}
|
35
|
+
text={text}
|
36
|
+
{...props}
|
37
|
+
>
|
38
|
+
<NavItem link="#"
|
39
|
+
text="City"
|
40
|
+
{...props}
|
41
|
+
/>
|
42
|
+
<NavItem link="#"
|
43
|
+
text="People"
|
44
|
+
{...props}
|
45
|
+
/>
|
46
|
+
<NavItem link="#"
|
47
|
+
text="Business"
|
48
|
+
{...props}
|
49
|
+
/>
|
50
|
+
</NavItem>
|
51
|
+
);
|
52
|
+
})}
|
53
|
+
</Nav>
|
54
|
+
</>
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export default CollapsibleNavCustom
|
@@ -0,0 +1 @@
|
|
1
|
+
The collapsible nav kit uses our Collapsible kit under the hood and as such the `useCollapsible` hook can be used to achieve custom toggling of the collapsible nav. To do this, you must import and declare the `useCollapsible` hook and pass it's state to the `collapsed` prop. See our code example below to see how this can be done.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= pb_rails("nav", props: { variant: "subtle" }) do %>
|
2
|
+
<%= pb_rails("nav/item", props: { text: "Overview", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left:"city", collapsible_trail: true }) do %>
|
3
|
+
<%= pb_rails("nav", props: { variant: "subtle" }) do %>
|
4
|
+
<%= pb_rails("nav/item", props: { text: "City", link: "#" }) %>
|
5
|
+
<%= pb_rails("nav/item", props: { text: "People", link: "#" }) %>
|
6
|
+
<%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<%= pb_rails("nav/item", props: { text: "Albums", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left: "theater-masks", collapsible_trail:true }) do %>
|
10
|
+
<%= pb_rails("nav", props: { variant: "subtle" }) do %>
|
11
|
+
<%= pb_rails("nav/item", props: { text: "Entertainment", link: "#" }) %>
|
12
|
+
<%= pb_rails("nav/item", props: { text: "Food", link: "#" }) %>
|
13
|
+
<%= pb_rails("nav/item", props: { text: "Style", link: "#" }) %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left: "city", collapsible_trail:true }) do %>
|
17
|
+
<%= pb_rails("nav", props: { variant: "subtle" }) do %>
|
18
|
+
<%= pb_rails("nav/item", props: { text: "City", link: "#" }) %>
|
19
|
+
<%= pb_rails("nav/item", props: { text: "People", link: "#" }) %>
|
20
|
+
<%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
@@ -1,11 +1,15 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Nav, NavItem } from '../..'
|
3
3
|
|
4
|
-
const
|
4
|
+
const CollapsibleNavEmphasize = (props) => {
|
5
5
|
return (
|
6
|
-
<Nav variant="
|
6
|
+
<Nav variant="bold">
|
7
7
|
<NavItem
|
8
|
-
|
8
|
+
active
|
9
|
+
collapsible
|
10
|
+
collapsibleTrail
|
11
|
+
fontSize="small"
|
12
|
+
fontWeight="bolder"
|
9
13
|
iconLeft="city"
|
10
14
|
iconRight={["plus", "minus"]}
|
11
15
|
link="#"
|
@@ -29,8 +33,10 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
29
33
|
/>
|
30
34
|
</NavItem>
|
31
35
|
<NavItem
|
32
|
-
active
|
33
36
|
collapsible
|
37
|
+
collapsibleTrail
|
38
|
+
fontSize="small"
|
39
|
+
fontWeight="bolder"
|
34
40
|
iconLeft="theater-masks"
|
35
41
|
iconRight={["plus", "minus"]}
|
36
42
|
link="#"
|
@@ -55,6 +61,9 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
55
61
|
</NavItem>
|
56
62
|
<NavItem
|
57
63
|
collapsible
|
64
|
+
collapsibleTrail
|
65
|
+
fontSize="small"
|
66
|
+
fontWeight="bolder"
|
58
67
|
iconLeft="city"
|
59
68
|
iconRight={["plus", "minus"]}
|
60
69
|
link="#"
|
@@ -81,4 +90,4 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
81
90
|
);
|
82
91
|
};
|
83
92
|
|
84
|
-
export default
|
93
|
+
export default CollapsibleNavEmphasize;
|
@@ -0,0 +1 @@
|
|
1
|
+
The ` navBold` prop can be passed to NavItem
|
@@ -7,7 +7,8 @@ examples:
|
|
7
7
|
- borderless_nav: No Borders
|
8
8
|
- subtle_nav: Subtle Variant
|
9
9
|
- subtle_with_icons_nav: Subtle With Icons
|
10
|
-
|
10
|
+
- collapsible_nav: Collapsible Nav
|
11
|
+
- collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
|
11
12
|
- subtle_no_highlight_nav: Subtle No Highlight
|
12
13
|
- bold_vertical_nav: Bold Variant
|
13
14
|
- horizontal_nav: Horizontal Nav
|
@@ -25,8 +26,9 @@ examples:
|
|
25
26
|
- borderless_nav: No Borders
|
26
27
|
- subtle_nav: Subtle Variant
|
27
28
|
- subtle_with_icons_nav: Subtle With Icons
|
28
|
-
|
29
|
-
|
29
|
+
- collapsible_nav: Collapsible Nav
|
30
|
+
- collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
|
31
|
+
- collapsible_nav_custom: Collapsible Nav With Custom Toggling
|
30
32
|
- subtle_no_highlight_nav: Subtle No Highlight
|
31
33
|
- bold_vertical_nav: Bold Variant
|
32
34
|
- horizontal_nav: Horizontal Nav
|
@@ -14,4 +14,5 @@ export { default as NewTab } from './_new_tab.jsx'
|
|
14
14
|
export { default as BoldHorizontalNav } from './_bold_horizontal_nav.jsx'
|
15
15
|
export { default as BoldVerticalNav } from './_bold_vertical_nav.jsx'
|
16
16
|
export { default as CollapsibleNav } from './_collapsible_nav.jsx'
|
17
|
-
export { default as
|
17
|
+
export { default as CollapsibleNavCustom } from './_collapsible_nav_custom.jsx'
|
18
|
+
export { default as CollapsibleNavEmphasize } from "./_collapsible_nav_emphasize.jsx"
|
@@ -2,19 +2,20 @@
|
|
2
2
|
aria: object.aria,
|
3
3
|
class: object.classname,
|
4
4
|
data: object.data,
|
5
|
+
dark: object.dark,
|
5
6
|
id: object.id) do %>
|
6
7
|
<% if object.collapsible %>
|
7
8
|
<%= pb_rails("collapsible", props: { name: "collapsible-nav-example" }) do %>
|
8
|
-
<%= pb_rails("collapsible/collapsible_main", props: { name: "default-collapsible-nav", icon: object.collapsible_icons, size: "xs" }) do %>
|
9
|
+
<%= pb_rails("collapsible/collapsible_main", props: { name: "default-collapsible-nav", icon: object.collapsible_icons, size: "xs", dark: object.dark }) do %>
|
9
10
|
<%= content_tag(object.tag,
|
10
11
|
object.link ? object.link_options : object.options) do %>
|
11
12
|
<% if object.image_url %>
|
12
|
-
<%= pb_rails("image", props: { url: object.image_url, classname: "
|
13
|
+
<%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper_collapsible" }) %>
|
13
14
|
<% end %>
|
14
15
|
<% if object.icon_left %>
|
15
|
-
<%= pb_rails("icon", props: { icon: object.icon_left, classname: "
|
16
|
+
<%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left_collapsible", fixed_width: true}) %>
|
16
17
|
<% end %>
|
17
|
-
<span class="
|
18
|
+
<span class="pb_nav_list_item_text_collapsible">
|
18
19
|
<%= object.text %>
|
19
20
|
</span>
|
20
21
|
<% end %>
|
@@ -41,3 +42,18 @@
|
|
41
42
|
<% end %>
|
42
43
|
<% end %>
|
43
44
|
<% end %>
|
45
|
+
|
46
|
+
<script>
|
47
|
+
document.addEventListener("DOMContentLoaded", function() {
|
48
|
+
var liElements = document.querySelectorAll('li');
|
49
|
+
|
50
|
+
liElements.forEach(function(liElement) {
|
51
|
+
var orientation = liElement.getAttribute('data-orientation');
|
52
|
+
var variant = liElement.getAttribute('data-variant');
|
53
|
+
if (orientation === "horizontal" && variant === "normal") {
|
54
|
+
liElement.classList.remove('font_regular')
|
55
|
+
liElement.classList.add('font_bold')
|
56
|
+
}
|
57
|
+
})
|
58
|
+
})
|
59
|
+
</script>
|
@@ -4,9 +4,16 @@ module Playbook
|
|
4
4
|
module PbNav
|
5
5
|
class Item < Playbook::KitBase
|
6
6
|
prop :active, type: Playbook::Props::Boolean, default: false
|
7
|
+
prop :font_size, type: Playbook::Props::Enum,
|
8
|
+
values: %w[normal small],
|
9
|
+
default: "normal"
|
10
|
+
prop :font_weight, type: Playbook::Props::Enum,
|
11
|
+
values: %w[bold regular bolder],
|
12
|
+
default: "regular"
|
7
13
|
prop :collapsible, type: Playbook::Props::Boolean, default: false
|
8
14
|
prop :link
|
9
15
|
prop :text
|
16
|
+
prop :collapsible_trail, type: Playbook::Props::Boolean, default: false
|
10
17
|
prop :icon_left
|
11
18
|
prop :icon_right
|
12
19
|
prop :image_url
|
@@ -15,9 +22,41 @@ module Playbook
|
|
15
22
|
default: "_self"
|
16
23
|
def classname
|
17
24
|
if collapsible
|
18
|
-
"
|
25
|
+
"#{generate_classname('pb_nav_list_kit_item', active_class)} #{generate_classname('pb_collapsible_nav_item', active_class, collapsible_trail_class)} #{font_size_class} #{font_weight_class}"
|
19
26
|
else
|
20
|
-
generate_classname(
|
27
|
+
"#{generate_classname('pb_nav_list_kit_item', active_class)} #{font_size_class} #{font_weight_class}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def spacing_props
|
32
|
+
if object.padding || object.padding_x || object.padding_y || object.padding_bottom || object.padding_top || object.padding_right || object.padding_left || object.margin || object.margin_x || object.margin_y || object.margin_bottom || object.margin_top || object.margin_right || object.margin_left
|
33
|
+
# Call the original method
|
34
|
+
original_result = super
|
35
|
+
|
36
|
+
# Remove p_value, px_value, py_value, etc. based on the object's properties
|
37
|
+
padding_classes_to_remove = []
|
38
|
+
padding_classes_to_remove << "p_#{object.padding}" if object.padding
|
39
|
+
padding_classes_to_remove << "px_#{object.padding_x}" if object.padding_x
|
40
|
+
padding_classes_to_remove << "py_#{object.padding_y}" if object.padding_y
|
41
|
+
padding_classes_to_remove << "pb_#{object.padding_bottom}" if object.padding_bottom
|
42
|
+
padding_classes_to_remove << "pt_#{object.padding_top}" if object.padding_top
|
43
|
+
padding_classes_to_remove << "pr_#{object.padding_right}" if object.padding_right
|
44
|
+
padding_classes_to_remove << "pl_#{object.padding_left}" if object.padding_left
|
45
|
+
padding_classes_to_remove << "m_#{object.margin}" if object.margin
|
46
|
+
padding_classes_to_remove << "mx_#{object.margin_x}" if object.margin_x
|
47
|
+
padding_classes_to_remove << "my_#{object.margin_y}" if object.margin_y
|
48
|
+
padding_classes_to_remove << "mb_#{object.margin_bottom}" if object.margin_bottom
|
49
|
+
padding_classes_to_remove << "mt_#{object.margin_top}" if object.margin_top
|
50
|
+
padding_classes_to_remove << "mr_#{object.margin_right}" if object.margin_right
|
51
|
+
padding_classes_to_remove << "ml_#{object.margin_left}" if object.margin_left
|
52
|
+
|
53
|
+
padding_classes_to_remove.each do |class_to_remove|
|
54
|
+
original_result.gsub!(class_to_remove, "")
|
55
|
+
end
|
56
|
+
|
57
|
+
original_result.strip
|
58
|
+
else
|
59
|
+
super
|
21
60
|
end
|
22
61
|
end
|
23
62
|
|
@@ -27,7 +66,7 @@ module Playbook
|
|
27
66
|
|
28
67
|
def options
|
29
68
|
{
|
30
|
-
class: "pb_nav_list_item_link",
|
69
|
+
class: collapsible ? "pb_nav_list_item_link_collapsible #{padding_classes}" : "pb_nav_list_item_link #{padding_classes}",
|
31
70
|
}.compact
|
32
71
|
end
|
33
72
|
|
@@ -47,6 +86,53 @@ module Playbook
|
|
47
86
|
def active_class
|
48
87
|
active ? "active" : nil
|
49
88
|
end
|
89
|
+
|
90
|
+
def font_weight_class
|
91
|
+
case font_weight
|
92
|
+
when "bold"
|
93
|
+
"font_bold"
|
94
|
+
when "bolder"
|
95
|
+
"font_bolder"
|
96
|
+
else
|
97
|
+
"font_regular"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def collapsible_trail_class
|
102
|
+
collapsible_trail ? "collapsible_trail" : nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def font_size_class
|
106
|
+
font_size === "small" ? "font_size_small" : "font_size_normal"
|
107
|
+
end
|
108
|
+
|
109
|
+
def padding_classes
|
110
|
+
spacing_attributes = {
|
111
|
+
padding: "p",
|
112
|
+
padding_x: "px",
|
113
|
+
padding_y: "py",
|
114
|
+
padding_bottom: "pb",
|
115
|
+
padding_top: "pt",
|
116
|
+
padding_right: "pr",
|
117
|
+
padding_left: "pl",
|
118
|
+
margin: "m",
|
119
|
+
margin_x: "mx",
|
120
|
+
margin_y: "my",
|
121
|
+
margin_bottom: "mb",
|
122
|
+
margin_top: "mt",
|
123
|
+
margin_right: "mr",
|
124
|
+
margin_left: "ml",
|
125
|
+
}
|
126
|
+
|
127
|
+
# rubocop:disable Style/RedundantAssignment
|
128
|
+
padding_classes = spacing_attributes.map do |attr, class_prefix|
|
129
|
+
# rubocop:enable Style/RedundantAssignment
|
130
|
+
value = object.public_send(attr)
|
131
|
+
" #{class_prefix}_#{value}" if value
|
132
|
+
end.compact.join
|
133
|
+
|
134
|
+
padding_classes
|
135
|
+
end
|
50
136
|
end
|
51
137
|
end
|
52
138
|
end
|
@@ -13,6 +13,7 @@ module Playbook
|
|
13
13
|
default: "normal"
|
14
14
|
prop :highlight, type: Playbook::Props::Boolean, default: true
|
15
15
|
prop :borderless, type: Playbook::Props::Boolean, default: false
|
16
|
+
prop :item_padding, type: Playbook::Props::Hash, default: {}
|
16
17
|
|
17
18
|
def classname
|
18
19
|
generate_classname("pb_nav_list", variant, orientation, highlight_class, borderless_class)
|
@@ -25,6 +26,18 @@ module Playbook
|
|
25
26
|
def borderless_class
|
26
27
|
borderless ? "borderless" : nil
|
27
28
|
end
|
29
|
+
|
30
|
+
def modified_content
|
31
|
+
parsed_content = Nokogiri::HTML.fragment(content.presence)
|
32
|
+
|
33
|
+
parsed_content.css("li").each do |element|
|
34
|
+
element["data-orientation"] = orientation
|
35
|
+
element["data-variant"] = variant
|
36
|
+
element["data-spacing"] = item_padding
|
37
|
+
end
|
38
|
+
|
39
|
+
parsed_content.to_html
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Spacing } from "../types";
|
2
|
+
|
3
|
+
export type SpacingObject = {
|
4
|
+
padding?: Spacing;
|
5
|
+
paddingBottom?: Spacing;
|
6
|
+
paddingTop?: Spacing;
|
7
|
+
paddingRight?: Spacing;
|
8
|
+
paddingLeft?: Spacing;
|
9
|
+
paddingX?: Spacing;
|
10
|
+
paddingY?: Spacing;
|
11
|
+
margin?: Spacing;
|
12
|
+
marginBottom?: Spacing;
|
13
|
+
marginTop?: Spacing;
|
14
|
+
marginRight?: Spacing;
|
15
|
+
marginLeft?: Spacing;
|
16
|
+
margingX?: Spacing;
|
17
|
+
marginY?: Spacing;
|
18
|
+
};
|
19
|
+
|
20
|
+
export type NavChildProps = {
|
21
|
+
orientation?: "vertical" | "horizontal";
|
22
|
+
variant?: "normal" | "subtle";
|
23
|
+
itemSpacing?: SpacingObject
|
24
|
+
};
|
25
|
+
|
@@ -2,6 +2,7 @@
|
|
2
2
|
@import "../pb_textarea/textarea_mixin";
|
3
3
|
@import "../tokens/titles";
|
4
4
|
@import "../tokens/colors";
|
5
|
+
@import "../tokens/spacing";
|
5
6
|
|
6
7
|
[class^=pb_select] {
|
7
8
|
select {
|
@@ -32,6 +33,42 @@
|
|
32
33
|
opacity: 0.5;
|
33
34
|
}
|
34
35
|
}
|
36
|
+
select[multiple] {
|
37
|
+
@include pb_textarea_light;
|
38
|
+
@include pb_body_light;
|
39
|
+
background: none;
|
40
|
+
background-color: $white;
|
41
|
+
appearance: none;
|
42
|
+
cursor: pointer;
|
43
|
+
box-shadow: inset 0 -11px 20px rgba($primary, 0.05);
|
44
|
+
padding-right: 0px !important;
|
45
|
+
color: transparent !important;
|
46
|
+
text-shadow: 0 0 0 $text_lt_default;
|
47
|
+
white-space: nowrap;
|
48
|
+
text-overflow: ellipsis;
|
49
|
+
padding: $space_xs 0px !important;
|
50
|
+
max-height: unset !important;
|
51
|
+
@media (hover:hover) {
|
52
|
+
&:hover, &:active, &:focus {
|
53
|
+
background-color: rgba($focus_input_light, $opacity_5);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
&:focus{
|
57
|
+
border-color: $primary;
|
58
|
+
@include transition_default;
|
59
|
+
}
|
60
|
+
option {
|
61
|
+
padding-left: $space_sm;
|
62
|
+
padding-top: $space_xxs;
|
63
|
+
padding-bottom: $space_xxs;
|
64
|
+
}
|
65
|
+
option:checked {
|
66
|
+
background-color: $hover_light;
|
67
|
+
}
|
68
|
+
option:hover {
|
69
|
+
background-color: $hover_light;
|
70
|
+
}
|
71
|
+
}
|
35
72
|
option {
|
36
73
|
color: $text_lt_default;
|
37
74
|
}
|
@@ -115,6 +152,45 @@
|
|
115
152
|
}
|
116
153
|
}
|
117
154
|
}
|
155
|
+
select[multiple] {
|
156
|
+
@include pb_textarea_dark;
|
157
|
+
@include pb_body_light_dark;
|
158
|
+
background: none;
|
159
|
+
background-color: rgba($white,.10);
|
160
|
+
appearance: none;
|
161
|
+
cursor: pointer;
|
162
|
+
box-shadow: inset 0 -11px 20px rgba($white, 0.05);
|
163
|
+
padding-right: 0px !important;
|
164
|
+
color: transparent !important;
|
165
|
+
text-shadow: 0 0 0 $text_dk_default;
|
166
|
+
white-space: nowrap;
|
167
|
+
text-overflow: ellipsis;
|
168
|
+
padding: $space_xs 0px !important;
|
169
|
+
max-height: unset !important;
|
170
|
+
@media (hover:hover) {
|
171
|
+
&:hover, &:active, &:focus {
|
172
|
+
background-color: rgba($white,.05);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
&:focus{
|
176
|
+
border-color: $primary;
|
177
|
+
@include transition_default;
|
178
|
+
}
|
179
|
+
option {
|
180
|
+
padding-left: $space_sm;
|
181
|
+
padding-top: $space_xxs;
|
182
|
+
padding-bottom: $space_xxs;
|
183
|
+
}
|
184
|
+
option:checked {
|
185
|
+
background-color: $hover_dark;
|
186
|
+
}
|
187
|
+
option:hover {
|
188
|
+
background-color: $hover_dark;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
option {
|
192
|
+
color: $text_dk_default;
|
193
|
+
}
|
118
194
|
.pb_select_kit_caret {
|
119
195
|
color: $white;
|
120
196
|
}
|
@@ -124,11 +124,15 @@ const Select = ({
|
|
124
124
|
htmlFor={name}
|
125
125
|
>
|
126
126
|
{selectBody}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
{ multiple !== true ?
|
128
|
+
<Icon
|
129
|
+
className="pb_select_kit_caret"
|
130
|
+
fixedWidth
|
131
|
+
icon="angle-down"
|
132
|
+
/>
|
133
|
+
:
|
134
|
+
null
|
135
|
+
}
|
132
136
|
{error &&
|
133
137
|
<Body
|
134
138
|
status="negative"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= pb_rails("select", props: {
|
2
|
+
attributes: {
|
3
|
+
data: { options: "data_attribute" },
|
4
|
+
},
|
5
|
+
label: "Favorite Food",
|
6
|
+
name: "food",
|
7
|
+
options: [
|
8
|
+
{
|
9
|
+
value: "1",
|
10
|
+
value_text: "Burgers",
|
11
|
+
},
|
12
|
+
{
|
13
|
+
value: "2",
|
14
|
+
selected: true,
|
15
|
+
value_text: "Pizza",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
value: "3",
|
19
|
+
value_text: "Tacos",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
value: "4",
|
23
|
+
value_text: "BBQ",
|
24
|
+
},
|
25
|
+
]
|
26
|
+
}) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Inspect the element and notice the data-attribute being added to the `<select>` element
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%= pb_rails("select", props: {
|
2
|
+
label: "Favorite Food",
|
3
|
+
name: "food",
|
4
|
+
multiple: true,
|
5
|
+
options: [
|
6
|
+
{
|
7
|
+
value: "1",
|
8
|
+
value_text: "Burgers",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
value: "2",
|
12
|
+
selected: true,
|
13
|
+
value_text: "Pizza",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
value: "3",
|
17
|
+
value_text: "Tacos",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
value: "4",
|
21
|
+
value_text: "BBQ",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
value: "4",
|
25
|
+
value_text: "Sushi",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
value: "4",
|
29
|
+
value_text: "Chinese",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
value: "4",
|
33
|
+
value_text: "Hot Dogs",
|
34
|
+
},
|
35
|
+
]
|
36
|
+
}) %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Select from '../_select'
|
4
|
+
|
5
|
+
const SelectMultiple = (props) => {
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
value: '1',
|
9
|
+
text: 'Burgers',
|
10
|
+
},
|
11
|
+
{
|
12
|
+
value: '2',
|
13
|
+
text: 'Pizza',
|
14
|
+
},
|
15
|
+
{
|
16
|
+
value: '3',
|
17
|
+
text: 'Tacos',
|
18
|
+
},
|
19
|
+
{
|
20
|
+
value: '3',
|
21
|
+
text: 'BBQ',
|
22
|
+
},
|
23
|
+
{
|
24
|
+
value: '3',
|
25
|
+
text: 'Sushi',
|
26
|
+
},
|
27
|
+
{
|
28
|
+
value: '3',
|
29
|
+
text: 'Chinese',
|
30
|
+
},
|
31
|
+
{
|
32
|
+
value: '3',
|
33
|
+
text: 'Hot Dogs',
|
34
|
+
},
|
35
|
+
]
|
36
|
+
|
37
|
+
return (
|
38
|
+
<div>
|
39
|
+
<Select
|
40
|
+
label="Favorite Food"
|
41
|
+
multiple
|
42
|
+
name="food"
|
43
|
+
options={options}
|
44
|
+
{...props}
|
45
|
+
/>
|
46
|
+
</div>
|
47
|
+
)
|
48
|
+
}
|
49
|
+
|
50
|
+
export default SelectMultiple
|
@@ -0,0 +1 @@
|
|
1
|
+
We recommend using a typeahead for better UX
|
@@ -11,6 +11,8 @@ examples:
|
|
11
11
|
- select_error: Select w/ Error
|
12
12
|
- select_inline: Select Inline
|
13
13
|
- select_inline_compact: Select Inline Compact
|
14
|
+
- select_attributes: Select W/ Attributes
|
15
|
+
- select_multiple: Select Multiple
|
14
16
|
|
15
17
|
|
16
18
|
|
@@ -25,3 +27,4 @@ examples:
|
|
25
27
|
- select_error: Select w/ Error
|
26
28
|
- select_inline: Select Inline
|
27
29
|
- select_inline_compact: Select Inline Compact
|
30
|
+
- select_multiple: Select Multiple
|
@@ -8,3 +8,4 @@ export { default as SelectValueTextSame } from './_select_value_text_same.jsx'
|
|
8
8
|
export { default as SelectError } from './_select_error.jsx'
|
9
9
|
export { default as SelectInline } from './_select_inline.jsx'
|
10
10
|
export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
11
|
+
export { default as SelectMultiple } from './_select_multiple.jsx'
|