playbook_ui 13.23.0.pre.alpha.PLAY1284investigation2657 β†’ 13.24.0.pre.alpha.PBNTR261NewKitDropdown2681

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/index.js +1 -0
  4. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +16 -2
  5. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +2 -0
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.html.erb +23 -0
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.jsx +35 -0
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.html.erb +22 -0
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.jsx +34 -0
  10. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.md +1 -0
  11. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +4 -0
  12. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +2 -0
  13. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +92 -0
  14. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +152 -0
  15. data/app/pb_kits/playbook/pb_dropdown/context/index.tsx +5 -0
  16. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +53 -0
  17. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +104 -0
  18. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +69 -0
  19. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +78 -0
  20. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +9 -0
  21. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -0
  22. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +17 -0
  23. data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +17 -0
  24. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +53 -0
  25. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +95 -0
  26. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +91 -0
  27. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +118 -0
  28. data/app/pb_kits/playbook/pb_list/_list_item.tsx +2 -2
  29. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  30. data/app/pb_kits/playbook/tokens/_colors.scss +1 -1
  31. data/dist/menu.yml +5 -1
  32. data/dist/playbook-rails.js +6 -6
  33. data/lib/playbook/version.rb +2 -2
  34. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f32666e4b2500b014dc2554c3ebf3f5f4e3695cc726a3fc1d53bf5b332455a5
4
- data.tar.gz: ff93821e0818cfbf57b09ece3fe03ce0c5459e4d29161f896d5771a3e8eb3761
3
+ metadata.gz: e7befd6847de7d677af4be77be96824572a5fc0cb5a643ea35570064fe156ccb
4
+ data.tar.gz: 67dea2e25b7861d71730c3ad905df0316806517c70f663077e506bdee9be471f
5
5
  SHA512:
6
- metadata.gz: 93c9e3de45864e757c047b19dd7eeed12610d97f234a160183143155ab0dbb88ea6087414e212ffd1037eff4064b239ba7eecfbb30627753f4b4ab1bfcacf1a9
7
- data.tar.gz: a5264af573a6eac322795be8739d2a3974a72085e3d5d163b79f4b1882899483b5e82f5205c1ced23c85d1dcc10f53d67570c3067645169fe9cf41f08062eca6
6
+ metadata.gz: 18d436e20297a673fbcaa699ce41a884d43859dd76482409ffb822b1dc803ceda9b78045642ccea169fd63645b73948e96d52343f76098ac8847415f57344e59
7
+ data.tar.gz: 16b5c21300347386fc574a61fa56a46c5b3e25c38bfb3f48f9b42ddc411b4f5a5d2c9121adbaa5e69384e189dcf24c896dcdf4892d41ff0078e3eea445f7edbb
@@ -1,5 +1,6 @@
1
1
 
2
2
 
3
+
3
4
  @import 'pb_advanced_table/advanced_table';
4
5
  @import 'pb_avatar/avatar';
5
6
  @import 'pb_avatar_action_button/avatar_action_button';
@@ -30,6 +31,7 @@
30
31
  @import 'pb_detail/detail';
31
32
  @import 'pb_dialog/dialog';
32
33
  @import 'pb_distribution_bar/distribution_bar';
34
+ @import 'pb_dropdown/dropdown';
33
35
  @import 'pb_file_upload/file_upload';
34
36
  @import 'pb_filter/filter';
35
37
  @import 'pb_fixed_confirmation_toast/fixed_confirmation_toast';
@@ -35,6 +35,7 @@ export { default as DateYearStacked } from './pb_date_year_stacked/_date_year_st
35
35
  export { default as Detail} from './pb_detail/_detail'
36
36
  export { default as Dialog } from './pb_dialog/_dialog'
37
37
  export { default as DistributionBar } from './pb_distribution_bar/_distribution_bar'
38
+ export { default as Dropdown} from './pb_dropdown/_dropdown'
38
39
  export { default as FileUpload } from './pb_file_upload/_file_upload'
39
40
  export { default as Filter } from './pb_filter/_filter'
40
41
  export { default as FixedConfirmationToast } from './pb_fixed_confirmation_toast/_fixed_confirmation_toast'
