Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

IconTooltip: Use click instead of mouseover for summoning
36 changes: 9 additions & 27 deletions projects/js-packages/components/components/icon-tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Popover } from '@wordpress/components';
import { useDebounce } from '@wordpress/compose';
import classNames from 'classnames';
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';
import Button from '../button';
import Gridicon from '../gridicon/index';
import { IconTooltipProps, Placement, Position } from './types';

Expand Down Expand Up @@ -37,27 +37,10 @@ const IconTooltip: React.FC< IconTooltipProps > = ( {
title,
children,
} ) => {
const delay = 300;
const POPOVER_HELPER_WIDTH = 124;
const [ isVisible, setIsVisible ] = useState( false );
const delayedSetIsOver = useDebounce( setIsVisible, delay );

const createToggleIsOver = ( eventName, isDelayed = false ) => {
return event => {
event.stopPropagation();
event.preventDefault();
const _isVisible = [ 'focus', 'mouseenter' ].includes( event.type );
if ( _isVisible === isVisible ) {
return;
}

if ( isDelayed ) {
delayedSetIsOver( _isVisible );
} else {
setIsVisible( _isVisible );
}
};
};
const showTooltip = useCallback( () => setIsVisible( true ), [ setIsVisible ] );
const hideTooltip = useCallback( () => setIsVisible( false ), [ setIsVisible ] );

const args = {
// To be compatible with deprecating prop `position`.
Expand All @@ -68,6 +51,9 @@ const IconTooltip: React.FC< IconTooltipProps > = ( {
resize: false,
flip: false,
offset, // The distance (in px) between the anchor and the popover.
focusOnMount: 'container' as const,
onClose: hideTooltip,
className: 'icon-tooltip-container',
};

const wrapperClassNames = classNames( 'icon-tooltip-wrapper', className );
Expand All @@ -77,13 +63,9 @@ const IconTooltip: React.FC< IconTooltipProps > = ( {

return (
<div className={ wrapperClassNames } data-testid="icon-tooltip_wrapper">
<span
style={ { cursor: 'pointer' } }
onMouseEnter={ createToggleIsOver( 'onMouseEnter', true ) }
onMouseLeave={ createToggleIsOver( 'onMouseLeave' ) }
>
<Button variant="link" onClick={ showTooltip }>
<Gridicon className={ iconClassName } icon={ iconCode } size={ iconSize } />
</span>
</Button>

<div className="icon-tooltip-helper" style={ iconShiftBySize }>
{ isVisible && (
Expand Down
19 changes: 13 additions & 6 deletions projects/js-packages/components/components/icon-tooltip/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,28 @@ $arrow-color: var( --jp-gray );
display: inline-block;
position: relative;
color: var( --jp-black );

.components-button.is-link:focus:not(:disabled) {
box-shadow: none;
}
}

.icon-tooltip-helper {
// POPOVER_HELPER_WIDTH
width: 124px;
height: 18px;
position: absolute;
top: 0;
height: 18px;
position: absolute;
top: 0;
// -( POPOVER_HELPER_WIDTH / 2 - iconSize / 2 ) + 'px'
left: -53px;
left: -53px;
pointer-events: none;
}

.icon-tooltip-container {
// Recover events
pointer-events: all;
}

.icon-tooltip-title {
font-weight: 600;
font-size: 16px;
Expand All @@ -91,6 +100,4 @@ $arrow-color: var( --jp-gray );
font-weight: 400;
font-size: 14px;
line-height: 24px;
// Recover events
pointer-events: all;
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}
}

.popover-icon {
.item .popover-icon {
fill: var( --jp-gray-20 );
flex-shrink: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/js-packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-components",
"version": "0.21.1-alpha",
"version": "0.22.0-alpha",
"description": "Jetpack Components Package",
"author": "Automattic",
"license": "GPL-2.0-or-later",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
4 changes: 2 additions & 2 deletions projects/js-packages/connection/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@automattic/jetpack-connection",
"version": "0.21.0",
"version": "0.21.1-alpha",
"description": "Jetpack Connection Component",
"author": "Automattic",
"license": "GPL-2.0-or-later",
"dependencies": {
"@automattic/jetpack-analytics": "workspace:* || ^0.1",
"@automattic/jetpack-config": "workspace:* || ^0.1",
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@automattic/jetpack-api": "workspace:* || ^0.14",
"@wordpress/base-styles": "4.7.0",
"@wordpress/browserslist-config": "5.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/js-packages/idc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@automattic/jetpack-analytics": "workspace:* || ^0.1",
"@automattic/jetpack-api": "workspace:* || ^0.14",
"@automattic/jetpack-base-styles": "workspace:* || ^0.3",
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@wordpress/base-styles": "4.7.0",
"@wordpress/components": "20.0.0",
"@wordpress/compose": "5.14.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
4 changes: 2 additions & 2 deletions projects/js-packages/licensing/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-licensing",
"version": "0.5.14",
"version": "0.5.15-alpha",
"description": "Jetpack licensing flow",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/licensing/#readme",
"bugs": {
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@automattic/jetpack-api": "workspace:* || ^0.14",
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@wordpress/components": "20.0.0",
"@wordpress/element": "4.14.0",
"@wordpress/i18n": "4.16.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
4 changes: 2 additions & 2 deletions projects/js-packages/partner-coupon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-partner-coupon",
"version": "0.2.27",
"version": "0.2.28-alpha",
"description": "This package aims to add components to make it easier to redeem partner coupons",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/partner-coupon/#readme",
"bugs": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"react-dom": "17.0.2"
},
"dependencies": {
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@automattic/jetpack-connection": "workspace:* || ^0.21",
"@wordpress/i18n": "4.16.0",
"classnames": "2.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
4 changes: 2 additions & 2 deletions projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize-components",
"version": "0.7.0",
"version": "0.7.1-alpha",
"description": "A library of JS components required by the Publicize editor plugin",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme",
"bugs": {
Expand All @@ -19,7 +19,7 @@
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
},
"dependencies": {
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@automattic/jetpack-shared-extension-utils": "workspace:* || ^0.6",
"@automattic/social-previews": "1.1.5",
"@wordpress/annotations": "2.16.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/js-packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test-coverage": "jest tests/ --coverage --collectCoverageFrom='src/**/*.js' --coverageDirectory=\"$COVERAGE_DIR\" --coverageReporters=clover"
},
"devDependencies": {
"@automattic/jetpack-components": "workspace:* || ^0.21",
"@automattic/jetpack-components": "workspace:* || ^0.22",
"@babel/core": "7.18.13",
"@babel/plugin-syntax-jsx": "7.18.6",
"@babel/preset-react": "7.18.6",
Expand Down
Loading