Skip to content

Commit e3c5540

Browse files
AkshatJawnemargaretkennedydsmmcken
authored
docs: ui.contextual_help (#974)
Closes #832 --------- Co-authored-by: margaretkennedy <[email protected]> Co-authored-by: Don <[email protected]>
1 parent 1eecb75 commit e3c5540

File tree

3 files changed

+130
-4
lines changed

3 files changed

+130
-4
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Contextual Help
2+
3+
Contextual help can be used to show extra information about the state of a component.
4+
5+
## Example
6+
7+
For the contextual help component, both the `heading` and `content` props are required.
8+
9+
```python
10+
from deephaven import ui
11+
12+
13+
my_contextual_help_basic = ui.contextual_help(
14+
heading="Need Help",
15+
content="If you are having issues accessing your account, contact our customer support team for help.",
16+
variant="info",
17+
)
18+
```
19+
20+
21+
## Placement
22+
23+
The contextual help component supports different placement options for when the popover's positioning needs to be customized.
24+
25+
```python
26+
from deephaven import ui
27+
28+
29+
@ui.component
30+
def ui_contextual_help_placement_examples():
31+
return [
32+
ui.contextual_help(
33+
heading="Need Help",
34+
content="If you are having issues accessing your account, contact our customer support team for help.",
35+
variant="info",
36+
),
37+
ui.contextual_help(
38+
heading="Need Help",
39+
content="If you are having issues accessing your account, contact our customer support team for help.",
40+
variant="info",
41+
placement="top start",
42+
),
43+
ui.contextual_help(
44+
heading="Need Help",
45+
content="If you are having issues accessing your account, contact our customer support team for help.",
46+
variant="info",
47+
placement="end",
48+
),
49+
]
50+
51+
52+
my_contextual_help_placement_examples = ui_contextual_help_placement_examples()
53+
```
54+
55+
56+
## Events
57+
58+
The `on_open_change` prop is triggered when the popover opens or closes.
59+
60+
```python
61+
from deephaven import ui
62+
63+
64+
@ui.component
65+
def ui_contextual_help_events_example():
66+
is_open, set_is_open = ui.use_state(False)
67+
return [
68+
ui.flex(
69+
ui.contextual_help(
70+
heading="Permission required",
71+
content="Your admin must grant you permission before you can create a segment.",
72+
variant="info",
73+
on_open_change={set_is_open},
74+
),
75+
align_items="center",
76+
)
77+
]
78+
79+
80+
my_contextual_help_events_example = ui_contextual_help_events_example()
81+
```
82+
83+
84+
## Visual Options
85+
86+
The `variant` prop can be set to either "info" or "help", depending on how the contextual help component is meant to help the user.
87+
88+
```python
89+
from deephaven import ui
90+
91+
92+
@ui.component
93+
def ui_contextual_help_variant_examples():
94+
return [
95+
ui.contextual_help(
96+
heading="Permission required",
97+
content="Your admin must grant you permission before you can create a segment.",
98+
variant="info",
99+
),
100+
ui.contextual_help(
101+
heading="What is a segment?",
102+
content="Segments identify who your visitors are, what devices and services they use, where they navigated from, and much more.",
103+
variant="help",
104+
),
105+
]
106+
107+
108+
my_contextual_help_variant_examples = ui_contextual_help_variant_examples()
109+
```
110+
111+
112+
## API reference
113+
114+
```{eval-rst}
115+
.. dhautofunction:: deephaven.ui.contextual_help
116+
```
117+

plugins/ui/docs/sidebar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
"label": "combo_box",
5050
"path": "components/combo_box.md"
5151
},
52+
{
53+
"label": "contextual_help",
54+
"path": "components/contextual_help.md"
55+
},
5256
{
5357
"label": "date_picker",
5458
"path": "components/date_picker.md"

plugins/ui/src/deephaven/ui/components/contextual_help.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def contextual_help(
7777
) -> Element:
7878
"""
7979
A contextual help is a quiet action button that triggers an informational popover.
80+
8081
Args:
8182
heading: The heading of the popover.
8283
content: The content of the popover.
@@ -127,13 +128,17 @@ def contextual_help(
127128
z_index: The stacking order for the element
128129
is_hidden: Hides the element.
129130
id: The unique identifier of the element.
130-
aria-label: Defines a string value that labels the current element.
131-
aria-labelledby: Identifies the element (or elements) that labels the current element.
132-
aria-describedby: Identifies the element (or elements) that describes the object.
133-
aria-details: Identifies the element (or elements) that provide a detailed, extended description for the object.
131+
aria_label: Defines a string value that labels the current element.
132+
aria_labelledby: Identifies the element (or elements) that labels the current element.
133+
aria_describedby: Identifies the element (or elements) that describes the object.
134+
aria_details: Identifies the element (or elements) that provide a detailed, extended description for the object.
134135
UNSAFE_class_name: Set the CSS className for the element. Only use as a last resort. Use style props instead.
135136
UNSAFE_style: Set the inline style for the element. Only use as a last resort. Use style props instead.
136137
key: A unique identifier used by React to render elements in a list.
138+
139+
Returns:
140+
The rendered contextual help component.
141+
137142
"""
138143
return component_element(
139144
"ContextualHelp",

0 commit comments

Comments
 (0)