Skip to content

Commit

Permalink
add support for breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Mar 3, 2024
1 parent e18004c commit 3eaadd7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 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.5",
version="0.1.6",
author="",
author_email="",
description="",
Expand Down
12 changes: 11 additions & 1 deletion streamfy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ def table(**kwargs):
component_value = _component_func(component="table", **hyphened)
return component_value

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

if not _RELEASE:
st.subheader("Breadcrumb")
item = breadcrumb(items=[{"text": "A"}, {"text": "B"}])
st.write(item)

st.subheader("Tags")
tags = taginput(data=["A", "B", "C"], placeholder="Choose letter")
tags = taginput(data=["A", "B", "C"], allow_new=True, open_on_focus=True, type="is-info", aria_close_label="Remove", placeholder="Choose letter")
st.write(tags)

st.subheader("Table")
columns = [
{
Expand Down
43 changes: 27 additions & 16 deletions streamfy/frontend/src/Streamfy.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
<template>
<span>
<b-field ref="tagField" :label="label">
<b-field ref="field" :label="label">
<b-breadcrumb
v-if="args.component == 'breadcrumb' && args.items != undefined"
>
<b-breadcrumb-item
v-for="item in args.items"
:key="item.text"
v-bind="item"
tag="router-link"
to="#"
@click="click(item.text)"
>{{item.text}}
</b-breadcrumb-item>
</b-breadcrumb>
<b-taginput
v-if="args.component == 'taginput'"
v-else-if="args.component == 'taginput'"
v-model="tags"
:data="args.data"
autocomplete
:allow-new="true"
:open-on-focus="true"
type="is-info"
:placeholder="args.placeholder"
aria-close-label="Remove"
v-bind="args"
@focus="focused"
@blur="blured">
@blur="blured"
>
</b-taginput>
<b-table
v-else-if="args.component == 'table'"
v-bind="args"
:mobile-cards="args['has_mobile_cards'] != undefined ? args['has_mobile_cards'] : false"
>
>
</b-table>
</b-field>
</span>
Expand All @@ -40,8 +48,8 @@ export default {
},
methods: {
focused() {
if (this.tagField) {
const menu = this.tagField.$el.querySelector('.dropdown-menu');
if (this.field) {
const menu = this.field.$el.querySelector('.dropdown-menu');
menu.style.bottom = 'auto';
}
Expand All @@ -50,7 +58,10 @@ export default {
},
blured() {
setTimeout(() => Streamlit.setFrameHeight(), 200);
}
},
click(value) {
Streamlit.setComponentValue(value)
},
},
watch: {
tags() {
Expand All @@ -60,10 +71,10 @@ export default {
setup() {
useStreamlit()
const tagField = ref(null);
const field = ref(null);
return {
tagField,
field,
}
},
}
Expand Down

0 comments on commit 3eaadd7

Please sign in to comment.