-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
* 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 <[email protected]>
src/components/flipper.ts
Outdated
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ts-ignore here?
if (_.isMobile()) { | ||
return; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/components/polyfills.ts
Outdated
// 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/components/ui/toolbox.ts
Outdated
|
||
this.addTools(); | ||
this.enableFlipper(); | ||
this.popover.on(PopoverEvent.OverlayClicked, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we unsubscribe somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/components/utils.ts
Outdated
/** | ||
* True if screen has mobile size | ||
*/ | ||
export function isMobile(): boolean { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to isMobileScreen
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', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/components/utils/popover.ts
Outdated
private createItem(item: PopoverItem): HTMLElement { | ||
const el = Dom.make('div', Popover.CSS.item); | ||
|
||
el.setAttribute('data-item-name', item.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el.setAttribute('data-item-name', item.name); | |
el.dataset.itemName = item.name; |
src/styles/input.css
Outdated
@@ -0,0 +1,46 @@ | |||
img, video, audio, canvas, input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not encapsulated selectors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant
There was a problem hiding this comment.
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/utils/popover.ts
Outdated
|
||
if (item.secondaryLabel) { | ||
el.appendChild(Dom.make('div', Popover.CSS.itemSecondaryLabel, { | ||
innerHTML: item.secondaryLabel, |
There was a problem hiding this comment.
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
?
src/styles/input.css
Outdated
@@ -0,0 +1,46 @@ | |||
img, video, audio, canvas, input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant
* Change popover opening direction based on available space below it * Update check * Use cacheable decorator
Co-authored-by: George Berezhnoy <[email protected]>
…/editor.js into feat/vertical-toolbox
because I have no idea what does it mean
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
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.
Changelog
Popover
utility has been created. It will be used for all vertical lists.Toolbox
now uses thePopover
to display the tools listPlus
button will be always shown (previously, it appears only for empty blocks)Toolbar
won't move on hover at mobile viewports. Resolves [Bug] hover toolbar doesn't work on mobile responsive size layout #1972Flipper
now scrolls to the focused item usingscrollIntoViewIfNeeded
Also, see the Discussion #1811
Thanks to @TatianaFomina for finishing the PR so fast.