Skip to content

Block.tsx refactor#4053

Merged
tvst merged 20 commits intostreamlit:developfrom
tvst:block-refactor
Dec 5, 2021
Merged

Block.tsx refactor#4053
tvst merged 20 commits intostreamlit:developfrom
tvst:block-refactor

Conversation

@tvst
Copy link
Copy Markdown
Contributor

@tvst tvst commented Nov 10, 2021

📚 Context

Many months ago, I was working on visual updates for Streamlit and found that Block.tsx needed a little cleaning up. I proposed this on Slack and was OKed to pursue it. At the time, I sent out an early PR to show the work I was talking about #3583 , but never finished it. So this is me finally doing the last bit of work on that.

  • What kind of change does this PR introduce?

    • Bugfix
    • Feature
    • Refactoring
    • Other, please describe:

🧠 Description of Changes

  • This is mostly a refactor of Block.tsx into several React components, rather than 1 component plus several bespoke functions. This way we end up with a more canonical React-style code, with better use of React's DOM diffing, no need to pass keys around, and (I think!) much easier to read.

  • This also makes it so we only ever need an <AutoSizer> component when we have a <VerticalBlock>, because that's the only kind of component that holds Streamlit elements directly (and elements are the only things that need to know their widths, so they need the autosizer).

  • This also cleans up the way we used to insert vertical padding between consecutive elements in an app. This vertical space used to live all over the place (forms, expandable, containers, blocks) but now it's been unified to only live at StyledVerticalBlock.

  • Finally, this removes a stray parenthesis in ThemedApp.tsx

    • This is a breaking API change
    • This is a visible (user-facing) change

Revised:

Insert screenshot of your updated UI/code here

Current:

Insert screenshot of existing UI/code here

🧪 Testing Done

  • [N/A] Screenshots included
  • Added/Updated unit tests
  • [N/A] Added/Updated e2e tests

🌐 References

Does this depend on other work, documents, or tickets?
Nope.


Contribution License Agreement

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

@tvst tvst requested a review from tconkling November 10, 2021 23:17
@tvst tvst changed the title Block refactor Block.tsx refactor Nov 10, 2021
@tvst
Copy link
Copy Markdown
Contributor Author

tvst commented Nov 15, 2021

BTW, I'm working on the failing tests.

Copy link
Copy Markdown
Contributor

@tconkling tconkling left a comment

Choose a reason for hiding this comment

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

I love this change!

@tvst
Copy link
Copy Markdown
Contributor Author

tvst commented Nov 16, 2021

I still have some tests to fix, but PTAL at the unresolved comment above and LMKWYT!

The changes are grouped here:
https://github.com/streamlit/streamlit/pull/4053/files/3c887e86db3431aa9f31afc84e651d485dd80f86..a5024ee01dfe4ba46ae7f9dfecf28d1052ec19ed

...though it maybe be easier to just read the commits above, as they're pretty well isolated.

@tconkling
Copy link
Copy Markdown
Contributor

I still have some tests to fix, but PTAL at the unresolved comment above and LMKWYT!

The changes are grouped here: https://github.com/streamlit/streamlit/pull/4053/files/3c887e86db3431aa9f31afc84e651d485dd80f86..a5024ee01dfe4ba46ae7f9dfecf28d1052ec19ed

...though it maybe be easier to just read the commits above, as they're pretty well isolated.

Sweet, all looks good to me!

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 24, 2021

CLA assistant check
All committers have signed the CLA.

@tvst
Copy link
Copy Markdown
Contributor Author

tvst commented Nov 29, 2021

@tconkling : I have no idea how to update these Custom Component tests... I tried locally but they fail and it's unclear why. Is there a trick for these?

(I also don't know why they're failing when I didn't touch them anything related to them! Perhaps they were never updated to the latest fonts a few months ago?)

@tconkling
Copy link
Copy Markdown
Contributor

I'll take a look. I don't think it's an issue with tests not being properly updated in the past, because other CircleCI runs are succeeding on these tests. I wonder if perhaps some CSS changes in this PR are affecting something about the component iframe's frame?

@tvst
Copy link
Copy Markdown
Contributor Author

tvst commented Dec 5, 2021

YES!!!! All tests pass! Merging before Cypress changes its mind.

@tvst tvst merged commit 161368a into streamlit:develop Dec 5, 2021
@tvst tvst deleted the block-refactor branch December 5, 2021 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants