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

fix: Coalesce UI filtering menus #4972

Merged
merged 3 commits into from Feb 2, 2021
Merged

fix: Coalesce UI filtering menus #4972

merged 3 commits into from Feb 2, 2021

Conversation

simster7
Copy link
Member

@simster7 simster7 commented Jan 29, 2021

Fixes #4969

WIP. Menus are now coalesced but no good unified UX yet, testing different options

Signed-off-by: Simon Behar simbeh7@gmail.com

Checklist:

Signed-off-by: Simon Behar <simbeh7@gmail.com>
@alexec
Copy link
Contributor

alexec commented Jan 29, 2021

Could I suggest something a bit bigger than the drop-down - you have to scroll the drop-down which discourages usage.

What about a bespoke floating panel, like this:

image

@alexec
Copy link
Contributor

alexec commented Jan 29, 2021

Tippy might work for this.

@simster7
Copy link
Member Author

Yep, was chatting with Remington about some ideas and we considered this as well

Signed-off-by: Simon Behar <simbeh7@gmail.com>
@simster7
Copy link
Member Author

simster7 commented Feb 1, 2021

Current view

image

image

@simster7 simster7 marked this pull request as ready for review February 1, 2021 16:57
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

it seems to me that this combine two things

  • drop-down
  • floating panel

Can you separate them please?

@alexec alexec self-assigned this Feb 1, 2021
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

See comment.

@simster7
Copy link
Member Author

simster7 commented Feb 2, 2021

it seems to me that this combine two things

drop-down
floating panel

Can you separate them please?

Sorry, don't think I know what you mean. Could you clarify please?

@simster7
Copy link
Member Author

simster7 commented Feb 2, 2021

@alexec

@alexec
Copy link
Contributor

alexec commented Feb 2, 2021

Sorry, don't think I know what you mean. Could you clarify please?

Single responsibility principle. Rather than write a component that must do both jobs - pop-over + drop-down - write one component for the pop-over and another for the drop-down.

@simster7
Copy link
Member Author

simster7 commented Feb 2, 2021

Single responsibility principle. Rather than write a component that must do both jobs - pop-over + drop-down - write one component for the pop-over and another for the drop-down.

Understood, thanks!

Copy link
Member Author

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

Hey @alexec, I took another look at the code after reading your message on Slack and I do see that the "filtering" and the "dropdown" aspects of the code are separated (see comments). Let me know what you think and if you think I'm still misunderstanding the change you want.

className={classNames('argo-dropdown__content', {'opened': this.state.opened, 'is-menu': this.props.isMenu})}
style={{top: this.state.top, left: this.state.left}}
ref={el => (this.content = el)}>
{children}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is where we display the "filter" part of the code. This function does not make any assumptions about the content of children (which comes from props.children): The code in this function is only concerned with displaying the drop down menu and has no code regarding the actual list to be filtered.

Comment on lines +26 to +46
<ul>
{props.sections
.filter(item => item.values)
.map((item, i) => (
<div key={i}>
<li className={classNames('top-bar__filter-item', {title: true})}>
<span>{item.title}</span>
</li>
{Object.entries(item.values)
.sort()
.map(([label, checked]) => (
<li className={classNames('top-bar__filter-item')}>
<React.Fragment>
<Checkbox id={`filter__${label}`} checked={checked} onChange={v => item.onChange(label, v)} />
<label htmlFor={`filter__${label}`}>{label}</label>
</React.Fragment>
</li>
))}
</div>
))}
</ul>
Copy link
Member Author

@simster7 simster7 Feb 2, 2021

Choose a reason for hiding this comment

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

This is where we display the "filtering" aspect. It is passed as an argument (through props.children) to DropDown. None of the code here (even the code that deals with onChange) is known/used/needed by DropDown, it is simply passed through and displayed.

onChange: (label: string, checked: boolean) => void;
}

export const FilterDropDown = (props: FilterDropDownProps) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This component is called FilterDropDown, but since it uses the abstract DropDown and adds filtering to it as content, I think it's a fair name.

@simster7 simster7 merged commit ccd669e into argoproj:master Feb 2, 2021
@simster7 simster7 mentioned this pull request Feb 8, 2021
38 tasks
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.

Two identical filter widgets that do different things
3 participants