Skip to content

Migrate Modal to Baseweb#1930

Merged
kmcgrady merged 11 commits intostreamlit:developfrom
kmcgrady:modal-1862
Sep 3, 2020
Merged

Migrate Modal to Baseweb#1930
kmcgrady merged 11 commits intostreamlit:developfrom
kmcgrady:modal-1862

Conversation

@kmcgrady
Copy link
Copy Markdown
Collaborator

@kmcgrady kmcgrady commented Aug 27, 2020

Issue: #1862

Description:
Migrate Modal from Reactstrap to Baseweb

Before
about_modal_before
After
about_modal_after
Before
cache_modal_before
After
cache_modal_after
Modal needed a header to make things look consistent and work visually.
Before
screencast_modal_before
After
screencast_modal_after
Before
screencast_unsupported_modal_before
After
screencast_unsupported_modal_after
Before
script_execution_error_modal_before
After
script_execution_error_modal_after
Before
settings_modal_before
After
settings_modal_after
Before
snapshot_modal_before
After
snapshot_modal_after
Before
connection_error_before
After
connection_error_after
Before
video_recorded_modal_before
After
video_recorded_modal_after
Made the modal a little wider


Contribution License Agreement

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

@kmcgrady kmcgrady requested a review from a team August 27, 2020 19:47
@tvst
Copy link
Copy Markdown
Contributor

tvst commented Aug 28, 2020

Is it possible to make the style more closely match the original?

See comments on the image:
image

This text is getting too close to the X:
image