@@ -37,6 +37,7 @@ type BarGraphProps = {
37
37
  y?: number;
38
38
  aria?: { [key: string]: string };
39
39
  data?: { [key: string]: string };
40
+ stacking?: "normal" | "percent"
40
41
  axisFormat?: { format: string; }[] | string;
41
42
  };
42
43
 
@@ -55,6 +56,7 @@ const BarGraph = ({
55
56
  axisFormat,
56
57
  id,
57
58
  pointStart,
59
+ stacking,
58
60
  subTitle,
59
61
  type = "column",
60
62
  title = "Title",
@@ -101,7 +103,12 @@ const BarGraph = ({
101
103
  opposite: false,
102
104
  title: {
103
105
  text: typeof axisTitle === 'string' ? axisTitle : axisTitle[0].name,
104
- }
106
+ },
107
+ plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
108
+ value: 0,
109
+ zIndex: 10,
110
+ color: "#E4E8F0"
111
+ }],
105
112
  }],
106
113
  xAxis: {
107
114
  categories: xAxisCategories,
@@ -120,7 +127,9 @@ const BarGraph = ({
120
127
  : highchartsTheme.colors,
121
128
  plotOptions: {
122
129
  series: {
130
+ stacking: stacking,
123
131
  pointStart: pointStart,
132
+ borderWidth: stacking ? 0 : "",
124
133
  events: {},
125
134
  dataLabels: {
126
135
  enabled: false,
@@ -141,7 +150,12 @@ if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
141
150
  opposite: true,
142
151
  title: {
143
152
  text: axisTitle[1].name,
144
- }
153
+ },
154
+ plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
155
+ value: 0,
156
+ zIndex: 10,
157
+ color: "#E4E8F0"
158
+ }],
145
159
  });
146
160
  }
147
161
 
@@ -15,6 +15,7 @@ module Playbook
15
15
  values: %w[vertical horizontal],
16
16
  default: "vertical"
17
17
  prop :point_start, type: Playbook::Props::Numeric
18
+ prop :stacking
18
19
  prop :subtitle
19
20
  prop :title
20
21
  prop :x_axis_categories, type: Playbook::Props::Array,
@@ -50,6 +51,7 @@ module Playbook
50
51
  dark: dark ? "dark" : "",
51
52
  type: chart_type,
52
53
  title: title,
54
+ stacking: stacking,
53
55
  subTitle: subtitle,
54
56
  axisTitle: axis_title,
55
57
  axisFormat: axis_format,
