-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: st.toast #6783
Feature: st.toast #6783
Conversation
frontend/src/app/App.tsx
Outdated
@@ -1565,6 +1565,8 @@ export class App extends PureComponent<Props, State> { | |||
value={{ | |||
initialSidebarState, | |||
wideMode: userSettings.wideMode, | |||
toastAdjustment: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When host is Community Cloud, toolbar items are sent - this is used as a proxy to check whether toast position should be moved up not to interfere with their Manage App
button
|
||
if TYPE_CHECKING: | ||
from streamlit.delta_generator import DeltaGenerator | ||
from streamlit.type_util import SupportsStr | ||
|
||
|
||
def validate_emoji(maybe_emoji: Optional[str]) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved function to string_util.py
so it can be shared with toast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Most of my comments are nits, but I'll probably want to take a second pass at this later given the length of the PR + app/lib split. I'm guessing this should be easy to do since this PR will likely be open awhile while waiting for QA.
It'd also be good to have @tconkling sanity check this for the app/lib split implications since I'm not yet entirely confident in my ability to reason about what should live where, but nothing stuck out to me about how everything is organized.
frontend/src/lib/components/shared/StreamlitMarkdown/StreamlitMarkdown.tsx
Outdated
Show resolved
Hide resolved
frontend/src/lib/components/shared/StreamlitMarkdown/StreamlitMarkdown.tsx
Outdated
Show resolved
Hide resolved
frontend/src/lib/components/shared/StreamlitMarkdown/styled-components.ts
Outdated
Show resolved
Hide resolved
width: "288px", | ||
marginTop: "8px", | ||
borderRadius: "4px", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be nice to move these into the theme object if there are reasonable places to put them (same comment for a few other magic values in this file + throughout the PR)
Hi @mayagbarnes, I'm just working on the docs and just FYI I'm getting a nit warning on line 28 about using streamlit/lib/streamlit/elements/toast.py Line 28 in 867ece0
Cheers! |
@mayagbarnes we had a late request in office hours today to conform better with other APIs and name the first parameter I'm very sorry for missing this earlier!! If it's a big effort to change or otherwise warrants further discussion, let me know, happy to do it. |
ef04922
to
ad0761c
Compare
51507df
to
948a0f2
Compare
948a0f2
to
f7dbee6
Compare
* develop: Feature: st.toast (streamlit#6783) Bump semver from 5.7.1 to 5.7.2 in /frontend (streamlit#6982) Add host communication e2e tests (streamlit#6806) Re-add homepage to package.json (streamlit#6987) Remove unnecessary code and Add rm commands to make clean (streamlit#6980) Allow setting placeholder for st.selectbox (streamlit#6913) Allow setting placeholder for st.multiselect (streamlit#6901) Also use bottom padding in embedded mode for chat input (streamlit#6979) Feature/st lib (streamlit#6692) Remove unused import (streamlit#6977) Release 1.24.1 (streamlit#6965) Update st.audio/st.video docstrings (streamlit#6964) Slightly simplify bug report template (streamlit#6972) Fix baseweb warnings by using longhand properties (streamlit#6976)
Adds a new widget for notification toasts using st.toast - covers the use case for notifications that don't disrupt the flow/organization of the existing app. This is distinct from the existing st.warning, st.error, st.success & st.info, which are inline. NOTE: This PR also creates a new event rendering construct in an effort to distinguish events from persistent elements like widgets. The path is as follows: - new RootContainer constant -> EVENT - lib/streamlit/__init__.py -> toast mapped to event.toast vs. other methods on main - AppView.tsx has a new EventContainer that uses existing renderBlock method that takes in event elements
Adds a new widget for notification toasts using st.toast - covers the use case for notifications that don't disrupt the flow/organization of the existing app. This is distinct from the existing st.warning, st.error, st.success & st.info, which are inline. NOTE: This PR also creates a new event rendering construct in an effort to distinguish events from persistent elements like widgets. The path is as follows: - new RootContainer constant -> EVENT - lib/streamlit/__init__.py -> toast mapped to event.toast vs. other methods on main - AppView.tsx has a new EventContainer that uses existing renderBlock method that takes in event elements
Adds a new widget for notification toasts using st.toast - covers the use case for notifications that don't disrupt the flow/organization of the existing app. This is distinct from the existing st.warning, st.error, st.success & st.info, which are inline. NOTE: This PR also creates a new event rendering construct in an effort to distinguish events from persistent elements like widgets. The path is as follows: - new RootContainer constant -> EVENT - lib/streamlit/__init__.py -> toast mapped to event.toast vs. other methods on main - AppView.tsx has a new EventContainer that uses existing renderBlock method that takes in event elements
📚 Context
Adds a new widget for notification toasts using
st.toast
- covers the use case for notifications that don't disrupt the flow/organization of the existing app. This is distinct from the existingst.warning
,st.error
,st.success
&st.info
, which are inline.st.toast
params are as follows:text(str) - Short message for the toast.
icon(None or str) - An optional, keyword-only argument that specifies an emoji to use as the icon for the toast. Shortcodes are not allowed, please use a single character instead. E.g. "🚨", "🔥", "🤖", etc. Defaults to None, which means no icon is displayed.
NOTE: This PR also creates a new
event
rendering construct in an effort to distinguish events from persistent elements like widgets. The path is as follows:lib/streamlit/__init__.py
-> toast mapped to event.toast vs. other methods on mainAppView.tsx
has a new EventContainer that uses existingrenderBlock
method that takes in event elements🧪 Testing Done
🌐 References