playbook_ui_docs 14.20.0.pre.rc.0 → 14.20.0.pre.rc.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff2d019b5abd6484c31d09bc6ca745b354d5121f9e7462be866214da1c3231dd
4
- data.tar.gz: 2c29674f75161acb7770a03ac2dc2bfcdda0fa5803cec3a30230717f71518d90
3
+ metadata.gz: 0c0461f51db06ad404a1a56e785dd3c5ad04191d05abdcf9f02086ab4d6aa753
4
+ data.tar.gz: d2ffd749f0e102fb3e4585d9e636e8c375b635e44c399a06edf68cd7dd261a50
5
5
  SHA512:
6
- metadata.gz: d20ca232588c4ae79da0cab06e132a3458fdbdd2c8e772705da120464217af4b42e1419f2c546c6dd2a819fd8082bc7c8a7a9b47aeecc5f66a6dc0d52a8fe980
7
- data.tar.gz: 9e074e2fbd029f9e86bff6cd7e0c9916663c8f911914df3222689f79b72a2dde002a7d0b39573c7ef72df3db13a08f240bcb2e0c75cbebbd5258e064b45af94f
6
+ metadata.gz: 2302b4ee2951ea5b1fc254ef086d2f48987aa02504210ce8fcab594ce141a9e576483154ca6140e1e9da820cc4f8060e88b1a8357b0043eca837cfb2dff3a2d4
7
+ data.tar.gz: c45f6d809e4b047dd972da4ff3ce6ce3d22833387d9d4928769ee6bdafd354f94e5d16b1162df6ce57f27aed99ddb1ef2995b494aafdbda1fcdd1dce64610ba3
@@ -6,6 +6,7 @@ import Flex from '../../pb_flex/_flex'
6
6
  import FlexItem from '../../pb_flex/_flex_item'
7
7
  import Avatar from '../../pb_avatar/_avatar'
8
8
  import User from '../../pb_user/_user'
9
+ import Body from '../../pb_body/_body'
9
10
 
10
11
  const DropdownWithCustomDisplay = (props) => {
11
12
  const [selectedOption, setSelectedOption] = useState();
@@ -50,10 +51,20 @@ const DropdownWithCustomDisplay = (props) => {
50
51
  <>
51
52
  {
52
53
  selectedOption && (
54
+ <Flex align="center">
53
55
  <Avatar
54
56
  name={selectedOption.label}
55
57
  size="xs"
56
58
  />
59
+ <Body
60
+ marginX="xs"
61
+ text={selectedOption.label}
62
+ />
63
+ <Badge
64
+ text={selectedOption.status}
65
+ variant={selectedOption.status == "Offline" ? "neutral" : selectedOption.status == "Online" ? "success" : "warning"}
66
+ />
67
+ </Flex>
57
68
  )
58
69
  }
59
70
  </>
@@ -1,4 +1,4 @@
1
- Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected. The component passed to customDisplay will be rendered to the left of the default text-based display. In this example the Avatar kit is being used.
1
+ Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `customDisplay` will display as the selected option.
2
2
 
3
3
  The `placeholder` prop can also be used to customize the placeholder text for the default `Dropdown.Trigger`.
4
4
 
@@ -38,7 +38,11 @@
38
38
 
39
39
  <%
40
40
  custom_display = capture do
41
- pb_rails("avatar", props: { name: "Courtney Long", size: "xs" })
41
+ pb_rails("flex", props: { align: "center" }) do
42
+ concat(pb_rails("avatar", props: { name: "", size: "xs", id: "dropdown-avatar" }))
43
+ concat(pb_rails("body", props: { text: "", size: "xs", margin_x: "xs", id: "dropdown-avatar-name" }))
44
+ concat(pb_rails("badge", props: { text: "", id: "dropdown-avatar-status" }))
45
+ end
42
46
  end
43
47
  %>
44
48
 
@@ -62,4 +66,31 @@
62
66
  <% end %>
63
67
  <% end %>
64
68
  <% end %>
65
- <% end %>
69
+ <% end %>
70
+
71
+
72
+ <script>
73
+ document.addEventListener("pb:dropdown:selected", (e) => {
74
+ const option = e.detail;
75
+ const dropdown = e.target;
76
+
77
+ const display = dropdown.querySelector("#dropdown_trigger_custom_display");
78
+ if (!display) return;
79
+
80
+ const nameEl = display.querySelector("#dropdown-avatar-name");
81
+ if (nameEl) nameEl.textContent = option.label;
82
+
83
+ const avatarEl = display.querySelector("#dropdown-avatar").querySelector(".avatar_wrapper");
84
+ const initials = (option.label[0] + option.label.split(" ").pop()[0]).toUpperCase();
85
+ if (avatarEl) {
86
+ avatarEl.dataset.name = option.label;
87
+ avatarEl.setAttribute("data-initials", initials);
88
+ }
89
+ const badgeEl = display.querySelector("#dropdown-avatar-status");
90
+ const variant = option.status === "Online" ? "success" : option.status === "Offline" ? "neutral" : "warning";
91
+ if (badgeEl) {
92
+ badgeEl.querySelector("span").textContent = option.status;
93
+ badgeEl.className = 'pb_badge_kit_' + variant;
94
+ }
95
+ });
96
+ </script>
@@ -1,4 +1,6 @@
1
- Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected. The component passed to custom_display will be rendered to the left of the default text-based display. In this example the Avatar kit is being used.
1
+ Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `custom_display` will display as the selected option.
2
+
3
+ Make use of a script to help set the custom_display with the correct value. By using the pb:dropdown:selected event listener, you can target the kits with a querySelector and update them dynamically with the values needed to match the selected option. Make sure to add an ID to the kits being passed in.
2
4
 
3
5
  The `placeholder` prop can also be used to customize the placeholder text for the default `dropdown/dropdown_trigger`.
4
6