playbook_ui 12.37.0.pre.alpha.PLAY951collapsiblenav31062 → 12.37.0.pre.alpha.svgiconmethods1064
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 +0 -6
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -3
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +9 -10
- 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 +8 -4
- 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/example.yml +6 -7
- data/app/pb_kits/playbook/pb_collapsible/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_icon/docs/_icon_animate.html.erb +1 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +2 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_svg.html.erb +5 -0
- data/app/pb_kits/playbook/pb_icon/docs/example.yml +10 -9
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +3 -3
- data/app/pb_kits/playbook/pb_icon/icon.rb +19 -0
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +16 -141
- data/app/pb_kits/playbook/pb_nav/_item.tsx +22 -33
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +6 -6
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +58 -79
- data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_emphasize.jsx → _collapsible_nav_custom_icons.jsx} +3 -5
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +3 -5
- data/app/pb_kits/playbook/pb_nav/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_nav/item.html.erb +4 -5
- data/app/pb_kits/playbook/pb_nav/item.rb +2 -17
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -10
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +0 -75
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.md +0 -3
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +0 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +0 -57
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.md +0 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +0 -23
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14c36bf2dc83555d191d529d857f9be98bed92ff0165962b37676c269dee8c44
|
4
|
+
data.tar.gz: 36997b2084a332b87ef58515b6a3263e633c2e9f873bb754ad71282a2babef31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96695e4ab6365e311252d3b7b02971bbcb418b1bae241f7d23cdeef069d469ccf01db4739ae41c8f1b3db91b939d1851f0be4301e789988add39902acc538c64
|
7
|
+
data.tar.gz: 1b88816484853815d500c9629c80e36970d7c238be5b017d88ed2f761e81525b4073e0c55135dfbfeacc385fc653fdb593eb7f9ff70ad17d44edfc09a1be1ff2
|
@@ -20,7 +20,7 @@ type CollapsibleProps = {
|
|
20
20
|
icon?: string | string[],
|
21
21
|
iconColor?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
|
22
22
|
iconSize?: IconSizes,
|
23
|
-
|
23
|
+
iconClick?: ()=> void,
|
24
24
|
onClick?: ()=> void,
|
25
25
|
id?: string,
|
26
26
|
}
|
@@ -36,7 +36,7 @@ const Collapsible = ({
|
|
36
36
|
icon,
|
37
37
|
iconColor = 'default',
|
38
38
|
iconSize,
|
39
|
-
|
39
|
+
iconClick,
|
40
40
|
onClick,
|
41
41
|
id,
|
42
42
|
...props
|
@@ -66,7 +66,7 @@ const Collapsible = ({
|
|
66
66
|
className
|
67
67
|
)
|
68
68
|
return (
|
69
|
-
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor,
|
69
|
+
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor, iconClick, onClick }}>
|
70
70
|
<div
|
71
71
|
{...ariaProps}
|
72
72
|
{...dataProps}
|
@@ -33,7 +33,6 @@ type CollapsibleMainProps = {
|
|
33
33
|
children: React.ReactNode[] | React.ReactNode,
|
34
34
|
className?: string,
|
35
35
|
cursor?: string,
|
36
|
-
dark?: boolean,
|
37
36
|
onClick?: ()=> void
|
38
37
|
}
|
39
38
|
type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success"
|
@@ -43,10 +42,10 @@ type IconProps = {
|
|
43
42
|
icon?: string[] | string
|
44
43
|
iconColor?: IconColors
|
45
44
|
iconSize?: IconSizes
|
46
|
-
|
45
|
+
iconClick?: ()=> void
|
47
46
|
}
|
48
47
|
|
49
|
-
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor,
|
48
|
+
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, iconClick }: IconProps) => {
|
50
49
|
const color = colorMap[iconColor]
|
51
50
|
|
52
51
|
const showIcon = (icon: string |string[]) => {
|
@@ -57,9 +56,9 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, onIconClick }: IconP
|
|
57
56
|
}
|
58
57
|
|
59
58
|
const handleIconClick = (e:any) => {
|
60
|
-
if (
|
59
|
+
if (iconClick) {
|
61
60
|
e.stopPropagation();
|
62
|
-
|
61
|
+
iconClick()
|
63
62
|
}
|
64
63
|
}
|
65
64
|
|
@@ -94,18 +93,18 @@ const CollapsibleMain = ({
|
|
94
93
|
cursor = 'pointer',
|
95
94
|
...props
|
96
95
|
}: CollapsibleMainProps): React.ReactElement=> {
|
97
|
-
const {collapsed, toggle, icon, iconSize, iconColor,
|
96
|
+
const {collapsed, toggle, icon, iconSize, iconColor, iconClick, onClick}: any = useContext(CollapsibleContext)
|
98
97
|
const mainCSS = buildCss('pb_collapsible_main_kit')
|
99
98
|
const mainSpacing = globalProps(props, { cursor })
|
100
99
|
|
101
|
-
const handleCollapsibleClick = () => {
|
100
|
+
const handleCollapsibleClick = (e:any) => {
|
102
101
|
toggle();
|
103
|
-
onClick && onClick()
|
102
|
+
onClick && onClick(e)
|
104
103
|
}
|
105
104
|
|
106
105
|
return (
|
107
106
|
<div className={classnames(mainCSS, className, mainSpacing)}>
|
108
|
-
<div onClick={handleCollapsibleClick}>
|
107
|
+
<div onClick={(e)=>handleCollapsibleClick(e)}>
|
109
108
|
<Flex
|
110
109
|
spacing="between"
|
111
110
|
vertical="center"
|
@@ -117,7 +116,7 @@ const CollapsibleMain = ({
|
|
117
116
|
iconColor={iconColor as IconColors}
|
118
117
|
iconSize={iconSize as IconSizes}
|
119
118
|
icon={icon as string[] | string}
|
120
|
-
|
119
|
+
iconClick={iconClick}
|
121
120
|
/>
|
122
121
|
</FlexItem>
|
123
122
|
</Flex>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleColor = (
|
4
|
+
const CollapsibleColor = () => (
|
5
5
|
<div>
|
6
6
|
<Collapsible
|
7
7
|
iconColor='default'
|
8
8
|
marginBottom="xs"
|
9
9
|
>
|
10
|
-
<Collapsible.Main
|
10
|
+
<Collapsible.Main>
|
11
11
|
<div>{'Default Section'}</div>
|
12
12
|
</Collapsible.Main>
|
13
13
|
<Collapsible.Content>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleDefault = (
|
4
|
+
const CollapsibleDefault = () => (
|
5
5
|
<Collapsible >
|
6
|
-
<Collapsible.Main
|
6
|
+
<Collapsible.Main>
|
7
7
|
<div>{'Main Section'}</div>
|
8
8
|
</Collapsible.Main>
|
9
9
|
<Collapsible.Content>
|
@@ -1,14 +1,18 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { Collapsible } from '../..'
|
2
|
+
import { Collapsible, useCollapsible, Button } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleIcons = (
|
4
|
+
const CollapsibleIcons = () => {
|
5
|
+
const [isCollapsed, setIsCollapsed] = useCollapsible(true)
|
5
6
|
|
6
7
|
return (
|
7
8
|
<>
|
8
|
-
<
|
9
|
+
<Button onClick={()=> setIsCollapsed(!isCollapsed)}>
|
10
|
+
{isCollapsed ? "Expand" : "Collapse"}
|
11
|
+
</Button>
|
12
|
+
<Collapsible collapsed={isCollapsed}
|
9
13
|
icon={['plus','minus']}
|
10
14
|
>
|
11
|
-
<Collapsible.Main
|
15
|
+
<Collapsible.Main>
|
12
16
|
<div>{'Main Section'}</div>
|
13
17
|
</Collapsible.Main>
|
14
18
|
<Collapsible.Content>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
##### Prop
|
2
|
-
|
2
|
+
This kit uses 'chevron-up' and 'chevron-down' icons as default for the toggle icons. To customize these icons, use the `icon` prop to pass in an array of two icons, the first will render when the collapisble is closed and the second will render when the collapsible is open. In this example, we are using `icon: ['plus','minus']`
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Collapsible } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleSize = (
|
4
|
+
const CollapsibleSize = () => (
|
5
5
|
<div>
|
6
6
|
<Collapsible
|
7
7
|
iconSize="xs"
|
8
8
|
marginBottom="xs"
|
9
9
|
>
|
10
|
-
<Collapsible.Main
|
10
|
+
<Collapsible.Main>
|
11
11
|
<div>{'Extra Small Section'}</div>
|
12
12
|
</Collapsible.Main>
|
13
13
|
<Collapsible.Content>
|
@@ -22,7 +22,7 @@ const CollapsibleSize = (props) => (
|
|
22
22
|
iconSize="sm"
|
23
23
|
marginBottom="xs"
|
24
24
|
>
|
25
|
-
<Collapsible.Main
|
25
|
+
<Collapsible.Main>
|
26
26
|
<div>{'Small Section'}</div>
|
27
27
|
</Collapsible.Main>
|
28
28
|
<Collapsible.Content>
|
@@ -36,7 +36,7 @@ const CollapsibleSize = (props) => (
|
|
36
36
|
<Collapsible
|
37
37
|
marginBottom="xs"
|
38
38
|
>
|
39
|
-
<Collapsible.Main
|
39
|
+
<Collapsible.Main>
|
40
40
|
<div>{'Default Section'}</div>
|
41
41
|
</Collapsible.Main>
|
42
42
|
<Collapsible.Content>
|
@@ -51,7 +51,7 @@ const CollapsibleSize = (props) => (
|
|
51
51
|
iconSize="lg"
|
52
52
|
marginBottom="xs"
|
53
53
|
>
|
54
|
-
<Collapsible.Main
|
54
|
+
<Collapsible.Main>
|
55
55
|
<div>{'Large Section'}</div>
|
56
56
|
</Collapsible.Main>
|
57
57
|
<Collapsible.Content>
|
@@ -2,13 +2,12 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- collapsible_default: Default
|
5
|
-
- collapsible_size:
|
6
|
-
- collapsible_color:
|
7
|
-
- collapsible_icons: Custom Icons
|
5
|
+
- collapsible_size: Size
|
6
|
+
- collapsible_color: Color
|
7
|
+
# - collapsible_icons: Custom Icons
|
8
8
|
|
9
9
|
react:
|
10
10
|
- collapsible_default: Default
|
11
|
-
- collapsible_size:
|
12
|
-
- collapsible_color:
|
13
|
-
- collapsible_icons: Custom Icons
|
14
|
-
- collapsible_state: useCollapsible Hook
|
11
|
+
- collapsible_size: Size
|
12
|
+
- collapsible_color: Color
|
13
|
+
# - collapsible_icons: Custom Icons
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export { default as CollapsibleDefault } from './_collapsible_default.jsx'
|
2
2
|
export { default as CollapsibleSize } from './_collapsible_size.jsx'
|
3
3
|
export { default as CollapsibleColor } from './_collapsible_color.jsx'
|
4
|
-
export { default as CollapsibleIcons } from './_collapsible_icons.jsx'
|
5
|
-
export {default as CollapsibleState } from './_collapsible_state.jsx'
|
4
|
+
export { default as CollapsibleIcons } from './_collapsible_icons.jsx'
|
@@ -1,14 +1,15 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
|
-
- icon_default: Icon Default
|
4
|
-
- icon_rotate: Icon Rotate
|
5
|
-
- icon_flip: Icon Flip
|
6
|
-
- icon_animate: Icon Animation
|
7
|
-
- icon_pull: Icon Pull
|
8
|
-
- icon_border: Icon Border
|
9
|
-
- icon_sizes: Icon Sizes
|
10
|
-
- icon_custom: Icon Custom
|
11
|
-
- icon_fa_kit: Icon with FontAwesome Kit
|
3
|
+
# - icon_default: Icon Default
|
4
|
+
# - icon_rotate: Icon Rotate
|
5
|
+
# - icon_flip: Icon Flip
|
6
|
+
# - icon_animate: Icon Animation
|
7
|
+
# - icon_pull: Icon Pull
|
8
|
+
# - icon_border: Icon Border
|
9
|
+
# - icon_sizes: Icon Sizes
|
10
|
+
# - icon_custom: Icon Custom
|
11
|
+
# - icon_fa_kit: Icon with FontAwesome Kit
|
12
|
+
- icon_svg: Icon SVG
|
12
13
|
|
13
14
|
react:
|
14
15
|
- icon_default: Icon Default
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<% if object.custom_icon %>
|
2
|
-
<%= object.
|
2
|
+
<%= object.embedded_svg(object.custom_icon) %>
|
3
3
|
<% elsif object.valid_emoji(object.icon) %>
|
4
4
|
<span class="pb_icon_kit_emoji"><%= object.icon.html_safe %></span>
|
5
5
|
<% else %>
|
6
6
|
<%= content_tag(:i, nil,
|
7
7
|
id: object.id,
|
8
8
|
data: object.data,
|
9
|
-
class: object.classname
|
9
|
+
class: object.classname,
|
10
10
|
) %>
|
11
11
|
<%= content_tag(:span, nil,
|
12
12
|
aria: { label: "#{object.icon} icon" }.merge(object.aria),
|
13
13
|
hidden: true
|
14
14
|
) %>
|
15
|
-
<% end %>
|
15
|
+
<% end %>
|
@@ -90,6 +90,25 @@ module Playbook
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
def embedded_svg(icon_name)
|
94
|
+
svg_path = Rails.application.config.respond_to?(:icon_path) ? Rails.application.config.icon_path : "app/assets/images"
|
95
|
+
file_path = File.read(Rails.root.join(svg_path, "#{icon_name}.svg"))
|
96
|
+
|
97
|
+
doc = Nokogiri::HTML::DocumentFragment.parse file_path
|
98
|
+
svg = doc.at_css "svg"
|
99
|
+
|
100
|
+
doc.to_html.html_safe
|
101
|
+
|
102
|
+
size_factor = size.to_i
|
103
|
+
if size_factor > 1
|
104
|
+
pixel_size = size_factor * 16
|
105
|
+
svg["width"] = pixel_size.to_s
|
106
|
+
svg["height"] = pixel_size.to_s
|
107
|
+
end
|
108
|
+
|
109
|
+
raw doc
|
110
|
+
end
|
111
|
+
|
93
112
|
private
|
94
113
|
|
95
114
|
def border_class
|
@@ -1,152 +1,27 @@
|
|
1
1
|
@import "../tokens/spacing";
|
2
2
|
@import "../tokens/colors";
|
3
3
|
@import "../tokens/border_radius";
|
4
|
-
@import "../tokens/titles";
|
5
|
-
@import "../tokens/typography";
|
6
4
|
|
7
5
|
[class^="pb_nav_list"] {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
@mixin bold_class {
|
17
|
-
.pb_collapsible_main_kit {
|
18
|
-
.pb_nav_list_item_text_collapsible {
|
19
|
-
@include pb_title_4;
|
20
|
-
font-weight: $bolder !important;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
&[class*="_active"] {
|
26
|
-
background-color: unset !important;
|
27
|
-
.pb_nav_list_item_link {
|
28
|
-
color: unset !important;
|
29
|
-
}
|
30
|
-
.pb_collapsible_main_kit {
|
31
|
-
background-color: $primary !important;
|
32
|
-
border-radius: $border_rad_heavier;
|
33
|
-
.pb_nav_list_item_text_collapsible,
|
34
|
-
.pb_nav_list_item_icon_collapsible,
|
35
|
-
.icon_wrapper,
|
36
|
-
.pb_icon_kit {
|
37
|
-
color: $white !important;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
&:hover {
|
42
|
-
background-color: unset;
|
43
|
-
}
|
44
|
-
.pb_collapsible_main_kit:hover {
|
45
|
-
.pb_nav_list_item_text_collapsible {
|
46
|
-
color: $white !important;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
.icon_wrapper {
|
51
|
-
&:hover {
|
52
|
-
background-color: mix($primary, $card_light, 40%);
|
53
|
-
.pb_icon_kit {
|
54
|
-
color: $primary !important;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
6
|
+
.pb_collapsible_nav_item {
|
7
|
+
.pb_collapsible_main_kit,
|
8
|
+
.pb_collapsible_content_kit,
|
9
|
+
.pb_collapsible_kit {
|
10
|
+
padding: 0 !important;
|
11
|
+
}
|
59
12
|
|
13
|
+
.icon_wrapper {
|
14
|
+
border-radius: $border_radius_rounded;
|
15
|
+
width: 19px;
|
16
|
+
height: 19px;
|
17
|
+
display:flex;
|
18
|
+
align-items: center;
|
19
|
+
justify-content: center;
|
20
|
+
margin-right: $space_xs;
|
60
21
|
&:hover {
|
61
|
-
|
62
|
-
background-color: unset !important;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
.pb_collapsible_main_kit:hover {
|
67
|
-
border-radius: $border_rad_heavier;
|
68
|
-
background-color: mix($primary, $card_light, 10%);
|
69
|
-
.pb_nav_list_item_text_collapsible,
|
70
|
-
svg {
|
71
|
-
color: $primary !important;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
.pb_collapsible_main_kit,
|
76
|
-
.pb_collapsible_content_kit,
|
77
|
-
.pb_collapsible_kit {
|
78
|
-
padding: 0 !important;
|
79
|
-
}
|
22
|
+
background-color: rgba($primary_action, $opacity_3);
|
80
23
|
|
81
|
-
&[class*="_collapsible_trail"] {
|
82
|
-
@include collapsible_trail_class;
|
83
|
-
}
|
84
|
-
|
85
|
-
&[class*="_bold_text"] {
|
86
|
-
@include bold_class;
|
87
|
-
}
|
88
|
-
|
89
|
-
&[class*="_emphasized"] {
|
90
|
-
@include collapsible_trail_class;
|
91
|
-
@include bold_class;
|
92
|
-
}
|
93
|
-
|
94
|
-
.icon_wrapper {
|
95
|
-
border-radius: $border_radius_rounded;
|
96
|
-
width: $space_sm + 3;
|
97
|
-
height: $space_sm + 3;
|
98
|
-
display: flex;
|
99
|
-
align-items: center;
|
100
|
-
justify-content: center;
|
101
|
-
margin-right: $space_xs;
|
102
|
-
&:hover {
|
103
|
-
background-color: mix($primary, $card_light, 40%);
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
&.dark {
|
108
|
-
&[class*="pb_nav_list_kit_item"] [class*="_link"]:hover {
|
109
|
-
.pb_nav_list_item_text {
|
110
|
-
color: $white !important;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
.pb_nav_list_item_text_collapsible {
|
115
|
-
color: $white !important;
|
116
|
-
}
|
117
|
-
.pb_nav_list_item_text {
|
118
|
-
color: $text_dk_light;
|
119
|
-
}
|
120
|
-
.pb_nav_list_kit_item:hover {
|
121
|
-
background-color: #ffffff33;
|
122
|
-
color: $white;
|
123
|
-
}
|
124
|
-
.pb_icon_kit {
|
125
|
-
color: $text_dk_light;
|
126
|
-
}
|
127
|
-
|
128
|
-
.pb_collapsible_main_kit:hover {
|
129
|
-
background-color: mix($white, $card_dark, 20%);
|
130
|
-
.pb_nav_list_item_text_collapsible,
|
131
|
-
svg {
|
132
|
-
color: $white !important;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
.icon_wrapper:hover {
|
136
|
-
background-color: mix($white, $card_dark, 40%);
|
137
|
-
}
|
138
|
-
&[class*="_active"] {
|
139
|
-
.icon_wrapper:hover {
|
140
|
-
background-color: mix($primary, $card_light, 40%);
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
&[class*="pb_collapsible_nav_item"][class*="_emphasized"],
|
145
|
-
&[class*="pb_collapsible_nav_item"][class*="_collapsible_trail"] {
|
146
|
-
.pb_collapsible_content_kit {
|
147
|
-
border-color: $border_dark;
|
148
|
-
}
|
149
|
-
}
|
150
24
|
}
|
151
25
|
}
|
152
26
|
}
|
27
|
+
}
|
@@ -11,69 +11,57 @@ import Collapsible from '../pb_collapsible/_collapsible'
|
|
11
11
|
type NavItemProps = {
|
12
12
|
active?: boolean,
|
13
13
|
aria?: { [key: string]: string },
|
14
|
-
bold?: boolean,
|
15
|
-
emphasized?: boolean,
|
16
14
|
children?: React.ReactNode[] | React.ReactNode,
|
17
15
|
className?: string,
|
18
16
|
collapsible?: boolean,
|
17
|
+
collapsibleClick?: () => void,
|
19
18
|
data?: object,
|
20
|
-
dark?: boolean,
|
21
19
|
iconLeft?: string,
|
22
20
|
iconRight?: string | string[],
|
23
|
-
|
24
|
-
|
21
|
+
iconRightClick?: () => void,
|
22
|
+
iconLeftClick?: () => void,
|
25
23
|
id?: string,
|
26
24
|
imageUrl?: string,
|
27
25
|
link?: string,
|
28
|
-
onClick?:
|
26
|
+
onClick?: React.MouseEventHandler<HTMLElement>,
|
29
27
|
target?: '_blank' | '_self' | '_parent' | '_top',
|
30
28
|
text: string,
|
31
|
-
|
32
|
-
collapsed?: boolean
|
29
|
+
toggleCollapsed?: any
|
33
30
|
} & GlobalProps
|
34
31
|
|
35
32
|
const NavItem = (props: NavItemProps) => {
|
36
33
|
const {
|
37
34
|
active = false,
|
38
35
|
aria = {},
|
39
|
-
bold,
|
40
|
-
emphasized,
|
41
36
|
children,
|
42
37
|
className,
|
43
38
|
collapsible,
|
39
|
+
collapsibleClick,
|
44
40
|
data = {},
|
45
|
-
dark = false,
|
46
41
|
iconLeft,
|
47
42
|
iconRight,
|
48
|
-
|
49
|
-
|
43
|
+
iconRightClick,
|
44
|
+
iconLeftClick,
|
50
45
|
id,
|
51
46
|
imageUrl,
|
52
47
|
link,
|
53
48
|
onClick = () => { },
|
54
49
|
target = '_self',
|
55
50
|
text = '',
|
56
|
-
|
57
|
-
collapsed
|
51
|
+
toggleCollapsed
|
58
52
|
} = props
|
59
53
|
|
60
54
|
const Tag = link ? 'a' : 'div'
|
61
55
|
const activeClass = active === true ? 'active' : ''
|
62
|
-
const collapsibleTrailClass = collapsible && collapsibleTrail ? 'collapsible_trail' : ''
|
63
|
-
const boldClass = collapsible && bold ? 'bold' : ''
|
64
|
-
const emphasizedClass = collapsible && emphasized ? 'emphasized' : ''
|
65
56
|
const ariaProps = buildAriaProps(aria)
|
66
57
|
const dataProps = buildDataProps(data)
|
67
|
-
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass),
|
68
|
-
collapsible ? buildCss('pb_collapsible_nav_item', activeClass, collapsibleTrailClass, boldClass, emphasizedClass) : '',
|
69
|
-
globalProps(props),
|
70
|
-
className)
|
58
|
+
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass), collapsible ? 'pb_collapsible_nav_item' : '', globalProps(props), className)
|
71
59
|
|
72
60
|
|
73
61
|
const handleIconClick = (e:any) => {
|
74
|
-
if (
|
62
|
+
if (iconLeftClick) {
|
75
63
|
e.stopPropagation();
|
76
|
-
|
64
|
+
iconLeftClick()
|
77
65
|
}
|
78
66
|
}
|
79
67
|
|
@@ -89,19 +77,20 @@ const NavItem = (props: NavItemProps) => {
|
|
89
77
|
<Collapsible icon={iconRight ? iconRight : ['plus','minus']}
|
90
78
|
iconSize="xs"
|
91
79
|
id={id}
|
92
|
-
collapsed={
|
93
|
-
|
94
|
-
onClick={
|
80
|
+
collapsed={toggleCollapsed}
|
81
|
+
iconClick={iconRightClick}
|
82
|
+
onClick={collapsibleClick}
|
95
83
|
>
|
96
|
-
<Collapsible.Main
|
84
|
+
<Collapsible.Main>
|
97
85
|
<Tag
|
98
|
-
className="
|
86
|
+
className="pb_nav_list_item_link"
|
99
87
|
href={link}
|
88
|
+
onClick={onClick}
|
100
89
|
target={target}
|
101
90
|
>
|
102
91
|
{imageUrl &&
|
103
92
|
<div
|
104
|
-
className="
|
93
|
+
className="pb_nav_list_item_icon_section"
|
105
94
|
key={imageUrl}
|
106
95
|
onClick={(e)=>handleIconClick(e)}
|
107
96
|
>
|
@@ -114,18 +103,18 @@ const NavItem = (props: NavItemProps) => {
|
|
114
103
|
|
115
104
|
{iconLeft &&
|
116
105
|
<div
|
117
|
-
className="
|
106
|
+
className="pb_nav_list_item_icon_section"
|
118
107
|
key={iconLeft}
|
119
108
|
onClick={(e)=>handleIconClick(e)}
|
120
109
|
>
|
121
110
|
<Icon
|
122
|
-
className="
|
111
|
+
className="pb_nav_list_item_icon_left"
|
123
112
|
fixedWidth
|
124
113
|
icon={iconLeft}
|
125
114
|
/>
|
126
115
|
</div>
|
127
116
|
}
|
128
|
-
<span className="
|
117
|
+
<span className="pb_nav_list_item_text">
|
129
118
|
{text}
|
130
119
|
</span>
|
131
120
|
</Tag>
|
@@ -29,6 +29,12 @@
|
|
29
29
|
flex: 1;
|
30
30
|
font-weight: $regular;
|
31
31
|
}
|
32
|
+
}
|
33
|
+
&[class*=_active] [class*=_link] {
|
34
|
+
@include pb_title_4;
|
35
|
+
color: $primary;
|
36
|
+
letter-spacing: normal;
|
37
|
+
}
|
32
38
|
&:hover {
|
33
39
|
background-color: rgba($primary, 0.03);
|
34
40
|
[class*=_icon] {
|
@@ -38,11 +44,5 @@
|
|
38
44
|
color: $primary;
|
39
45
|
}
|
40
46
|
}
|
41
|
-
}
|
42
|
-
&[class*=_active] [class*=_link] {
|
43
|
-
@include pb_title_4;
|
44
|
-
color: $primary;
|
45
|
-
letter-spacing: normal;
|
46
|
-
}
|
47
47
|
}
|
48
48
|
}
|