Skip to content

Commit 60589be

Browse files
committed
Add always_show_buttons option
Option to show buttons (add rule, etc.) even when they are not hovered.
1 parent 219f994 commit 60589be

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ st.write(return_val)
101101
```python
102102
def condition_tree(
103103
config: dict,
104-
return_type: str,
105-
tree: dict,
106-
min_height: int,
107-
placeholder: str,
108-
key: str
104+
return_type: str [Optional],
105+
tree: dict [Optional],
106+
min_height: int [Optional],
107+
placeholder: str [Optional],
108+
always_show_buttons: bool [Optional],
109+
key: str [Optional]
109110
)
110111
```
111112

@@ -144,6 +145,11 @@ and [demo](https://ukrbublik.github.io/react-awesome-query-builder/).
144145
Default : None
145146

146147

148+
- **always_show_buttons**: Show buttons (create rule, etc.) even when they are not hovered
149+
150+
Default: False
151+
152+
147153
- **key**: Fixed identity if you want to change its arguments over time and not have it be re-created.
148154
Can also be used to access the generated condition tree (see section below).
149155

streamlit_condition_tree/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def condition_tree(config: dict,
5757
tree: dict = None,
5858
min_height: int = 400,
5959
placeholder: str = '',
60+
always_show_buttons: bool = False,
6061
key: str = None):
6162
"""Create a new instance of condition_tree.
6263
@@ -79,6 +80,9 @@ def condition_tree(config: dict,
7980
placeholder: str
8081
Text displayed when the condition tree is empty
8182
Default: empty
83+
always_show_buttons: false
84+
If false, buttons (add rule, etc.) will be shown only on hover
85+
Default: true
8286
key: str or None
8387
An optional key that uniquely identifies this component. If this is
8488
None, and the component's arguments are changed, the component will
@@ -109,6 +113,7 @@ def condition_tree(config: dict,
109113
key='_' + key if key else None,
110114
min_height=min_height,
111115
placeholder=placeholder,
116+
always_show_buttons=always_show_buttons,
112117
default=['', '']
113118
)
114119

streamlit_condition_tree/frontend/src/ConditionTree.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class ConditionTree extends StreamlitComponentBase<State> {
146146

147147
private renderBuilder = (props: BuilderProps) => (
148148
<div className="query-builder-container">
149-
<div className="query-builder qb-lite">
149+
<div className={'query-builder '+
150+
(this.props.args['always_show_buttons'] ? '':'qb-lite')}>
150151
<Builder {...props} />
151152
</div>
152153
</div>

0 commit comments

Comments
 (0)