Fullscreen button to expand tables and charts#137
Fullscreen button to expand tables and charts#137dcaminos merged 28 commits intostreamlit:developfrom
Conversation
|
I'm seeing a slight flicker of the button after expanding and resetting. To reproduce try: expand dataframe -> move mouse below chart -> press escape |
frontend/src/components/shared/FullScreenWrapper/FullScreenWrapper.tsx
Outdated
Show resolved
Hide resolved
| table: (el: SimpleElement) => ( | ||
| <FullScreenWrapper width={width}> | ||
| {({ width, height }) => ( | ||
| <Table element={el} width={width} height={height} /> |
There was a problem hiding this comment.
I don't think table is responding to the height property.
There was a problem hiding this comment.
No, and width either, and I don't fixed it because I finded this comment on the code:
@tvst can you clarify this please?
There was a problem hiding this comment.
@tvst can you comment on why table is not handling width or height?
There was a problem hiding this comment.
Tables don't have a height prop. So you should just remove it here.
As for width, I don't really recall what's up with that comment I wrote. The comment is now almost 1 year old, though, so you can't blame me! 😎
There was a problem hiding this comment.
Just tried this out on my machine. It's so awesome 👏
Some comments about the UX:
- Can you add the "expand" button to all types of plots? This means VegaLiteChart.tsx, DeckGlChart.tsx, GraphVizChart.tsx, PlotlyChart.tsx, and BokehChart.tsx
- Can you add the "expand' button to images
and videostoo? ImageList.tsxand Video.tsx. Edit: actually videos already have a fullscreen button. No need to do anything there. - Add a tooltip on the button, that says "View fullscreen" and "Exit fullscreen"
- When I go fullscreen and then rerun the app (by pressing
r), the UI looks weird. I think it's because the fullscreen element is fading away. As a quick fix, can you make elements not fade when fullscreen?
Also, please run make headers to add the Apache header to all new files.
| @@ -0,0 +1,32 @@ | |||
| .streamlit-container .stFullScreenFrame--expanded { | |||
| position: fixed; | |||
| top: 0px; | |||
There was a problem hiding this comment.
Use 0 instead of 0px. Same below.
| overflow: auto; | ||
| background: white; | ||
| z-index: 1000; | ||
| padding: 30px; |
There was a problem hiding this comment.
Can we make this smaller? Like 0.5rem?
(When I do this I still get a huge margin on the right and bottom sides. No idea why.)
| background: white; | ||
| z-index: 1000; | ||
| padding: 30px; | ||
| padding-top: 80px; |
There was a problem hiding this comment.
Use the same value as the header height here. I believe that's 3.5rem (which includes some margin).
Also, please put 3.5rem as a variable in variables.scss and use it in header.scss and here.
| .streamlit-container .stFullScreenFrame .stButton-enter { | ||
| position: absolute; | ||
| right: 10px; | ||
| top: 10px; |
There was a problem hiding this comment.
Look at header.scss and see what we use for the hamburger menu, make it a variable and use it here.
(Also, I think we don't use px as a unit for this things, but I may be mistaken...)
|
@tvst should be better don't re run when you are in fullscreen? "When I go fullscreen and then rerun the app (by pressing r), the UI looks weird. I think it's because the fullscreen element is fading away. As a quick fix, can you make elements not fade when fullscreen?" |
In terms of user experience, I think it's best to allow rerunning when fullscreen. This way you if you have a time-varying script, you can zoom into a chart and keep rerunning the app to focus on how the reruns impact the chart. But if that is too much work to get right (more than an afternoon), then it's OK to disallow it for now. |
… PlotlyChart, BokehChart (now responsive) and ImageList
frontend/src/components/elements/GraphVizChart/GraphVizChart.tsx
Outdated
Show resolved
Hide resolved
| public render = (): React.ReactNode => { | ||
| const width: number = this.props.element.get("width") || this.props.width | ||
|
|
||
| const height: number = |
There was a problem hiding this comment.
Shouldn't this use the same logic as the code block above for // Override or reset the graph height?
There was a problem hiding this comment.
Is the same logic, this.props.element.get("height") have preference
There was a problem hiding this comment.
Above also uses this.originalHeight .. should it be a possible value for height here as well?
|
I just created a branch tweaking the styles for these new buttons to match the "copy" button that shows up when you hover over codeblocks. I also moved the buttons to the right of the elements rather than on top. Please take a look and merge into your branch: |
|
|
||
| interface Props { | ||
| width: number | ||
| height: number | undefined |
There was a problem hiding this comment.
Unrelated to this line but the UI is a bit jumpy when expanding and resetting the graphviz charts (and probably other charts) but it's easy to see with the second chart in e2e/scripts/graphviz_chart.py
There was a problem hiding this comment.
Yes, I agree about graphviz (no others charts). I guess is because D3 update the chart after component did update.
|
|
||
| interface Props { | ||
| width: number | ||
| height: number | undefined |
There was a problem hiding this comment.
- I'm not seeing the expand button on the first 4 vega lite charts in
e2e/scripts/vega_lite_chart.py, only the last 4, is this expected? - The charts expand to fullscreen height but not width, is this expected?
- If you expand a chart, then set the width to 500, then re-run report, the chart will expand to the width but revert it's height. If you set the width before expanding the chart, it expands correctly. Very minor case.
There was a problem hiding this comment.
I'm not seeing the expand button on the first 4 vega lite charts
You are right, there are a bug with the opacity transition, I will try to solve it.
There was a problem hiding this comment.
The charts expand to fullscreen height but not width, is this expected?
That is right, because the user are specifying a width into the script
There was a problem hiding this comment.
If you expand a chart, then set the width to 500, then re-run report, the chart will expand to the width but revert it's height. If you set the width before expanding the chart, it expands correctly. Very minor case.
I will try to solve it
tvst
left a comment
There was a problem hiding this comment.
Looks good to me, after comments are addressed.
But since Jonathan left comments too, I'll let him be the one to click "approve"
| index: number | ||
| } | ||
|
|
||
| const DEFAULT_HEIGHT = 400 |
There was a problem hiding this comment.
Does this mean that when in normal non-fullscreen mode the default height for a Bokeh chart will be 400px? If so, I think we shouldn't do that. Instead, just let Bokeh choose the height of the chart. This way Bokeh charts in Streamlit will work just like Bokeh charts anywhere else.
There was a problem hiding this comment.
Same with the other charts below.
There was a problem hiding this comment.
Before this PR, all Bokeh charts was 600px x 600px. Users must write the chart width and height on python code to set that values.
If we dont set a default, the height will be 600px. We can set the default on 600 or just remove the default value.
There was a problem hiding this comment.
Ah I see. Yeah, I think removing the default makes sense. This way Bokeh decides what to use as default.
Same for other libraries in this PR.
|
|
||
| componentDidMount() { | ||
| this.updateWindowDimensions() | ||
| window.addEventListener("resize", this.updateWindowDimensions) |
frontend/src/components/shared/FullScreenWrapper/FullScreenWrapper.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| updateWindowDimensions = () => { | ||
| this.setState({ | ||
| fullwidth: window.innerWidth - this.convertRemToPixels(1.5), //0.75rem + 0.75rem |
There was a problem hiding this comment.
Where is the 1.5 coming from? If we have it variables.scss then you can get it here with import { SCSS_VARS } from "autogen/scssVariables".
Otherwise, at least add a comment explaining where it comes from. And if there is some CSS file that this needs to be in sync with, add a comment in that file pointing to this.
Same below.
frontend/src/components/shared/FullScreenWrapper/FullScreenWrapper.tsx
Outdated
Show resolved
Hide resolved
frontend/mochawesome.json
Outdated
| @@ -0,0 +1,283 @@ | |||
| { | |||
There was a problem hiding this comment.
Remove file from PR and add to .gitignore
| table: (el: SimpleElement) => ( | ||
| <FullScreenWrapper width={width}> | ||
| {({ width, height }) => ( | ||
| <Table element={el} width={width} height={height} /> |
There was a problem hiding this comment.
@tvst can you comment on why table is not handling width or height?
| public render = (): React.ReactNode => { | ||
| const width: number = this.props.element.get("width") || this.props.width | ||
|
|
||
| const height: number = |
There was a problem hiding this comment.
Above also uses this.originalHeight .. should it be a possible value for height here as well?
|
The expand icon is staying visible on a Vega lite chart after minimizing. It doesn't seem to disappear until you click somewhere off the chart. Is it expected? |
@jrhone I saw it. I'm not sure if this is wrong. Is like a make, like "you was here" But we can talk about this if you want. |
|
@tvst this is the bug I fixed with vega lite charts: |
| spec.width = width | ||
| spec.height = height | ||
| spec.padding = { | ||
| bottom: EMBED_PADDING, |
There was a problem hiding this comment.
Wait, this will override any padding the user adds, right?
There was a problem hiding this comment.
Yes. Can they set a padding when write the chart? I that case, I can use that padding and this should be the default one.
|
@tvst I improved the vega-lite solution to do not override current padding |
tvst
left a comment
There was a problem hiding this comment.
Leaving another partial review, as I haven't looked at everything yet. Will look through it all by tomorrow at noon. Apologies for the delay!
| height={height} | ||
| /> | ||
| )} | ||
| </FullScreenWrapper> |
There was a problem hiding this comment.
Can you move these FullScreenWrappers into each element's component? It would be nice to keep this big switch statement lean.
| table: (el: SimpleElement) => ( | ||
| <FullScreenWrapper width={width}> | ||
| {({ width, height }) => ( | ||
| <Table element={el} width={width} height={height} /> |
There was a problem hiding this comment.
Tables don't have a height prop. So you should just remove it here.
As for width, I don't really recall what's up with that comment I wrote. The comment is now almost 1 year old, though, so you can't blame me! 😎
|
|
||
| return ( | ||
| <div className={`stFullScreenFrame${expanded ? "--expanded" : ""}`}> | ||
| <button |
There was a problem hiding this comment.
Is is possible to use a Reactstrap <Button> component? See the main menu and toolbar button for examples.
There was a problem hiding this comment.
Yes I can, but I based on this button: https://github.com/dcaminos/streamlit/blob/58bd06cee4de0b403dbfff55de8a07aea79dbf4a/frontend/src/components/elements/CodeBlock/CopyButton.tsx#L46
We should create a "OverlayButton" component for both cases (and use Reactstrap), but I don't wanna do it on this PR (it's too big right now)
There was a problem hiding this comment.
Sounds good. Can you create an issue for this?
|
There are some JS warnings, by the way: |
* develop: Fullscreen button to expand tables and charts (streamlit#137) Blacklist for hashing (streamlit#254) Adding utils and tests for hello.py (streamlit#261) Fix port-finding bugs (streamlit#280) Fix hello.py usage of os.path.join on a URL (streamlit#285)


*Added new component FullScreenWrapper