playbook_ui 12.36.0 → 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/index.js +2 -1
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +33 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_default_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_notification_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_props_swift.md +6 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +15 -13
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +24 -8
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +15 -4
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_collapsible/useCollapsible.tsx +14 -0
- 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 +22 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +26 -2
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +59 -79
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +4 -6
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_nav/item.rb +5 -1
- data/app/pb_kits/playbook/pb_pill/docs/_pill_default_swift.md +5 -0
- data/app/pb_kits/playbook/pb_pill/docs/_pill_props_swift.md +5 -0
- data/app/pb_kits/playbook/pb_pill/docs/_pill_variants_swift.md +10 -0
- data/app/pb_kits/playbook/pb_pill/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment_swift.md +16 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_swift.md +18 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_default_swift.md +15 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error_swift.md +14 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_orientation_swift.md +15 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_padding_swift.md +31 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_props_swift.md +10 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_spacing_swift.md +36 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_subtitle_swift.md +13 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_options.html.erb +12 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +1 -1
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align_swift.md +45 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default_swift.md +26 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed_swift.md +25 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_props_swift.md +10 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones_swift.md +67 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_swift.md +19 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +8 -0
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +2 -2
- metadata +33 -7
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
|
@@ -129,4 +129,5 @@ export { default as PbTypeahead } from './pb_typeahead'
|
|
129
129
|
export { default as dialogHelper } from './pb_dialog/dialogHelper'
|
130
130
|
|
131
131
|
//Theming
|
132
|
-
export {default as mapTheme} from './pb_map/pbMapTheme'
|
132
|
+
export {default as mapTheme} from './pb_map/pbMapTheme'
|
133
|
+
export {default as useCollapsible} from './pb_collapsible/useCollapsible'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
![badge-colors](https://github.com/powerhome/playbook/assets/92755007/52ce34ef-eb0d-48c0-9232-89edfff60cef)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
HStack {
|
5
|
+
PBBadge(text: "1", rounded: true, variant: .chat)
|
6
|
+
PBBadge(text: "4", variant: .chat)
|
7
|
+
PBBadge(text: "1000", variant: .chat)
|
8
|
+
|
9
|
+
PBBadge(text: "1", rounded: true, variant: .error)
|
10
|
+
PBBadge(text: "4", variant: .error)
|
11
|
+
PBBadge(text: "1000", variant: .error)
|
12
|
+
|
13
|
+
PBBadge(text: "1", rounded: true, variant: .info)
|
14
|
+
PBBadge(text: "4", variant: .info)
|
15
|
+
PBBadge(text: "1000", variant: .info)
|
16
|
+
|
17
|
+
PBBadge(text: "1", rounded: true, variant: .neutral)
|
18
|
+
PBBadge(text: "4", variant: .neutral)
|
19
|
+
PBBadge(text: "1000", variant: .neutral)
|
20
|
+
|
21
|
+
PBBadge(text: "1", rounded: true, variant: .primary)
|
22
|
+
PBBadge(text: "4", variant: .primary)
|
23
|
+
PBBadge(text: "1000", variant: .primary)
|
24
|
+
|
25
|
+
PBBadge(text: "1", rounded: true, variant: .success)
|
26
|
+
PBBadge(text: "4", variant: .success)
|
27
|
+
PBBadge(text: "1000", variant: .success)
|
28
|
+
|
29
|
+
PBBadge(text: "1", rounded: true, variant: .warning)
|
30
|
+
PBBadge(text: "4", variant: .warning)
|
31
|
+
PBBadge(text: "1000", variant: .warning)
|
32
|
+
}
|
33
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
![badge-rectangle](https://github.com/powerhome/playbook/assets/92755007/04188c68-84f0-475b-9764-7b9a325f73da)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
HStack {
|
5
|
+
PBBadge(text: "+1", variant: .primary)
|
6
|
+
PBBadge(text: "+4", variant: .primary)
|
7
|
+
PBBadge(text: "+1000", variant: .primary)
|
8
|
+
}
|
9
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
![badge-chat-notification](https://github.com/powerhome/playbook/assets/92755007/f769c3bc-6a63-465d-8538-3efb5f3ec0d3)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
HStack {
|
5
|
+
PBBadge(text: "1", rounded: true, variant: .chat)
|
6
|
+
PBBadge(text: "4", variant: .chat)
|
7
|
+
PBBadge(text: "1000", variant: .chat)
|
8
|
+
}
|
9
|
+
```
|
@@ -0,0 +1,6 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **text** | `String` | Specifies the value of the Badge | | |
|
5
|
+
| **rounded** | `Bool` | Displays the rounded variant | `false` | |
|
6
|
+
| **variant** | `Variant` | Changes the color of the Badge | `.primary` | `.chat` `.error` `.info` `.neutral` `.primary` `.success` `.warning` |
|
@@ -0,0 +1,9 @@
|
|
1
|
+
![badge-rounded](https://github.com/powerhome/playbook/assets/92755007/775a906f-0108-4ee1-a277-e7b9f2715a2b)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
HStack {
|
5
|
+
PBBadge(text: "+1", rounded: true, variant: .primary)
|
6
|
+
PBBadge(text: "+4", rounded: true, variant: .primary)
|
7
|
+
PBBadge(text: "+1000", rounded: true, variant: .primary)
|
8
|
+
}
|
9
|
+
```
|
@@ -10,3 +10,10 @@ examples:
|
|
10
10
|
- badge_rounded: Rounded
|
11
11
|
- badge_colors: Colors
|
12
12
|
- badge_notification: Notification
|
13
|
+
|
14
|
+
swift:
|
15
|
+
- badge_default_swift: Rectangle
|
16
|
+
- badge_rounded_swift: Rounded
|
17
|
+
- badge_colors_swift: Colors
|
18
|
+
- badge_notification_swift: Notification
|
19
|
+
- badge_props_swift: ""
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { useEffect } from 'react'
|
2
2
|
import classnames from 'classnames'
|
3
|
+
import useCollapsible from './useCollapsible'
|
3
4
|
|
4
5
|
import { globalProps } from '../utilities/globalProps'
|
5
6
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
@@ -16,20 +17,15 @@ type CollapsibleProps = {
|
|
16
17
|
className?: string,
|
17
18
|
collapsed?: boolean,
|
18
19
|
data?: object,
|
19
|
-
icon?: string | string[]
|
20
|
+
icon?: string | string[],
|
20
21
|
iconColor?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
|
21
|
-
iconSize?: IconSizes
|
22
|
+
iconSize?: IconSizes,
|
23
|
+
iconClick?: ()=> void,
|
24
|
+
onClick?: ()=> void,
|
22
25
|
id?: string,
|
23
26
|
}
|
24
27
|
|
25
|
-
const useCollapsible = (initial = false) => {
|
26
|
-
const [collapsed, setCollapsed] = useState(initial)
|
27
28
|
|
28
|
-
return [
|
29
|
-
collapsed,
|
30
|
-
() => setCollapsed((t) => !t),
|
31
|
-
]
|
32
|
-
}
|
33
29
|
|
34
30
|
const Collapsible = ({
|
35
31
|
aria = {},
|
@@ -40,10 +36,17 @@ const Collapsible = ({
|
|
40
36
|
icon,
|
41
37
|
iconColor = 'default',
|
42
38
|
iconSize,
|
39
|
+
iconClick,
|
40
|
+
onClick,
|
43
41
|
id,
|
44
42
|
...props
|
45
43
|
}: CollapsibleProps) => {
|
46
|
-
const [isCollapsed,
|
44
|
+
const [isCollapsed, toggle, setIsCollapsed] = useCollapsible(collapsed)
|
45
|
+
|
46
|
+
useEffect(()=> {
|
47
|
+
setIsCollapsed(collapsed)
|
48
|
+
},[collapsed])
|
49
|
+
|
47
50
|
const CollapsibleParent = React.Children.toArray(children) as JSX.Element[]
|
48
51
|
|
49
52
|
if (CollapsibleParent.length !== 2) {
|
@@ -62,9 +65,8 @@ const Collapsible = ({
|
|
62
65
|
globalProps(props),
|
63
66
|
className
|
64
67
|
)
|
65
|
-
|
66
68
|
return (
|
67
|
-
<CollapsibleContext.Provider value={{ collapsed: isCollapsed,
|
69
|
+
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, toggle, icon, iconSize, iconColor, iconClick, onClick }}>
|
68
70
|
<div
|
69
71
|
{...ariaProps}
|
70
72
|
{...dataProps}
|
@@ -33,7 +33,7 @@ type CollapsibleMainProps = {
|
|
33
33
|
children: React.ReactNode[] | React.ReactNode,
|
34
34
|
className?: string,
|
35
35
|
cursor?: string,
|
36
|
-
|
36
|
+
onClick?: ()=> void
|
37
37
|
}
|
38
38
|
type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success"
|
39
39
|
|
@@ -42,9 +42,10 @@ type IconProps = {
|
|
42
42
|
icon?: string[] | string
|
43
43
|
iconColor?: IconColors
|
44
44
|
iconSize?: IconSizes
|
45
|
+
iconClick?: ()=> void
|
45
46
|
}
|
46
47
|
|
47
|
-
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
|
48
|
+
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor, iconClick }: IconProps) => {
|
48
49
|
const color = colorMap[iconColor]
|
49
50
|
|
50
51
|
const showIcon = (icon: string |string[]) => {
|
@@ -54,6 +55,13 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
|
|
54
55
|
return icon
|
55
56
|
}
|
56
57
|
|
58
|
+
const handleIconClick = (e:any) => {
|
59
|
+
if (iconClick) {
|
60
|
+
e.stopPropagation();
|
61
|
+
iconClick()
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
57
65
|
return (
|
58
66
|
<>
|
59
67
|
{collapsed ? (
|
@@ -61,6 +69,7 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
|
|
61
69
|
className="icon_wrapper"
|
62
70
|
key={icon ? showIcon(icon)[0] : "chevron-down"}
|
63
71
|
style={{ verticalAlign: "middle", color: color }}
|
72
|
+
onClick={(e)=> handleIconClick(e)}
|
64
73
|
>
|
65
74
|
<Icon icon={icon ? showIcon(icon)[0] : "chevron-down"} size={iconSize} />
|
66
75
|
</div>
|
@@ -69,6 +78,7 @@ const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
|
|
69
78
|
className="icon_wrapper"
|
70
79
|
key={icon ? showIcon(icon)[1] : "chevron-up"}
|
71
80
|
style={{ verticalAlign: "middle", color: color }}
|
81
|
+
onClick={(e)=> handleIconClick(e)}
|
72
82
|
>
|
73
83
|
<Icon icon={icon ? showIcon(icon)[1] : "chevron-up"} size={iconSize} />
|
74
84
|
</div>
|
@@ -83,13 +93,18 @@ const CollapsibleMain = ({
|
|
83
93
|
cursor = 'pointer',
|
84
94
|
...props
|
85
95
|
}: CollapsibleMainProps): React.ReactElement=> {
|
86
|
-
const
|
96
|
+
const {collapsed, toggle, icon, iconSize, iconColor, iconClick, onClick}: any = useContext(CollapsibleContext)
|
87
97
|
const mainCSS = buildCss('pb_collapsible_main_kit')
|
88
98
|
const mainSpacing = globalProps(props, { cursor })
|
89
99
|
|
100
|
+
const handleCollapsibleClick = (e:any) => {
|
101
|
+
toggle();
|
102
|
+
onClick && onClick(e)
|
103
|
+
}
|
104
|
+
|
90
105
|
return (
|
91
106
|
<div className={classnames(mainCSS, className, mainSpacing)}>
|
92
|
-
<div onClick={
|
107
|
+
<div onClick={(e)=>handleCollapsibleClick(e)}>
|
93
108
|
<Flex
|
94
109
|
spacing="between"
|
95
110
|
vertical="center"
|
@@ -97,10 +112,11 @@ const CollapsibleMain = ({
|
|
97
112
|
<FlexItem>{children}</FlexItem>
|
98
113
|
<FlexItem>
|
99
114
|
<ToggleIcon
|
100
|
-
collapsed={
|
101
|
-
iconColor={
|
102
|
-
iconSize={
|
103
|
-
icon={
|
115
|
+
collapsed={collapsed as () => void}
|
116
|
+
iconColor={iconColor as IconColors}
|
117
|
+
iconSize={iconSize as IconSizes}
|
118
|
+
icon={icon as string[] | string}
|
119
|
+
iconClick={iconClick}
|
104
120
|
/>
|
105
121
|
</FlexItem>
|
106
122
|
</Flex>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<%= content.presence %>
|
10
10
|
<% end %>
|
11
11
|
<%= pb_rails("flex/flex_item") do %>
|
12
|
-
<div style="color: <%= object.icon_color %>">
|
12
|
+
<div style="color: <%= object.icon_color %>" class="icon_wrapper" >
|
13
13
|
<% if object.icon.present? %>
|
14
14
|
<%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[0], id:"collapsible_open_icon", size: object.size }) %>
|
15
15
|
<%= pb_rails("icon", props: { icon: object.show_icon(object.icon)[1], id:"collapsible_close_icon", size: object.size }) %>
|
@@ -1,8 +1,17 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { Collapsible } from '../..'
|
2
|
+
import { Collapsible, useCollapsible, Button } from '../..'
|
3
3
|
|
4
|
-
const CollapsibleIcons = () =>
|
5
|
-
|
4
|
+
const CollapsibleIcons = () => {
|
5
|
+
const [isCollapsed, setIsCollapsed] = useCollapsible(true)
|
6
|
+
|
7
|
+
return (
|
8
|
+
<>
|
9
|
+
<Button onClick={()=> setIsCollapsed(!isCollapsed)}>
|
10
|
+
{isCollapsed ? "Expand" : "Collapse"}
|
11
|
+
</Button>
|
12
|
+
<Collapsible collapsed={isCollapsed}
|
13
|
+
icon={['plus','minus']}
|
14
|
+
>
|
6
15
|
<Collapsible.Main>
|
7
16
|
<div>{'Main Section'}</div>
|
8
17
|
</Collapsible.Main>
|
@@ -14,6 +23,8 @@ const CollapsibleIcons = () => (
|
|
14
23
|
</div>
|
15
24
|
</Collapsible.Content>
|
16
25
|
</Collapsible>
|
17
|
-
|
26
|
+
</>
|
27
|
+
)
|
28
|
+
}
|
18
29
|
|
19
30
|
export default CollapsibleIcons
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import {useState} from 'react';
|
2
|
+
|
3
|
+
const useCollapsible = (initial= true) => {
|
4
|
+
const [collapsed, setCollapsed] = useState(initial)
|
5
|
+
|
6
|
+
const toggle = () => setCollapsed((prev) => !prev)
|
7
|
+
return [
|
8
|
+
collapsed,
|
9
|
+
toggle,
|
10
|
+
setCollapsed as any,
|
11
|
+
]
|
12
|
+
}
|
13
|
+
|
14
|
+
export default useCollapsible
|
@@ -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,6 +1,27 @@
|
|
1
|
+
@import "../tokens/spacing";
|
2
|
+
@import "../tokens/colors";
|
3
|
+
@import "../tokens/border_radius";
|
4
|
+
|
1
5
|
[class^="pb_nav_list"] {
|
6
|
+
.pb_collapsible_nav_item {
|
2
7
|
.pb_collapsible_main_kit,
|
3
|
-
.pb_collapsible_content_kit
|
8
|
+
.pb_collapsible_content_kit,
|
9
|
+
.pb_collapsible_kit {
|
4
10
|
padding: 0 !important;
|
5
11
|
}
|
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;
|
21
|
+
&:hover {
|
22
|
+
background-color: rgba($primary_action, $opacity_3);
|
23
|
+
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
6
27
|
}
|
@@ -14,15 +14,19 @@ type NavItemProps = {
|
|
14
14
|
children?: React.ReactNode[] | React.ReactNode,
|
15
15
|
className?: string,
|
16
16
|
collapsible?: boolean,
|
17
|
+
collapsibleClick?: () => void,
|
17
18
|
data?: object,
|
18
19
|
iconLeft?: string,
|
19
20
|
iconRight?: string | string[],
|
21
|
+
iconRightClick?: () => void,
|
22
|
+
iconLeftClick?: () => void,
|
20
23
|
id?: string,
|
21
24
|
imageUrl?: string,
|
22
25
|
link?: string,
|
23
26
|
onClick?: React.MouseEventHandler<HTMLElement>,
|
24
27
|
target?: '_blank' | '_self' | '_parent' | '_top',
|
25
28
|
text: string,
|
29
|
+
toggleCollapsed?: any
|
26
30
|
} & GlobalProps
|
27
31
|
|
28
32
|
const NavItem = (props: NavItemProps) => {
|
@@ -32,22 +36,34 @@ const NavItem = (props: NavItemProps) => {
|
|
32
36
|
children,
|
33
37
|
className,
|
34
38
|
collapsible,
|
39
|
+
collapsibleClick,
|
35
40
|
data = {},
|
36
41
|
iconLeft,
|
37
42
|
iconRight,
|
43
|
+
iconRightClick,
|
44
|
+
iconLeftClick,
|
38
45
|
id,
|
39
46
|
imageUrl,
|
40
47
|
link,
|
41
48
|
onClick = () => { },
|
42
49
|
target = '_self',
|
43
50
|
text = '',
|
51
|
+
toggleCollapsed
|
44
52
|
} = props
|
45
53
|
|
46
54
|
const Tag = link ? 'a' : 'div'
|
47
55
|
const activeClass = active === true ? 'active' : ''
|
48
56
|
const ariaProps = buildAriaProps(aria)
|
49
57
|
const dataProps = buildDataProps(data)
|
50
|
-
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass), globalProps(props), className)
|
58
|
+
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass), collapsible ? 'pb_collapsible_nav_item' : '', globalProps(props), className)
|
59
|
+
|
60
|
+
|
61
|
+
const handleIconClick = (e:any) => {
|
62
|
+
if (iconLeftClick) {
|
63
|
+
e.stopPropagation();
|
64
|
+
iconLeftClick()
|
65
|
+
}
|
66
|
+
}
|
51
67
|
|
52
68
|
return (
|
53
69
|
<li
|
@@ -58,7 +74,13 @@ const NavItem = (props: NavItemProps) => {
|
|
58
74
|
>
|
59
75
|
{
|
60
76
|
collapsible ? (
|
61
|
-
<Collapsible icon={iconRight ? iconRight : ['plus','minus']}
|
77
|
+
<Collapsible icon={iconRight ? iconRight : ['plus','minus']}
|
78
|
+
iconSize="xs"
|
79
|
+
id={id}
|
80
|
+
collapsed={toggleCollapsed}
|
81
|
+
iconClick={iconRightClick}
|
82
|
+
onClick={collapsibleClick}
|
83
|
+
>
|
62
84
|
<Collapsible.Main>
|
63
85
|
<Tag
|
64
86
|
className="pb_nav_list_item_link"
|
@@ -70,6 +92,7 @@ const NavItem = (props: NavItemProps) => {
|
|
70
92
|
<div
|
71
93
|
className="pb_nav_list_item_icon_section"
|
72
94
|
key={imageUrl}
|
95
|
+
onClick={(e)=>handleIconClick(e)}
|
73
96
|
>
|
74
97
|
<Image
|
75
98
|
className="pb_nav_img_wrapper"
|
@@ -82,6 +105,7 @@ const NavItem = (props: NavItemProps) => {
|
|
82
105
|
<div
|
83
106
|
className="pb_nav_list_item_icon_section"
|
84
107
|
key={iconLeft}
|
108
|
+
onClick={(e)=>handleIconClick(e)}
|
85
109
|
>
|
86
110
|
<Icon
|
87
111
|
className="pb_nav_list_item_icon_left"
|
@@ -1,83 +1,63 @@
|
|
1
|
-
import React from "react"
|
2
|
-
|
3
|
-
import Nav from "../_nav";
|
4
|
-
import NavItem from "../_item";
|
1
|
+
import React from "react"
|
2
|
+
import { Nav, NavItem, useCollapsible } from "../.."
|
5
3
|
|
6
4
|
const CollapsibleNav = (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
|
+
|
20
|
+
const handleIconRightClick = (index) => {
|
21
|
+
const [isCollapsed, setCollapsed] = collapsibles[index]
|
22
|
+
setCollapsed(!isCollapsed)
|
23
|
+
}
|
24
|
+
|
7
25
|
return (
|
8
|
-
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
/>
|
45
|
-
<NavItem
|
46
|
-
link="#"
|
47
|
-
text="Food"
|
48
|
-
{...props}
|
49
|
-
/>
|
50
|
-
<NavItem
|
51
|
-
link="#"
|
52
|
-
text="Style"
|
53
|
-
{...props}
|
54
|
-
/>
|
55
|
-
</NavItem>
|
56
|
-
<NavItem
|
57
|
-
collapsible
|
58
|
-
iconLeft="city"
|
59
|
-
link="#"
|
60
|
-
text="Similar Artists"
|
61
|
-
{...props}
|
62
|
-
>
|
63
|
-
<NavItem
|
64
|
-
link="#"
|
65
|
-
text="City"
|
66
|
-
{...props}
|
67
|
-
/>
|
68
|
-
<NavItem
|
69
|
-
link="#"
|
70
|
-
text="People"
|
71
|
-
{...props}
|
72
|
-
/>
|
73
|
-
<NavItem
|
74
|
-
link="#"
|
75
|
-
text="Business"
|
76
|
-
{...props}
|
77
|
-
/>
|
78
|
-
</NavItem>
|
79
|
-
</Nav>
|
80
|
-
);
|
81
|
-
};
|
26
|
+
<>
|
27
|
+
<Nav variant='subtle'>
|
28
|
+
{navItems.map((text, index) => {
|
29
|
+
const [collapsed] = collapsibles[index]
|
30
|
+
return (
|
31
|
+
<NavItem
|
32
|
+
collapsible
|
33
|
+
collapsibleClick={() => handleMainClick(index)}
|
34
|
+
iconLeft="chevron-down"
|
35
|
+
iconRightClick={() => handleIconRightClick(index)}
|
36
|
+
id={`collapsible-nav-item-${index + 1}`}
|
37
|
+
key={index}
|
38
|
+
link="#"
|
39
|
+
text={text}
|
40
|
+
toggleCollapsed={collapsed}
|
41
|
+
{...props}
|
42
|
+
>
|
43
|
+
<NavItem link="#"
|
44
|
+
text="City"
|
45
|
+
{...props}
|
46
|
+
/>
|
47
|
+
<NavItem link="#"
|
48
|
+
text="People"
|
49
|
+
{...props}
|
50
|
+
/>
|
51
|
+
<NavItem link="#"
|
52
|
+
text="Business"
|
53
|
+
{...props}
|
54
|
+
/>
|
55
|
+
</NavItem>
|
56
|
+
);
|
57
|
+
})}
|
58
|
+
</Nav>
|
59
|
+
</>
|
60
|
+
)
|
61
|
+
}
|
82
62
|
|
83
|
-
export default CollapsibleNav
|
63
|
+
export default CollapsibleNav
|