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(ui): the toolbox became vertical #2014

Merged
merged 36 commits into from
Apr 25, 2022
Merged

feat(ui): the toolbox became vertical #2014

merged 36 commits into from
Apr 25, 2022

Conversation

neSpecc
Copy link
Member

@neSpecc neSpecc commented Apr 7, 2022

This PR is the second part of the big UI update called "Unified Toolbox". See the Roadmap for more details.

In this iteration, the Toolbox became a vertical list.

image

image

Changelog

  • the Popover utility has been created. It will be used for all vertical lists.
  • the Toolbox now uses the Popover to display the tools list
  • the Plus button will be always shown (previously, it appears only for empty blocks)

image


Also, see the Discussion #1811


Thanks to @TatianaFomina for finishing the PR so fast.

neSpecc and others added 11 commits January 13, 2022 20:45
* FIx mobile popover fixed positioning

* Add mobile popover overlay

* Hide mobile popover on scroll

* Alter toolbox buttons hover

* Fix closing popover on overlay click

* Tests fix

* Fix onchange test

* restore focus after toolbox closing by ESC

* don't move toolbar by block-hover on mobile

Resolves #1972

* popover mobile styles improved

* Cleanup

* Remove scroll event listener

* Lock scroll on mobile

* don't show shortcuts in mobile popover

* Change data attr name

* Remove unused styles

* Remove unused listeners

* disable hover on mobile popover

* Scroll fix

* Lint

* Revert "Scroll fix"

This reverts commit 82deae5.

* Return back background color for active state of toolbox buttons

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Comment on lines 275 to 276
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

Why ts-ignore here?

Comment on lines 517 to 519
if (_.isMobile()) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we just do not subscribe on mobile?

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

Comment on lines 105 to 111
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
if (!Element.prototype.scrollIntoViewIfNeeded) {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded): void {
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
Copy link
Member

Choose a reason for hiding this comment

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

You can extends Element interface to avoid ts-ignore here

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed


this.addTools();
this.enableFlipper();
this.popover.on(PopoverEvent.OverlayClicked, () => {
Copy link
Member

Choose a reason for hiding this comment

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

Do we unsubscribe somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

/**
* True if screen has mobile size
*/
export function isMobile(): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to rename the function as it doesn't return what expected. Something like isNarrowScreen

Copy link
Contributor

Choose a reason for hiding this comment

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

renamed to isMobileScreen

Comment on lines +120 to +133
popover: 'ce-popover',
popoverOpened: 'ce-popover--opened',
itemsWrapper: 'ce-popover__items',
item: 'ce-popover__item',
itemHidden: 'ce-popover__item--hidden',
itemFocused: 'ce-popover__item--focused',
itemLabel: 'ce-popover__item-label',
itemIcon: 'ce-popover__item-icon',
itemSecondaryLabel: 'ce-popover__item-secondary-label',
noFoundMessage: 'ce-popover__no-found',
noFoundMessageShown: 'ce-popover__no-found--shown',
popoverOverlay: 'ce-popover__overlay',
popoverOverlayHidden: 'ce-popover__overlay--hidden',
documentScrollLocked: 'ce-scroll-locked',
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 really think of using css modules

Copy link
Member Author

@neSpecc neSpecc Apr 19, 2022

Choose a reason for hiding this comment

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

We will, at some of the next updates

private createItem(item: PopoverItem): HTMLElement {
const el = Dom.make('div', Popover.CSS.item);

el.setAttribute('data-item-name', item.name);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
el.setAttribute('data-item-name', item.name);
el.dataset.itemName = item.name;

src/components/utils/search-input.ts Show resolved Hide resolved
@@ -0,0 +1,46 @@
img, video, audio, canvas, input,
Copy link
Member

Choose a reason for hiding this comment

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

Not encapsulated selectors

Copy link
Member

Choose a reason for hiding this comment

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

Still relevant

Copy link
Contributor

Choose a reason for hiding this comment

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

removed these lines

* Replace visibility property with display for hiding popover

* Disable arrow right and left keys for popover

* Revert "Replace visibility property with display for hiding popover"

This reverts commit af521cf.

* Hide popover via setting max-height to 0 to fix animation in safari

* Remove redundant condition
src/components/flipper.ts Outdated Show resolved Hide resolved

if (item.secondaryLabel) {
el.appendChild(Dom.make('div', Popover.CSS.itemSecondaryLabel, {
innerHTML: item.secondaryLabel,
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need innerHTML here? Can we use textCintent?

@@ -0,0 +1,46 @@
img, video, audio, canvas, input,
Copy link
Member

Choose a reason for hiding this comment

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

Still relevant

@neSpecc neSpecc marked this pull request as ready for review April 19, 2022 16:04
@neSpecc neSpecc requested a review from khaydarov as a code owner April 19, 2022 16:04
also, improve popover padding for two reasons:

- make the popover more consistent with the Table tool popover (in future, it can be done with the same api method)
- make popover looks better
@neSpecc neSpecc merged commit 8f156a8 into next Apr 25, 2022
@neSpecc neSpecc deleted the feat/vertical-toolbox branch April 25, 2022 15:29
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.

[Bug] hover toolbar doesn't work on mobile responsive size layout
4 participants