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

(3P) Premium Blocks: Add contextual tip for upgrade star icon #44050

Closed
obenland opened this issue Jul 9, 2020 · 12 comments
Closed

(3P) Premium Blocks: Add contextual tip for upgrade star icon #44050

obenland opened this issue Jul 9, 2020 · 12 comments
Labels
[Goal] Editor Improvements [Status] Needs Design Add this to PRs that need input from Design [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Comments

@obenland
Copy link
Member

obenland commented Jul 9, 2020

This will add a contextual tip to explain the meaning of the premium block stars, introduced in #44048.

I'm not sure if that is even possible currently, we should investigate if we can use __experimentalInserterMenuExtension for that and maybe position that tip via CSS.

Screenshot

image-2020-07-07-at-9 27 22-pm

Prior Art

See 123-gh-dotcom-manage

@obenland obenland added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Goal] Editor Improvements [Status] Needs Design Add this to PRs that need input from Design labels Jul 9, 2020
@obenland
Copy link
Member Author

obenland commented Jul 9, 2020

@sfougnier @jancavan Is there a chance I could defer to you for the creation of that star-with-background SVG that's being displayed in the tip?

@obenland obenland changed the title FSE: Add contextual tip for upgrade star icon Premium Blocks: Add contextual tip for upgrade star icon Jul 9, 2020
@obenland obenland changed the title Premium Blocks: Add contextual tip for upgrade star icon (3P) Premium Blocks: Add contextual tip for upgrade star icon Jul 13, 2020
@mreishus mreishus self-assigned this Jul 13, 2020
@mreishus
Copy link
Contributor

mreishus commented Jul 13, 2020

It looks like the goal is to overwrite the <Tip> element in Gutenberg, which provides a "global tip".

global-tip

In Gutenberg:

  • tips.js - Provides <Tips>, which reads from a locally defined globalTips and renders one
  • menu.js - Renders <Tips> from tips.js above

I'm not seeing a way that the tips can modified from outside gutenberg. Two possible ways to approach this:

  • A: Submit a PR to gutenberg to make the tips extensible. (Currently unsure of specifics)
  • B: Try a solution without changing gutenberg, such as the one Konstantin mentioned at the beginning of this issue. Generally injecting an element and positioning it with CSS.

I haven't tried B yet, I'll spend some time playing around with it tomorrow.

@mreishus
Copy link
Contributor

mreishus commented Jul 14, 2020

In testing, I was able to use __experimentalInserterMenuExtension to add a <div> to the menu. However, I'm not able to use CSS to position it over the global tooltip space. I tried using absolute positioning. Without changing other parts of the site, the nearest positioned parent is the scrollable block inserter div:

2020-07-14_09-23

Now, I can add bottom: 0px to put it at the bottom of the list, sort of. It's at the bottom of the first screenful of blocks before you scroll at all. But we need to 'break out' of that parent and go lower than that. What if I use a negative position on the bottom attribute? Well, it moves it lower and lower inside the list of blocks, but still inside the scrollable container. And if I tweak the position to be at the bottom of the scrollable container and then go even more negative, it extends the scrollable container. Example:

2020-07-14_09-24

I'm not seeing a way to do this with CSS, but I'm open to suggestions if anyone has any. I think we need some sort of modification to gutenberg.

Edit: Checking on a CSS driven approach with :after and .content.

@mreishus
Copy link
Contributor

mreishus commented Jul 14, 2020

Here's a css only approach. I used a placeholder SVG star from wikipedia for the time being. The positioning of it can be tweaked as well.

.block-editor-inserter__tips {
	.components-tip {
		svg {
			visibility: hidden;
		}
	}
	&::before {
		display: block;
		content: ' ';
		background-image: url( 'https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg' );
		position: absolute;
		background-size: 24px 24px;
		height: 24px;
		width: 24px;
	}
	&::after {
		content: 'Premium tools are available for you to preview within your site without an upgrade.';
		position: absolute;
		bottom: 16px;
		right: 16px;
		left: 50px;
		height: 39px;
		z-index: 11;
		background: #fff;
		text-align: center;
		overflow: hidden;
	}
}

2020-07-14_11-27

Issues:

  • Text is not available for translation. I don't see a way to stick something on a data- element as done on (5P) Premium Blocks: Add banner to block preview #44055.
  • Banner would always appear. It should only appear for non-upgraded users. Maybe there's a parent class somewhere that reflects that?

@mreishus
Copy link
Contributor

Note about customizing through Gutenberg. Even if we are able to add an override mechanism for globalTips in tips.js, that would change the text only. Currently, tips.js is hardcoded to use the <Tip> component, which uses a hardcoded icon. So we'd either have to add an icon customization method as well, or use a portal slot/filler mechanism for the tip space.

@ghost
Copy link

ghost commented Jul 14, 2020

The star asset can be found here:
Star.svg.zip

@mreishus
Copy link
Contributor

Halting work on this, unassigning.

@mreishus mreishus removed their assignment Jul 14, 2020
@obenland
Copy link
Member Author

@mreishus What are the next steps for this?

@mreishus
Copy link
Contributor

mreishus commented Jul 14, 2020

Decide which approach to use:

CSS:

  • I have a initial version above, but it has four problems:
    • Lacking translation (Unsure how to fix)
    • Appears always, instead of only when unpaid
    • Needs to use proper star SVG.
    • One small range of very narrow browser widths where a word or two gets cut off.

Integration with Gutenberg:

  • No code done. Two broad approaches possible
    • Add a mechanism to override globalTips in tips.js. This must be combined with a mechanism that overrides the graphic in the Tip component.
    • OR
    • Use a slot/filler mechanism in gutenberg's menu.js to override the <Tips> component entirely.

@obenland
Copy link
Member Author

WordPress/gutenberg#22109 (comment) has some good feedback from Core maintainers around creating a Tips API to register, unregister, and display Tips. It might be worth investing time into making that properly extensible for more ease of use down the road

@ghost
Copy link

ghost commented Jul 17, 2020

Latest design
Based on some of the issues that have come up with this in terms of both the functionality and implementation, the latest designs have removed this feature. The placement of messaging is now within the block + sidebar only.

01C Premium Block Flow

Design Links
Flow states
Block states

@mreishus
Copy link
Contributor

the latest designs have removed this feature

Closing this issue as it's not needed at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Editor Improvements [Status] Needs Design Add this to PRs that need input from Design [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

No branches or pull requests

2 participants