Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update native filter dividers to support horizontal display #21970

Closed
wants to merge 10 commits into from

Conversation

codyml
Copy link
Member

@codyml codyml commented Oct 29, 2022

SUMMARY

This PR updates native filter dividers to display correctly when native filters are rendered as a horizontal bar, which will be supported in a future PR. In this PR, the divider is factored out into its own component, FilterDivider, which now supports three view modes:

  • Vertical: Same as current; displays full title and full description, if set.
  • Horizontal: Displays title, subject to truncation. If title is truncated or if there is a description set, an icon appears with a tooltip showing the full title (if truncated) and/or the description (if set).
  • Horizontal overflow: Displays title and description, if set, both subject to truncation. Hovering over truncated description or title will show full text.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Vertical (same as before):
Screen Shot 2022-10-28 at 4 27 49 PM

Horizontal:
Screen Shot 2022-10-28 at 4 27 59 PM
Screen Shot 2022-10-28 at 4 28 09 PM
Screen Shot 2022-10-28 at 4 28 26 PM
Screen Shot 2022-10-28 at 4 28 37 PM

Horizontal overflow:
Screen Shot 2022-10-28 at 4 28 44 PM
Screen Shot 2022-10-28 at 4 28 56 PM
Screen Shot 2022-10-28 at 4 29 10 PM

TESTING INSTRUCTIONS

  • Check that current native filters dividers look and work the same as they currently do.
  • Run Storybook locally off of this PR and open the FilterDivider component, which should contain Vertical Filter Divider, Horizontal Filter Divider, and Horizontal Overflow Filter Divider. Check that all three behave as expected with:
    • Short title
    • Long title
    • No description
    • Short description
    • Long description

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Oct 29, 2022

Codecov Report

Merging #21970 (89fde38) into master (72598a5) will increase coverage by 0.01%.
The diff coverage is 71.23%.

❗ Current head 89fde38 differs from pull request most recent head 3d175ff. Consider uploading reports for the commit 3d175ff to get more accurate results

@@            Coverage Diff             @@
##           master   #21970      +/-   ##
==========================================
+ Coverage   65.72%   65.74%   +0.01%     
==========================================
  Files        1809     1811       +2     
  Lines       69335    69370      +35     
  Branches     7413     7425      +12     
==========================================
+ Hits        45571    45606      +35     
  Misses      21853    21853              
  Partials     1911     1911              
Flag Coverage Δ
javascript 53.45% <71.23%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ilters/FilterBar/FilterControls/FilterControls.tsx 70.58% <ø> (ø)
...c/hooks/useTruncation/useChildElementTruncation.ts 44.73% <44.73%> (ø)
...Filters/FilterBar/FilterControls/FilterDivider.tsx 100.00% <100.00%> (ø)
...nd/src/hooks/useTruncation/useCSSTextTruncation.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

title: string;
description: string;
horizontal?: boolean;
horizontalOverflow?: boolean;
Copy link
Member

@zhaoyongjie zhaoyongjie Oct 31, 2022

Choose a reason for hiding this comment

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

@codyml I'm curious whether the verticalOverflow might be in the future. If it is, should we use props like overflow to control this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, changed horizontalOverflow to overflow in case we want to support that in the future. Since the styles are unique, another option is that I could have an orientation field that accepts constants for each supported orientation (vertical, horizontal, horizontal overflow) and we could add a 4th constant if we end up wanting to support vertical overflow dropdown – let me know if that sounds better.

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

Thanks for the awesome work! Just a few nits from a first look

horizontalOverflow?: boolean;
}

const useIsTruncated = <T extends HTMLElement>(
Copy link
Member

Choose a reason for hiding this comment

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

I saw this hook being used in at least 3 more places in the app. We should move this to the common hooks if possible. In a separate PR we can then go back and replace it everywhere else

Copy link
Member Author

@codyml codyml Nov 1, 2022

Choose a reason for hiding this comment

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

Looks like there's an useTruncation hook already in src/hooks, but it's for the separate use-case of multiple child elements with element truncation controlled by JS, rather than one element with text truncation controlled by CSS. I kept the default export of useTruncation the element version and added a new export of useCSSTextTruncation – does that seem like a good solution?

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 14px;
Copy link
Member

Choose a reason for hiding this comment

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

We should use the provided typography settings in the theme

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

data-test="divider-description-icon"
css={(theme: SupersetTheme) => css`
color: ${theme.colors.grayscale.base};
font-size: 16px;
Copy link
Member

Choose a reason for hiding this comment

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

Icons have a property iconSize with predefined sizes. We should stick to those whenever possible.

Copy link
Member Author

@codyml codyml Nov 1, 2022

Choose a reason for hiding this comment

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

Done! Also moved color to iconColor.

text-overflow: ellipsis;
color: ${theme.colors.grayscale.dark1};
font-weight: normal;
font-size: 14px;
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about font-size as above

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 12px;
Copy link
Member

Choose a reason for hiding this comment

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

This too

@pull-request-size pull-request-size bot added size/XL and removed size/L labels Nov 1, 2022
@codyml
Copy link
Member Author

codyml commented Nov 19, 2022

Closing in favor of #22169.

@codyml codyml closed this Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants