Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gap param to st.columns #4887

Merged
merged 9 commits into from Jul 7, 2022
Merged

Conversation

mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented Jun 23, 2022

馃摎 Context

This PR adds a keyword-only argument gap to st.columns to allow users additional layout flexibility.

  • What kind of change does this PR introduce?
    • Refactoring

馃 Description of Changes

  • Add gap as keyword only param to st.columns & validate input one of None, "small", "medium", or "large"

  • Pass gap to Horizontal & Column messages in Block.proto

  • Add gap as prop to StyledHorizontalBlock & StyledColumn

  • Set gap CSS property in StyledHorizontalBlock based on user-specified gap size

  • Adjust width CSS property in StyledColumn based on user-specified gap size

    • This is NOT a breaking API change - using keyword param & new default (small) gap is equal to the current gap size
    • This is a visible (user-facing) change

Revised:

  • Small Gap (Default) = 1rem

Screen Shot 2022-06-30 at 1 58 12 PM

  • Medium Gap = 2rem

Screen Shot 2022-06-30 at 1 58 18 PM

  • Large Gap = 4rem

Screen Shot 2022-06-30 at 1 58 24 PM

Current:

  • Standard Gap = 1rem

Screen Shot 2022-06-30 at 2 02 32 PM

馃И Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@mayagbarnes mayagbarnes marked this pull request as ready for review July 1, 2022 16:42
@mayagbarnes mayagbarnes requested a review from a team July 1, 2022 16:42
}

export const StyledColumn = styled.div<StyledColumnProps>(
({ weight, theme }) => {
({ weight, gap, theme }) => {
const percentage = weight * 100
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: both the HorizontalBlock (parent element) and each of the StyledColumns need to be aware of the specified gap

@@ -30,4 +30,5 @@ export const spacing = {
xl: "1.25rem",
twoXL: "1.5rem",
threeXL: "2rem",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure if I should add the new rem specification for large gap (4 rem) to the theme's spacing object... Can remove this if its unnecessary.

@kajarenc
Copy link
Collaborator

kajarenc commented Jul 4, 2022

LGTM 馃憤

@mayagbarnes mayagbarnes merged commit 3809637 into streamlit:develop Jul 7, 2022
@mayagbarnes mayagbarnes deleted the specify-gap branch July 7, 2022 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants