Skip to content

Commit

Permalink
add support for all properties for taginput and table
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Mar 3, 2024
1 parent 129db75 commit e18004c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="streamfy",
version="0.1.4",
version="0.1.5",
author="",
author_email="",
description="",
Expand Down
25 changes: 19 additions & 6 deletions streamfy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,30 @@
_component_func = components.declare_component(
"streamfy", path=build_dir)

def taginput(data=[], placeholder="", label="", key=None):
component_value = _component_func(component="taginput", label=label, data=data, placeholder=placeholder, key=key)
def hyphen_case(string):
string = string.replace('_', '-')
return string

def hyphen_case_keys(args):
snaked = {}
for key, value in args.items():
new_key = hyphen_case(key)
snaked[new_key] = value
return snaked

def taginput(**kwargs):
hyphened = hyphen_case_keys(kwargs)
component_value = _component_func(component="taginput", **hyphened)
return component_value

def table(data=[], columns=[], label="", key=None):
component_value = _component_func(component="table", label=label, data=data, columns=columns)
def table(**kwargs):
hyphened = hyphen_case_keys(kwargs)
component_value = _component_func(component="table", **hyphened)
return component_value

if not _RELEASE:
st.subheader("Tags")
tags = taginput(data = ["A", "B", "C"], placeholder = "Choose letter")
tags = taginput(data=["A", "B", "C"], placeholder="Choose letter")
st.write(tags)
st.subheader("Table")
columns = [
Expand All @@ -45,4 +58,4 @@ def table(data=[], columns=[], label="", key=None):
{ 'id': 1, 'name': 'Jesse' },
{ 'id': 2, 'first_name': 'John' },
]
table(data = data, columns = columns)
table(data=data, columns=columns, paginated=True)
6 changes: 3 additions & 3 deletions streamfy/frontend/src/Streamfy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
</b-taginput>
<b-table
v-else-if="args.component == 'table'"
:data="args.data"
:columns="args.columns"
:mobile-cards="args['has_mobile_cards'] != undefined ? args['has_mobile_cards'] : false">
v-bind="args"
:mobile-cards="args['has_mobile_cards'] != undefined ? args['has_mobile_cards'] : false"
>
</b-table>
</b-field>
</span>
Expand Down

0 comments on commit e18004c

Please sign in to comment.