@@ -0,0 +1,23 @@
1
+ <% data = [{
2
+ name: 'Installation',
3
+ data: [-475, 400, -1000, 354, -856],
4
+ threshold: 0
5
+ }, {
6
+ name: 'Manufacturing',
7
+ data: [1475, 200, 1000, 654, -656],
8
+ threshold: 0
9
+ },
10
+ {
11
+ name: 'Sales & Distribution',
12
+ data: [1270, 100, -1200, 554, 756],
13
+ threshold: 0
14
+ }] %>
15
+
16
+ <%= pb_rails("bar_graph", props: {
17
+ axis_title: 'Number of Employees',
18
+ chart_data: data,
19
+ id: "bar-default",
20
+ x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
21
+ title: 'Bar Graph with Negative Numbers',
22
+ legend: true,
23
+ }) %>
@@ -0,0 +1,35 @@
1
+ import React from 'react'
2
+
3
+ import BarGraph from '../_bar_graph'
4
+
5
+ const chartData = [{
6
+ name: 'Installation',
7
+ data: [-475, 400, -1000, 354, -856],
8
+ threshold: 0
9
+ }, {
10
+ name: 'Manufacturing',
11
+ data: [1475, 200, 1000, 654, -656],
12
+ threshold: 0
13
+ },
14
+ {
15
+ name: 'Sales & Distribution',
16
+ data: [1270, 100, -1200, 554, 756],
17
+ threshold: 0
18
+ }]
19
+
20
+
21
+ const BarGraphStacked = (props) => (
22
+ <div>
23
+ <BarGraph
24
+ axisTitle="Number of Employees"
25
+ chartData={chartData}
26
+ id="bar-default"
27
+ legend
28
+ title="Bar Graph with Negative Numbers"
29
+ xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
30
+ {...props}
31
+ />
32
+ </div>
33
+ )
34
+
35
+ export default BarGraphStacked
@@ -0,0 +1,22 @@
1
+ <% data = [{
2
+ name: 'Installation',
3
+ data: [1475, 200, 3000, 654, 656],
4
+ },
5
+ {
6
+ name: 'Manufacturing',
7
+ data: [1270, 800, 200, 454, 956],
8
+ }, {
9
+ name: 'Sales & Distribution',
10
+ data: [975, 1600, 1500, 924, 500],
11
+ }] %>
12
+
13
+ <%= pb_rails("bar_graph", props: {
14
+ axis_title: 'Number of Employees',
15
+ chart_data: data,
16
+ id: "bar-default",
17
+ y_axis_min: 0,
18
+ x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
19
+ stacking: "normal",
20
+ title: 'Bar Graph with Stacked Columns',
21
+ legend: true,
22
+ }) %>
@@ -0,0 +1,34 @@
1
+ import React from 'react'
2
+
3
+ import BarGraph from '../_bar_graph'
4
+
5
+ const chartData = [{
6
+ name: 'Installation',
7
+ data: [1475, 200, 3000, 654, 656],
8
+ },
9
+ {
10
+ name: 'Manufacturing',
11
+ data: [1270, 800, 200, 454, 956],
12
+ }, {
13
+ name: 'Sales & Distribution',
14
+ data: [975, 1600, 1500, 924, 500],
15
+ }]
16
+
17
+
18
+ const BarGraphStacked = (props) => (
19
+ <div>
20
+ <BarGraph
21
+ axisTitle="Number Of Employees"
22
+ chartData={chartData}
23
+ id="bar-default"
24
+ legend
25
+ stacking="normal"
26
+ title="Bar Graph with Stacked Columns"
27
+ xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
28
+ yAxisMin={0}
29
+ {...props}
30
+ />
31
+ </div>
32
+ )
33
+
34
+ export default BarGraphStacked
@@ -0,0 +1 @@
1
+ The `stacking` prop can be used for a stacked bar graph. The prop allows for `normal` or `percent` as options.
@@ -9,6 +9,8 @@ examples:
9
9
  - bar_graph_spline: Spline
10
10
  - bar_graph_colors: Color Overrides
11
11
  - bar_graph_custom: Custom Overrides
12
+ - bar_graph_stacked: Stacked
13
+ - bar_graph_negative_numbers: Negative Numbers
12
14
  - bar_graph_secondary_y_axis: Secondary Y-Axis
13
15
 
14
16
 
@@ -21,4 +23,6 @@ examples:
21
23
  - bar_graph_spline: Spline
22
24
  - bar_graph_colors: Color Overrides
23
25
  - bar_graph_custom: Custom Overrides
26
+ - bar_graph_stacked: Stacked
27
+ - bar_graph_negative_numbers: Negative Numbers
24
28
  - bar_graph_secondary_y_axis: Secondary Y-Axis
@@ -6,4 +6,6 @@ export { default as BarGraphHeight } from './_bar_graph_height.jsx'
6
6
  export { default as BarGraphSpline } from './_bar_graph_spline.jsx'
7
7
  export { default as BarGraphColors } from './_bar_graph_colors.jsx'
8
8
  export { default as BarGraphCustom } from './_bar_graph_custom.jsx'
9
+ export { default as BarGraphStacked } from './_bar_graph_stacked.jsx'
10
+ export { default as BarGraphNegativeNumbers } from './_bar_graph_negative_numbers.jsx'
9
11
  export { default as BarGraphSecondaryYAxis } from './_bar_graph_secondary_y_axis.jsx'
