forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Utilize new fullscreen Toolbar for st.{map|pydeck_chart} (stre…
…amlit#9501) ## Describe your changes - Utilizes the new fullscreen Toolbar from dataframes for `st.map` and `st.pydeck_chart` Dark mode: <img width="735" alt="Screenshot 2024-09-18 at 3 10 52 PM" src="https://github.com/user-attachments/assets/b5b5fe07-e6b6-4867-ba74-098a148ea51e"> Light mode: <img width="739" alt="Screenshot 2024-09-18 at 3 11 03 PM" src="https://github.com/user-attachments/assets/b54a0c3f-33cb-4a8d-92e1-fc3a96793bfb"> When in fullscreen: <img width="1507" alt="Screenshot 2024-09-18 at 3 14 56 PM" src="https://github.com/user-attachments/assets/629aa07e-c07f-41c6-94fd-381065d78ac3"> ## GitHub Issue Link (if applicable) ## Testing Plan - Explanation of why no additional tests are needed - Unit Tests (JS and/or Python) - E2E Tests ✅ Added tests + reusable helper function - Any manual testing needed? ✅ Manually tested --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
- Loading branch information
1 parent
810d50b
commit 7913ce5
Showing
14 changed files
with
138 additions
and
30 deletions.
There are no files selected for viewing
Binary file added
BIN
+114 KB
...right/__snapshots__/linux/st_map_test/st_map-fullscreen_collapsed[chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+114 KB
...ywright/__snapshots__/linux/st_map_test/st_map-fullscreen_collapsed[webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+163 KB
...wright/__snapshots__/linux/st_map_test/st_map-fullscreen_expanded[chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+166 KB
...aywright/__snapshots__/linux/st_map_test/st_map-fullscreen_expanded[webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+114 KB
..._/linux/st_pydeck_chart_test/st_pydeck_chart-fullscreen_collapsed[chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+114 KB
...s__/linux/st_pydeck_chart_test/st_pydeck_chart-fullscreen_collapsed[webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+163 KB
...__/linux/st_pydeck_chart_test/st_pydeck_chart-fullscreen_expanded[chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+166 KB
...ts__/linux/st_pydeck_chart_test/st_pydeck_chart-fullscreen_expanded[webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
if TYPE_CHECKING: | ||
from e2e_playwright.conftest import ImageCompareFunction | ||
|
||
|
||
def assert_fullscreen_toolbar_button_interactions( | ||
app: Page, | ||
assert_snapshot: ImageCompareFunction, | ||
widget_test_id: str, | ||
filename_prefix: str = "", | ||
nth: int = 0, | ||
pixel_threshold: float = 0.05, | ||
): | ||
""" | ||
Shared test function to assert that clicking on fullscreen toolbar button | ||
expands the map into fullscreen. | ||
""" | ||
|
||
widget_element = app.get_by_test_id(widget_test_id).nth(nth) | ||
widget_toolbar = widget_element.get_by_test_id("stElementToolbar") | ||
fullscreen_wrapper = app.get_by_test_id("stFullScreenFrame").nth(nth) | ||
|
||
fullscreen_toolbar_button = widget_toolbar.get_by_test_id( | ||
"stElementToolbarButton" | ||
).last | ||
|
||
# Activate toolbar: | ||
widget_element.hover() | ||
# Check that it is visible | ||
expect(widget_toolbar).to_have_css("opacity", "1") | ||
|
||
# Click on expand to fullscreen button: | ||
fullscreen_toolbar_button.click() | ||
|
||
# Check that it is visible | ||
assert_snapshot( | ||
fullscreen_wrapper, | ||
name=f"{filename_prefix if filename_prefix != "" else widget_test_id}-fullscreen_expanded", | ||
pixel_threshold=pixel_threshold, | ||
) | ||
|
||
# Click again on fullscreen button to close fullscreen mode: | ||
fullscreen_toolbar_button.click() | ||
assert_snapshot( | ||
fullscreen_wrapper, | ||
name=f"{filename_prefix if filename_prefix != "" else widget_test_id}-fullscreen_collapsed", | ||
pixel_threshold=pixel_threshold, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters