-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix appearance of DotTip on mobile Force DotTip content to appear underneath the indicator dot when on mobile viewports. This requires overriding a lot of .component-popover styles which is quite gross. * Remove unnecessary <Fragment> * Position NUX dots right next to the edge of the button Adjust popover's layout algorithm so that if yAxis === 'middle', it will set popoverLeft such that the popover points to the edge of the anchor node. This aligns with what e.g. position="bottom center" does. * Increase NUX tip padding * Add margin to sides of NUX tip on mobile * Don't encourage using domReady in the NUX README * Add wp-nux as a dependency of wp-edit-post * Suggest that NUX tip identifiers are prefixed * Don't use partial(), which is slated for removal * tipID → tipId * Improve NUX JSDoc comments * Memoize the getAssociatedGuide() selector * NUX: Dismiss the tip when one clicks away from it * Position tooltips above NUX tips * Remove aria-modal property from DotTip Safari 11 has a weird bug when this property is used. * Make order of the markup in DotTip match how they appear visually * Improve a11y of DotTip labels * Implement New User Guide Adds a series of floating modal 'tips' which introduces a new user to the editor. These tips can be advanced one by one or dismissed alltogether. If dismissed, they will never show again. * Dismiss tips instead of disabling when the X is clicked * Fix DotTip focus issue The first DotTip should receive focus when the page loads, and focus should not be on the X button. Also improve the note explaining our temporary position workaround. * NUX: Only show inserter tip in DefaultBlockAppender Only display the first DotTip in the new user guide in the DefaultBlockAppender that appears in a new post. This prevents the guide from appearing in an existing post that contains empty blocks.
- Loading branch information
1 parent
be00077
commit e809505
Showing
29 changed files
with
912 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,32 @@ const isMobileViewport = () => window.innerWidth < 782; | |
* @param {Object} anchorRect Anchor Rect. | ||
* @param {Object} contentSize Content Size. | ||
* @param {string} xAxis Desired xAxis. | ||
* @param {string} chosenYAxis yAxis to be used. | ||
* @param {boolean} expandOnMobile Whether to expand the popover on mobile or not. | ||
* | ||
* @return {Object} Popover xAxis position and constraints. | ||
*/ | ||
export function computePopoverXAxisPosition( anchorRect, contentSize, xAxis ) { | ||
export function computePopoverXAxisPosition( anchorRect, contentSize, xAxis, chosenYAxis ) { | ||
const { width } = contentSize; | ||
const popoverLeft = Math.round( anchorRect.left + ( anchorRect.width / 2 ) ); | ||
|
||
// x axis alignment choices | ||
const anchorMidPoint = Math.round( anchorRect.left + ( anchorRect.width / 2 ) ); | ||
const centerAlignment = { | ||
popoverLeft: anchorMidPoint, | ||
contentWidth: ( | ||
( popoverLeft - ( width / 2 ) > 0 ? ( width / 2 ) : popoverLeft ) + | ||
( popoverLeft + ( width / 2 ) > window.innerWidth ? window.innerWidth - popoverLeft : ( width / 2 ) ) | ||
( anchorMidPoint - ( width / 2 ) > 0 ? ( width / 2 ) : anchorMidPoint ) + | ||
( anchorMidPoint + ( width / 2 ) > window.innerWidth ? window.innerWidth - anchorMidPoint : ( width / 2 ) ) | ||
), | ||
}; | ||
const leftAlignmentX = chosenYAxis === 'middle' ? anchorRect.left : anchorMidPoint; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ellatrix
Member
|
||
const leftAlignment = { | ||
contentWidth: popoverLeft - width > 0 ? width : popoverLeft, | ||
popoverLeft: leftAlignmentX, | ||
contentWidth: leftAlignmentX - width > 0 ? width : leftAlignmentX, | ||
}; | ||
const rightAlignmentX = chosenYAxis === 'middle' ? anchorRect.right : anchorMidPoint; | ||
const rightAlignment = { | ||
contentWidth: popoverLeft + width > window.innerWidth ? window.innerWidth - popoverLeft : width, | ||
popoverLeft: rightAlignmentX, | ||
contentWidth: rightAlignmentX + width > window.innerWidth ? window.innerWidth - rightAlignmentX : width, | ||
}; | ||
|
||
// Choosing the x axis | ||
|
@@ -48,6 +54,15 @@ export function computePopoverXAxisPosition( anchorRect, contentSize, xAxis ) { | |
contentWidth = chosenWidth !== width ? chosenWidth : null; | ||
} | ||
|
||
let popoverLeft; | ||
if ( chosenXAxis === 'center' ) { | ||
popoverLeft = centerAlignment.popoverLeft; | ||
} else if ( chosenXAxis === 'left' ) { | ||
popoverLeft = leftAlignment.popoverLeft; | ||
} else { | ||
popoverLeft = rightAlignment.popoverLeft; | ||
} | ||
|
||
return { | ||
xAxis: chosenXAxis, | ||
popoverLeft, | ||
|
@@ -131,8 +146,8 @@ export function computePopoverYAxisPosition( anchorRect, contentSize, yAxis ) { | |
export function computePopoverPosition( anchorRect, contentSize, position = 'top', expandOnMobile = false ) { | ||
const [ yAxis, xAxis = 'center' ] = position.split( ' ' ); | ||
|
||
const xAxisPosition = computePopoverXAxisPosition( anchorRect, contentSize, xAxis ); | ||
const yAxisPosition = computePopoverYAxisPosition( anchorRect, contentSize, yAxis ); | ||
const xAxisPosition = computePopoverXAxisPosition( anchorRect, contentSize, xAxis, yAxisPosition.yAxis ); | ||
|
||
return { | ||
isMobile: isMobileViewport() && expandOnMobile, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
@noisysocks @youknowriad Do you remember why
anchorMidPoint
is used fortop
andbottom
, even though it's asking forleft
? This doesn't make any sense. Would have been good to comment on this.