@@ -0,0 +1,92 @@
1
+ @import "../tokens/colors";
2
+ @import "../tokens/spacing";
3
+ @import "../tokens/typography";
4
+ @import "../tokens/border_radius";
5
+ @import "../tokens/shadows";
6
+ @import "../tokens/positioning";
7
+ @import "../pb_body/body_mixins";
8
+
9
+ .pb_dropdown {
10
+ .dropdown_wrapper {
11
+ position: relative;
12
+ .dropdown_trigger_wrapper {
13
+ @include pb_body;
14
+ border: 1px solid $border_light;
15
+ background-color: $white;
16
+ &:hover {
17
+ background-color: rgba($focus_input_light, $opacity_5);
18
+ input {
19
+ background-color: rgba($focus_input_light, $opacity_5);
20
+ }
21
+ }
22
+
23
+ .dropdown_input {
24
+ @include pb_body;
25
+ border: unset;
26
+ border-radius: $border_rad_heavier;
27
+ padding: 0;
28
+
29
+ &:focus-visible {
30
+ outline: none;
31
+ }
32
+ }
33
+ &:focus {
34
+ box-shadow: 0px 0px 0 1px $primary;
35
+ outline: unset;
36
+ transition: box-shadow .15s ease-in-out;
37
+ }
38
+ }
39
+
40
+ .dropdown_trigger_wrapper_focus {
41
+ box-shadow: 0px 0px 0 1px $primary;
42
+ transition: box-shadow .10s ease-in-out;
43
+ }
44
+
45
+ .pb_dropdown_container {
46
+ background-color: $white;
47
+ overflow:hidden;
48
+ box-shadow: $shadow_deep;
49
+ border-radius: $border_rad_heavier;
50
+ border: 1px solid $border_light;
51
+ margin-top: $space_xs;
52
+ position: absolute;
53
+ z-index: $z_1;
54
+ width: 100%;
55
+ transition: opacity .25s ease-in-out;
56
+
57
+ .pb_dropdown_option {
58
+ :hover {
59
+ background-color: $border_light;
60
+ }
61
+ }
62
+
63
+ .dropdown_option_focused {
64
+ background-color: $border_light;
65
+ }
66
+
67
+ .dropdown_option {
68
+ width: 100%;
69
+ }
70
+
71
+ .dropdown_option_list {
72
+ border-bottom: 1px solid $border_light;
73
+ }
74
+ .dropdown_option_selected {
75
+ background-color: $primary;
76
+ [class^="pb_body"], [class^="pb_title_kit"] {
77
+ color: $white !important;
78
+ }
79
+ :hover {
80
+ background-color: unset;
81
+ }
82
+ }
83
+ }
84
+ .close {
85
+ display: none;
86
+ }
87
+
88
+ .open {
89
+ display: block;
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,152 @@
1
+ import React, {useState, useRef, useEffect} from 'react'
2
+ import classnames from 'classnames'
3
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
+ import { globalProps } from '../utilities/globalProps'
5
+
6
+ import Body from '../pb_body/_body'
7
+
8
+ import DropdownContainer from './subcomponents/DropdownContainer'
9
+ import DropdownOption from './subcomponents/DropdownOption'
10
+ import DropdownTrigger from './subcomponents/DropdownTrigger'
11
+ import DropdownContext from './context'
12
+ import useDropdown from './hooks/useDropdown'
13
+ import { GenericObject } from '../types'
14
+
15
+ type DropdownProps = {
16
+ aria?: { [key: string]: string },
17
+ className?: string,
18
+ data?: { [key: string]: string },
19
+ id?: string,
20
+ children?: React.ReactChild[] | React.ReactChild,
21
+ options?: GenericObject,
22
+ onSelect?: (arg:GenericObject) => null
23
+ }
24
+
25
+ const Dropdown = (props: DropdownProps) => {
26
+ const {
27
+ aria = {},
28
+ children,
29
+ className,
30
+ data = {},
31
+ id,
32
+ options,
33
+ onSelect
34
+ } = props
35
+
36
+ const ariaProps = buildAriaProps(aria)
37
+ const dataProps = buildDataProps(data)
38
+ const classes = classnames(buildCss('pb_dropdown'), globalProps(props), className)
39
+
40
+ const [ isDropDownClosed, setIsDropDownClosed, toggleDropdown ] = useDropdown()
41
+
42
+ const [filterItem, setFilterItem] = useState("");
43
+ const [selected, setSelected] = useState({});
44
+ const [isInputFocused, setIsInputFocused] = useState(false);
45
+ //state for keyboard events
46
+ const [focusedOptionIndex, setFocusedOptionIndex] = useState(-1);
47
+
48
+ const dropdownRef = useRef(null);
49
+ const inputRef = useRef(null);
50
+
51
+ // useEffect to handle clicks outside the dropdown
52
+ useEffect(() => {
53
+ const handleClickOutside = (event: any) => {
54
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
55
+ setIsDropDownClosed(true);
56
+ setIsInputFocused(false)
57
+ }
58
+ };
59
+ window.addEventListener("click", handleClickOutside);
60
+ return () => {
61
+ window.removeEventListener("click", handleClickOutside);
62
+ };
63
+ }, []);
64
+
65
+
66
+ const handleChange = (e: any) => {
67
+ setFilterItem(e.target.value);
68
+ setIsDropDownClosed(false);
69
+ };
70
+
71
+ const handleOptionClick = (selectedItem: GenericObject) => {
72
+ setSelected(selectedItem);
73
+ setFilterItem("");
74
+ setIsDropDownClosed(true);
75
+ onSelect(selectedItem);
76
+ };
77
+
78
+
79
+ const handleWrapperClick = () => {
80
+ inputRef.current.focus();
81
+ toggleDropdown();
82
+ };
83
+
84
+ const handleBackspace = () => {
85
+ setSelected({})
86
+ onSelect(null)
87
+ setFocusedOptionIndex(-1)
88
+ }
89
+
90
+ const filteredOptions = options?.filter((option: GenericObject) =>
91
+ option.label.toLowerCase().includes(filterItem.toLowerCase())
92
+ );
93
+
94
+ return (
95
+ <div
96
+ {...ariaProps}
97
+ {...dataProps}
98
+ className={classes}
99
+ id={id}
100
+ >
101
+ <DropdownContext.Provider
102
+ value={{
103
+ filteredOptions,
104
+ filterItem,
105
+ focusedOptionIndex,
106
+ handleBackspace,
107
+ handleChange,
108
+ handleOptionClick,
109
+ handleWrapperClick,
110
+ inputRef,
111
+ isInputFocused,
112
+ options,
113
+ selected,
114
+ setFocusedOptionIndex,
115
+ setIsInputFocused,
116
+ setSelected,
117
+ isDropDownClosed,
118
+ setIsDropDownClosed,
119
+ toggleDropdown
120
+
121
+ }}
122
+ >
123
+ <div className="dropdown_wrapper"
124
+ ref={dropdownRef}
125
+ >
126
+ {children ? (
127
+ children
128
+ ) : (
129
+ <>
130
+ <DropdownTrigger />
131
+ <DropdownContainer>
132
+ {options && options?.map((option: GenericObject) => (
133
+ <Dropdown.Option key={option.id}
134
+ option={option}
135
+ >
136
+ <Body text={option.label}/>
137
+ </Dropdown.Option>
138
+ ))}
139
+ </DropdownContainer>
140
+ </>
141
+ )}
142
+ </div>
143
+ </DropdownContext.Provider>
144
+ </div>
145
+ )
146
+ }
147
+
148
+ Dropdown.Option = DropdownOption;
149
+ Dropdown.Trigger = DropdownTrigger;
150
+ Dropdown.Container = DropdownContainer;
151
+
152
+ export default Dropdown
@@ -0,0 +1,5 @@
1
+ import { createContext } from "react";
2
+
3
+ const DropdownContext = createContext<any>({});
4
+
5
+ export default DropdownContext;
@@ -0,0 +1,53 @@
1
+ import React, { useState } from 'react'
2
+ import { Dropdown } from '../../'
3
+
4
+ const DropdownDefault = (props) => {
5
+ // eslint-disable-next-line no-unused-vars
6
+ const [selectedOption, setSelectedOption] = useState();
7
+
8
+ const options = [
9
+ {
10
+ label: "United States",
11
+ value: "United States",
12
+ areaCode: "+1",
13
+ icon: "πŸ‡ΊπŸ‡Έ",
14
+ id: "United-states"
15
+ },
16
+ {
17
+ label: "Ukraine",
18
+ value: "Ukraine",
19
+ areaCode: "+380",
20
+ icon: "πŸ‡ΊπŸ‡¦",
21
+ id: "ukraine"
22
+ },
23
+ {
24
+ label: "Pakistan",
25
+ value: "Pakistan",
26
+ areaCode: "+92",
27
+ icon: "πŸ‡΅πŸ‡°",
28
+ id: "pakistan"
29
+ }
30
+ ];
31
+
32
+
33
+ return (
34
+ <div>
35
+ <Dropdown
36
+ onSelect={(selectedItem) => setSelectedOption(selectedItem)}
37
+ options={options}
38
+ {...props}
39
+ >
40
+ <Dropdown.Trigger/>
41
+ <Dropdown.Container>
42
+ {options.map((option) => (
43
+ <Dropdown.Option key={option.id}
44
+ option={option}
45
+ />
46
+ ))}
47
+ </Dropdown.Container>
48
+ </Dropdown>
49
+ </div>
50
+ )
51
+ }
52
+
53
+ export default DropdownDefault
@@ -0,0 +1,104 @@
1
+ import React, { useState } from 'react'
2
+ import { Dropdown, User, FlexItem, Badge, Avatar } from '../../'
3
+
4
+ const DropdownWithCustomDisplay = (props) => {
5
+ const [selectedOption, setSelectedOption] = useState();
6
+
7
+ const options = [
8
+ {
9
+ label: "Jasper Furniss",
10
+ value: "Jasper Furniss",
11
+ territory: "PHL",
12
+ title: "Senior UX Engineer",
13
+ id: "jasper-furniss",
14
+ status: "Offline"
15
+ },
16
+ {
17
+ label: "Ramon Ruiz",
18
+ value: "Ramon Ruiz",
19
+ territory: "PHL",
20
+ title: "Senior UX Desinger",
21
+ id: "ramon-ruiz",
22
+ status: "Away"
23
+ },
24
+ {
25
+ label: "Jason Cypret",
26
+ value: "Jason Cypret",
27
+ territory: "PHL",
28
+ title: "VP of User Experience",
29
+ id: "jason-cypret",
30
+ status: "Online"
31
+ },
32
+ {
33
+ label: "Courtney Long",
34
+ value: "Courtney Long",
35
+ territory: "PHL",
36
+ title: "UX Design Mentor",
37
+ id: "courtney-long",
38
+ status: "Online"
39
+ }
40
+ ];
41
+
42
+ const customDisplay = () => {
43
+ return (
44
+ <>
45
+ {
46
+ selectedOption && (
47
+ <Avatar
48
+ name={selectedOption.label}
49
+ size="sm"
50
+ />
51
+ )
52
+ }
53
+ </>
54
+ )
55
+ };
56
+
57
+
58
+ return (
59
+ <div>
60
+ <Dropdown
61
+ onSelect={(selectedItem) => setSelectedOption(selectedItem)}
62
+ options={options}
63
+ {...props}
64
+ >
65
+ <Dropdown.Trigger customDisplay={customDisplay()}/>
66
+ <Dropdown.Container>
67
+ {options.map((option) => (
68
+ <Dropdown.Option key={option.id}
69
+ option={option}
70
+ >
71
+ <>
72
+ <FlexItem>
73
+ <User
74
+ align="left"
75
+ avatar
76
+ name={option.label}
77
+ orientation="horizontal"
78
+ territory={option.territory}
79
+ title={option.title}
80
+ />
81
+ </FlexItem>
82
+ <FlexItem>
83
+ <Badge
84
+ rounded
85
+ text={option.status}
86
+ variant={`${
87
+ option.status === "Offline"
88
+ ? "neutral"
89
+ : option.status === "Online"
90
+ ? "success"
91
+ : "warning"
92
+ }`}
93
+ />
94
+ </FlexItem>
95
+ </>
96
+ </Dropdown.Option>
97
+ ))}
98
+ </Dropdown.Container>
99
+ </Dropdown>
100
+ </div>
101
+ )
102
+ }
103
+
104
+ export default DropdownWithCustomDisplay