Skip to content

1159/use_container_width#1174

Merged
arraydude merged 4 commits intostreamlit:developfrom
arraydude:1159/use_container_width
Mar 4, 2020
Merged

1159/use_container_width#1174
arraydude merged 4 commits intostreamlit:developfrom
arraydude:1159/use_container_width

Conversation

@arraydude
Copy link
Copy Markdown
Contributor

@arraydude arraydude commented Mar 2, 2020

Issue: Fixes #1159 #1045


Contribution License Agreement

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

- use_container_width.
- small refactor.
- bugfix: DeckGLChart where not re-rendering if the props changes.
- adding deprecation warning message
@arraydude arraydude requested a review from a team as a code owner March 2, 2020 19:12
@tconkling tconkling self-requested a review March 3, 2020 21:46
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.

Looks good. I left a few nitpicky comments. Also, there are no tests; I can't remember if we have a convention around testing everything that can be marshalled from Python into Protobufs, but it might be worth adding some simple assertions to graphviz_test and deck_gl_test, to make sure that the flag is passed through as expected.

Comment on lines +97 to +109
if (height) {
//fullscreen
json.initialViewState.height = height
json.initialViewState.width = width
} else {
if (!json.initialViewState.height) {
json.initialViewState.height = DEFAULT_DECK_GL_HEIGHT
}

if (useContainerWidth) {
json.initialViewState.width = width
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If height == null && !useContainerWidth, then initialViewState.width won't be set. Is that intentional? Can you add a comment just explaining why initialViewState.height/width are not always set? (Are they already set in the JSON and this is just overriding them?)


json.initialViewState.height = height
json.initialViewState.width = width
if (height) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I think this if (height) would be better expressed either as a getter called this.isFullscreen(), or maybe just a local variable called isFullscreen that does the same, with documentation. It's very non-obvious (and easy to miss) why height being defined means that the chart is fullscreen.

pitch: number
bearing: number
zoom: number
state = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if there's a Streamlit convention around this or not, but I think since the rest of this function uses public/private access modifiers, state and componentDidMount() should be explicitly marked as private.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm getting a type error if I put those in private

TS2415: Class 'DeckGlJsonChart' incorrectly extends base class 'PureComponent<PropsWithHeight, State, any>'.   Property 'componentDidUpdate' is private in type 'DeckGlJsonChart' but not in type 'PureComponent<PropsWithHeight, State, any>'.

TS2415: Class 'DeckGlJsonChart' incorrectly extends base class 'PureComponent<PropsWithHeight, State, any>'.   Property 'state' is private in type 'DeckGlJsonChart' but not in type 'PureComponent<PropsWithHeight, State, any>'.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My mistake; I didn't check the subclass visibility. My point was that we should use visibility modifiers consistently, so if these need to be public, then they should be explicitly marked as such.

@arraydude arraydude merged commit 5280072 into streamlit:develop Mar 4, 2020
@arraydude arraydude deleted the 1159/use_container_width branch March 4, 2020 15:37
sthagen added a commit to sthagen/streamlit-streamlit that referenced this pull request Mar 5, 2020
tconkling added a commit to tconkling/streamlit that referenced this pull request Mar 9, 2020
* develop:
  Unpin python-dateutil package version (streamlit#1153)
  Pypi nightly builds (streamlit#1171)
  Adding custom filterOptions function to SelectBox (streamlit#1182)
  Expire media files when ReportSession expires (streamlit#1128)
  1159/use_container_width (streamlit#1174)
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.

Some elements don't have use_container_width

2 participants