Skip to content

Conversation

@tvst
Copy link
Contributor

@tvst tvst commented Aug 2, 2021

Except for some updates to how tables/dataframes look, everything else could even go unnoticed by distracted viewers.

If you're on Notion, you can find a wheel file here

Changes

  • New fonts!
    • We also no longer ship fonts with Streamlit, but use fallbacks instead.
  • New font sizes and weights for headers
  • New table and dataframe design
  • Numbers in Arrow tables are right-aligned, and everything else if left-aligned
  • Tooltip now has same color as background
  • No more Streamlit pink. Now we use Streamlit red. Pink was marked as deprecated in our Brand page for a while, and this is just the last nail!
  • Arrow Table now also aligns number-typed columns to the right (like Arrow DataFrame)
  • Unified all small fonts to the same size (we used to have two sizes of small font, for some reason, and they were just ~1px off from each other)
  • Make anchor/fullscreen/copy-to-clipboard floating icons use the same colors and animation. Also, improve the animation a bit!
  • Make st.text and st.json use normal-size font (instead of small)
  • Make vega-lite charts use small font (instead of an extremely tiny font it was using before)
  • Make code syntax highlighting match our brand colors (tested on light and dark theme. Some small issues with legibility, but no worse than today)
  • Checkbox in Settings page uses Streamlit colors
  • Tooltip uses small text
  • Tooltip padding for status area matches tooltip padding elsewhere
  • Make it so when a widget doesn't have a label we don't add the empty label to the DOM.
    • This fixes a problem with the settings page, where the selectbox had a bunch of padding above it because it had no label.
    • Tim touched on this a few months ago, and I verified that my change continues to address the original bug correctly (by trying the bug's toy example)

tvst added 30 commits July 13, 2021 00:49
- Use "Source * Pro" fonts
- No longer ship fonts with Streamlit, but use fallback instead.
- Update header sizes and weights
- Update text color
- Update table and dataframe designs
- Make tooltip follow bg color
)}
</StyledWidgetLabel>
) : null}
<WidgetLabel visible={!!label}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed help from here. No other widget did this, really, and it can only impact our own usage of Radio anyway since label is never falsy when coming from the Python side.

Plus we don't actually use Radio ourselves, and if we ever do we shouldn't have the combination of no label + help, as that would be visually strange.

Copy link
Collaborator

@kmcgrady kmcgrady left a comment

Choose a reason for hiding this comment

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

Found two bugs that exist today in my pass, and have a few questions/thoughts.

621858C6-7635-4C0A-BCF2-692AE77A813B

I see an issue with the dataframe ellipsis.

href="https://fonts.googleapis.com/css2?family=Source+Serif+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet"
/>

Copy link
Collaborator

Choose a reason for hiding this comment

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

This essentially prevents people from working with streamlit locally without an internet connection right? Should we be merging this into the codebase as font files?

// 1rem == 16px
// (Can't set actual pixels here because it breaks reboot)
$font-size-base: 1rem;
$font-size-base: 17px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Concerned about the comment removed that says can't set actual pixels here because it breaks reboot?

I say this because we often want the number to be highly divisible. It makes the REM to px computation more predictable.

"& .table-top-right": {
overflowX: "hidden",
backgroundColor: theme.colors.secondaryBg,
overflow: "hidden !important",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmmm. I don't think we are using !important properly here. What's accidentally overriding it?

borderBottom: `1px solid ${theme.colors.fadedText10}`,
borderRight: `1px solid ${theme.colors.fadedText10}`,
fontSize: theme.fontSizes.md,
fontFamily: theme.fonts.sansSerif,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be theme.genericFonts.bodyFont to be themeable?

textAlign: "right",
padding: theme.spacing.sm,
fontSize: theme.fontSizes.md,
fontFamily: theme.fonts.sansSerif,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. theme.genericFonts.bodyFont ?

paddingBottom: 0,
paddingTop: 0,
marginBottom: 0,
marginTop: 0,
lineHeight: 1.25,
marginTop: "0 !important",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious where you see the !important needed here? Is this not being respected here?

@@ -105,6 +109,36 @@ export const StyledHr = styled.hr(({ theme }) => ({

export const StyledCheckbox = styled.input(({ theme }) => ({
marginRight: theme.spacing.xs,
appearance: "none",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a big deal, but are we essentially looking to align these to the checkbox widget? It's close but we might be able to make that better.

@@ -44,7 +44,11 @@ export function ArrowTable(props: TableProps): ReactElement {
<StyledTableContainer data-testid="stTable">
{cssStyles && <style>{cssStyles}</style>}
<StyledTable id={cssId}>
{caption && <caption>{caption}</caption>}
{caption && (
<caption>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason we don't just use a styled component for StyledCaption. I think this would be a misuse of the small tag for accessibility reasons.

In HTML5 it is acceptable to use the tag to denote things like disclaimers, caveats, legal restrictions, or copyrights

@@ -197,7 +197,7 @@ class Multiselect extends React.PureComponent<Props, State> {

return (
<div className="row-widget stMultiSelect" style={style}>
<StyledWidgetLabel>
<WidgetLabel visible={!!element.label}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember we had issues with vertical alignment for elements that had a label and those that don't. This should be addressed.

425491A8-4C0D-4756-81B9-0BE7ABDAE78E

Current release:

B01158E3-2684-47C4-B508-F81460E2FAE5

md: "1rem",
lg: "1.25rem",
xl: "1.5rem",
twoXL: "1.75rem",
threeXL: "2.25rem",
fourXL: "3.125rem",

smNoUnits: 14, // 0.823rem with $font-size-base=17px
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really it's 13.991, right? I'm a little nervous at all this complex number of pixels. They present off rounding values that could make weird appearances.

Comment on lines +114 to +115
width: theme.fontSizes.md,
height: theme.fontSizes.md,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be theme.spacing.md?

return (
<div className="stTimeInput" style={style}>
<StyledWidgetLabel>
<WidgetLabel visible={!!element.label}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think it's a rare use case, but it is possible for a widget coming from Python to have a falsy label since the empty string is falsy in JS.

It also seems like there's at least a bit of contention around what the right behavior here is. Some users don't want the extra padding (#3603), but it was originally intentionally added to ensure that widget alignment is consistent even for widgets with no label (#3071).

@kinghuang
Copy link
Contributor

I see that this MR switches the fonts from IBM Plex * to Source * Pro. I've been using IBM Plex Sans Condensed heavily in my custom components to display high density text (#3588).

Is there any chance Streamlit can choose a font family that has a condensed font? The Source * Pro family doesn't have a condensed variant.

@tvst
Copy link
Contributor Author

tvst commented Aug 9, 2021

Closing this and breaking into multiple PRs, as requested offline.

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.

4 participants