-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a divider param to st.header & st.subheader, takes a str (supported colors: “blue”, “green”, “orange”, “red”, “violet”, “gray”/"grey", or “rainbow”) or bool. If divider=True, the divider color will cycle through selected options (blue -> green -> orange -> red -> violet -> blue ...)
- Loading branch information
1 parent
7902bfd
commit 9c91b7d
Showing
74 changed files
with
503 additions
and
98 deletions.
There are no files selected for viewing
Binary file added
BIN
+3.9 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-0[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
+5.36 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-0[firefox].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
+3.72 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-0[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
+3.99 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-1[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
+5.5 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-1[firefox].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
+3.81 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-1[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
+5.35 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-2[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
+6.66 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-2[firefox].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
+5.09 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-2[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
+3.64 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-3[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
+5.27 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-3[firefox].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
+3.44 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-3[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
+4.53 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-4[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
+6.09 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-4[firefox].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
+4.32 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-4[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
+4.77 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-5[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
+5.69 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-5[firefox].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
+4.49 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-5[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
+6.49 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-6[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
+7.02 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-6[firefox].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
+5.67 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-6[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
+4.33 KB
...ywright/snapshots/linux/st_headings_divider_test/header-divider-7[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
+5.77 KB
...aywright/snapshots/linux/st_headings_divider_test/header-divider-7[firefox].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
+4.15 KB
...laywright/snapshots/linux/st_headings_divider_test/header-divider-7[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
+4.12 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-10[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
+5.1 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-10[firefox].png
Oops, something went wrong.
Binary file added
BIN
+3.97 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-10[webkit].png
Oops, something went wrong.
Binary file added
BIN
+2.77 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-11[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.14 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-11[firefox].png
Oops, something went wrong.
Binary file added
BIN
+2.72 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-11[webkit].png
Oops, something went wrong.
Binary file added
BIN
+3.46 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-12[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.63 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-12[firefox].png
Oops, something went wrong.
Binary file added
BIN
+3.38 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-12[webkit].png
Oops, something went wrong.
Binary file added
BIN
+3.65 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-13[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.54 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-13[firefox].png
Oops, something went wrong.
Binary file added
BIN
+3.56 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-13[webkit].png
Oops, something went wrong.
Binary file added
BIN
+5.1 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-14[chromium].png
Oops, something went wrong.
Binary file added
BIN
+5.57 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-14[firefox].png
Oops, something went wrong.
Binary file added
BIN
+4.52 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-14[webkit].png
Oops, something went wrong.
Binary file added
BIN
+3.34 KB
...ght/snapshots/linux/st_headings_divider_test/subheader-divider-15[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.48 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-15[firefox].png
Oops, something went wrong.
Binary file added
BIN
+3.26 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-15[webkit].png
Oops, something went wrong.
Binary file added
BIN
+3.03 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-8[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.09 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-8[firefox].png
Oops, something went wrong.
Binary file added
BIN
+2.9 KB
...wright/snapshots/linux/st_headings_divider_test/subheader-divider-8[webkit].png
Oops, something went wrong.
Binary file added
BIN
+3.07 KB
...ight/snapshots/linux/st_headings_divider_test/subheader-divider-9[chromium].png
Oops, something went wrong.
Binary file added
BIN
+4.28 KB
...right/snapshots/linux/st_headings_divider_test/subheader-divider-9[firefox].png
Oops, something went wrong.
Binary file added
BIN
+3.03 KB
...wright/snapshots/linux/st_headings_divider_test/subheader-divider-9[webkit].png
Oops, something went wrong.
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,66 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# 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. | ||
|
||
import streamlit as st | ||
|
||
# Headers with specified colors | ||
st.header("Blue Divider:", divider="blue") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Green Divider:", divider="green") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Orange Divider:", divider="orange") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Red Divider:", divider="red") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Violet Divider:", divider="violet") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Gray Divider:", divider="gray") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Rainbow Divider:", divider="rainbow") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Grey Divider:", divider="grey") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
|
||
# Subheaders with specified colors | ||
st.subheader("Blue Divider:", divider="blue") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Green Divider:", divider="green") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Orange Divider:", divider="orange") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Red Divider:", divider="red") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Violet Divider:", divider="violet") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Gray Divider:", divider="gray") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Rainbow Divider:", divider="rainbow") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Grey Divider:", divider="grey") | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") |
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,38 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# 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 playwright.sync_api import Page, expect | ||
|
||
from conftest import ImageCompareFunction | ||
|
||
|
||
def test_header_display(app: Page, assert_snapshot: ImageCompareFunction): | ||
"""Test that st.header renders correctly with dividers.""" | ||
header_elements = app.locator(".stHeadingContainer") | ||
expect(header_elements).to_have_count(16) | ||
|
||
for i, element in enumerate(header_elements.all()): | ||
if i < 8: | ||
assert_snapshot(element, name=f"header-divider-{i}") | ||
|
||
|
||
def test_subheader_display(app: Page, assert_snapshot: ImageCompareFunction): | ||
"""Test that st.subheader renders correctly with dividers.""" | ||
subheader_elements = app.locator(".stHeadingContainer") | ||
expect(subheader_elements).to_have_count(16) | ||
|
||
for i, element in enumerate(subheader_elements.all()): | ||
if i > 7: | ||
assert_snapshot(element, name=f"subheader-divider-{i}") |
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,34 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# 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. | ||
|
||
import streamlit as st | ||
|
||
# Headers/Subheaders should cycle through selected colors when set to True | ||
st.header("Blue Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Green Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Orange Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Red Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.header("Violet Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") | ||
|
||
st.subheader("Blue Divider:", divider=True) | ||
st.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit") |
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,32 @@ | ||
/** | ||
* Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
* | ||
* 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. | ||
*/ | ||
|
||
describe("st.header & st.subheader dividers", () => { | ||
before(() => { | ||
cy.loadApp("http://localhost:3000/"); | ||
}); | ||
|
||
it("displays correctly when divider=True", () => { | ||
cy.get(".element-container .stMarkdown h2").should("have.length", 3); | ||
cy.get(".element-container .stMarkdown h3").should("have.length", 3); | ||
cy.get(".stHeadingContainer").should("have.length", 6) | ||
|
||
const expectedColors = [ "blue", "green", "orange", "red", "violet", "blue"] | ||
expectedColors.forEach( (color, idx) => { | ||
cy.getIndexed(".stHeadingContainer", idx).matchThemedSnapshots(`divider-${color}${idx}`) | ||
}) | ||
}); | ||
}); |
Binary file added
BIN
+4.43 KB
...press/snapshots/linux/2x/st_heading_divider.spec.js/divider-blue0-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+4.4 KB
...nd/cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-blue0.snap.png
Oops, something went wrong.
Binary file added
BIN
+3.56 KB
...press/snapshots/linux/2x/st_heading_divider.spec.js/divider-blue5-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+3.56 KB
...nd/cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-blue5.snap.png
Oops, something went wrong.
Binary file added
BIN
+4.04 KB
...ress/snapshots/linux/2x/st_heading_divider.spec.js/divider-green1-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+4.06 KB
...d/cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-green1.snap.png
Oops, something went wrong.
Binary file added
BIN
+6.14 KB
...ess/snapshots/linux/2x/st_heading_divider.spec.js/divider-orange2-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+6.09 KB
.../cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-orange2.snap.png
Oops, something went wrong.
Binary file added
BIN
+3.62 KB
...ypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-red3-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+3.6 KB
...end/cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-red3.snap.png
Oops, something went wrong.
Binary file added
BIN
+5.27 KB
...ess/snapshots/linux/2x/st_heading_divider.spec.js/divider-violet4-dark.snap.png
Oops, something went wrong.
Binary file added
BIN
+5.24 KB
.../cypress/snapshots/linux/2x/st_heading_divider.spec.js/divider-violet4.snap.png
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
frontend/lib/src/components/elements/Spinner/__snapshots__/Spinner.test.tsx.snap
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Spinner component renders without crashing 1`] = `"<div class=\\"css-yprxax-StyledSpinnerContainer e1se5lgy0\\"><i class=\\"css-55asu9-ThemedStyledSpinner e1se5lgy1 \\"></i><div data-testid=\\"stMarkdownContainer\\" class=\\"css-1cwy3ln-StyledStreamlitMarkdown e1nzilvr4\\"><p>Loading...</p></div></div>"`; | ||
exports[`Spinner component renders without crashing 1`] = `"<div class=\\"css-yprxax-StyledSpinnerContainer e1se5lgy0\\"><i class=\\"css-55asu9-ThemedStyledSpinner e1se5lgy1 \\"></i><div data-testid=\\"stMarkdownContainer\\" class=\\"css-1cwy3ln-StyledStreamlitMarkdown e1nzilvr5\\"><p>Loading...</p></div></div>"`; |
Oops, something went wrong.