If I record a screencast then stop recording via the menu, I get the recorded file dialog but it's huuuuuge:
(it's hard to tell from this screenshot because the dialog is the entire screen. But you can tell by looking at the top of the screen and noticing that the dialog header is there)
image

This progressbar looks wrong too:
image

And for some reason the "Copy to clipboard" button is not vertically aligned with the other ones. It's a couple of pixels off:
image

Edit: actually it's apparently using the old Bootstrap button:
image

Also:

  • If I record a screencast then press Esc to stop recording, I don't see the dialog that shows the recorded file. My guess is the dialog is handling the Esc event prematurely and closing.
  • Buttons are missing the "active" state. They should turn pink when clicked.
  • Checkboxes should be pink when checked
  • Checkbox focus ring should be pink, not black
  • Not sure if from this PR, but the menu item focus ring should be pink (right now it's black, but I don't remember it existing at all in the past...)

@tvst
Copy link
Copy Markdown
Contributor

tvst commented Aug 28, 2020

Out of all of these, the most important ones are:

  1. Make sure all the colors match our theme
  2. Make sure the Modal title is aligned with the X button
  3. Make sure the Copy to Clipboard button uses Baseweb
  4. Fix screencast Esc issue

As for border radii, lines, sizes, etc, those are less important. If they're hard to do, we can probably skip (need to see it live!)

@karriebear karriebear self-requested a review August 28, 2020 05:55
Copy link
Copy Markdown
Contributor

@karriebear karriebear left a comment

Choose a reason for hiding this comment

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

Here's some initial comments on the components. I assume the styles will get updated based on product comments and can take a look at the styling after

export enum Kind {
PRIMARY = "primary",
SECONDARY = "secondary",
}
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.

Curious why we have this? BaseUI's KIND enum has these + 2 more and in Modal.tsx we're using both enums

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is more a precursor to the Button migration and preparation for a design system. We talked about this for the Alert conversion to have our own enum instead of using BaseWeb. I was migrating the same stuff. Since we only use two versions, I didn't add more, but we can certainly in the future

const primary = SCSS_VARS.$primary
const primaryA50 = SCSS_VARS["$primary-a50"]
const textMargin = SCSS_VARS["$font-size-sm"]
const white = SCSS_VARS.$white
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.

It could just be my preference but I didn't like doing this so I made the colors from widgetTheme exportable. If you pull in latest you can use that instead of reassigning values here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Awesome. Will use

function ModalHeader({ children }: ModalHeaderProps): ReactElement {
return (
<UIModalHeader>
<span className="ModalTitle">{children}</span>
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.

According to our styleguide, we like camelCasing though that could all change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Awesome. I'll make the change to conform for now.

},
}

const buttonKind = isPrimary ? KIND.primary : KIND.tertiary
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.

Not sure if it's me but using tertiary here seems weird 🤷‍♀️ probably because I don't think we have a tertiary style in our brand. I think we can probably leave it and then when we do a whole design pass through, we can clean it up.

More of a FYI, the default minimal button kind matches tertiary. Not sure if that makes it better or worse but I'm using minimal for some fun icon buttons

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.

Wasn't sure where this goes (this comment or the one above). I think this is weird with the future proofing we're in the process of but I could live with this in the meantime. Linking to #1860?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That sounds reasonable. I chose tertiary, cause visually it matches what we are looking for.


function ModalButton({
children,
kind,
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.

Should we change this to isPrimary? It seems we don't actually care what kind of button, only if it's primary or not. Knowing that we overwrite this if it's not primary makes it odd when you declare a different kind of button like here

Or perhaps the thing to do is to update the buttonSecondary colors so that when we say we want secondary, we get secondary.

Sorry a lot of comment overlap between here and 👇 ☝️

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I guess I was future proofing it to support multiple kinds. Baseweb supports 4 kinds, and we may want to support all 4 as well. In addition, I think if we use ModalButton as essentially a Button with that margin update, I'd like their interface to be the same.

@karriebear
Copy link
Copy Markdown
Contributor

karriebear commented Sep 3, 2020

This looks to also fixes #1740

Copy link
Copy Markdown
Contributor

@karriebear karriebear 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. Can't wait to see everything transitioned over!

The only comment that gives me some concern is the one regarding class nesting for VideoRecordedDialog but not sure how that ties into the overall styling work that's going to happen. Risk of an issue arising in the meantime is pretty low.


// The c key clears the cache.
c: (): void => this.openClearCacheDialog(),
CLEAR_CACHE: (): void => this.openClearCacheDialog(),
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.

not annoying enough since keyMap is right above but the comments could be updated as well. more of a nice to have

},
}

const buttonKind = isPrimary ? KIND.primary : KIND.tertiary
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.

Wasn't sure where this goes (this comment or the one above). I think this is weird with the future proofing we're in the process of but I could live with this in the meantime. Linking to #1860?


@import "src/assets/css/theme";

.streamlit-dialog.screencast {
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 this is the right move? While this is imported specifically in the VideoRecordedDialog component, this still gets compiled into a css file for the page. It does not look like we do [the fancy webpack term] with dynamic loading. With this change, these styles would then get applied to all other modal bodies. While most of them either make sense globally or is random enough, .download-button could be problematic in the future. If we do prefer this to ax the .streamlit-dialog.screencast parent, I would vote to move this into our assets folder instead for future developers to not go wondering why does my download-button have a margin-top though whole other topic you'll be addressing :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oh. you're probably right. Let me relook into this.

* 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.
*/
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 think we can ax this file? 50% of this looks like it's covered in our body default, BaseWeb's theme and/or JS. Given that we're doing styling in JS also, can we standardize one way or the other? Fine to leave as is if this is a transitional state.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. That's easy to address.

}
.first-column,
.second-column,
.third-columnd {
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.

sorry missed this on the first pass but also it's been like this so not sure if fixing the typo will actually cause more grief or not... the component itself does not have the typo so i guess we've been living without some y padding 🤷

Suggested change
.third-columnd {
.third-column {

@tvst
Copy link
Copy Markdown
Contributor

tvst commented Sep 3, 2020

Looks amazing!

Some final comments, no need to do another product pass once fixed:

  • The modal body sometimes overflows
    image

  • The horizontal padding of the dialog body should match the one used in the title. (i.e. the title padding is the correct one)
    image

  • Just curious: how come we're not using Styletron for styling these components? And why not use BaseWeb's themeing system, for that matter?

@kmcgrady
Copy link
Copy Markdown
Collaborator Author

kmcgrady commented Sep 3, 2020

Thanks @tvst ! Modals do not have any theme variables. I think Buttons may have some, and we do use some, but we have a rich override set that does most of the work.

In terms of Styletron, we are actually overriding the styles of these components, which is the only available way to override these. I think we haven't committed to a styled component engine. The truth is while Baseweb is great, I do not think we see a long term future in it. We do a lot of overrides that make the work more brittle. It's an open discussion though, so we didn't put much effort using it right now. If that changes, that will fall under the conforming to the style guide part of the project.

@kmcgrady kmcgrady merged commit 41948f4 into streamlit:develop Sep 3, 2020
@kmcgrady kmcgrady deleted the modal-1862 branch September 3, 2020 23:33
tconkling added a commit to tconkling/streamlit that referenced this pull request Sep 8, 2020
* develop:
  Migrate Modal to Baseweb (streamlit#1930)
  Update bl dependency to resolve CVE (streamlit#1965)
  Force reinstall of setuptools to 49.6.0 (streamlit#1962)
  ComponentInstance unit tests (streamlit#1956)
  Update change log
  Fix alignment of `.. output::` command in st.write() (streamlit#1955)
  Fix alignment of `.. output::` command in st.write() (streamlit#1955)
  Add spacing to slider docs
  Up version to 0.66.0
  Switch statement to include ArrowTable (streamlit#1951)
  Remove st.write from unsupported in sidebar (streamlit#1952)
  Remove st.write from unsupported in sidebar (streamlit#1952)
  Switch statement to include ArrowTable (streamlit#1951)
  Add deprecation label to st.deck_gl_chart (streamlit#1943)
  Pin setuptools to <= 49.6.0 (streamlit#1944)
  DuplicateWidgetID error message should surface widget name (streamlit#1942)
  Set z-index of balloons to 1000000 to allow it to display over other elements. (streamlit#1934)
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