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

#5078: support showing panel as popover #5023

Merged
merged 7 commits into from
Jan 26, 2023
Merged

#5078: support showing panel as popover #5023

merged 7 commits into from
Jan 26, 2023

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Jan 15, 2023

What does this PR do?

Known Issues

  • Scroll bar behavior
  • Jumpy UI when using with mouseover trigger
  • Improve placement of "x": N/A. Using click outside event instead

Demo

Future Work

  • Not showing if toward the bottom of page? ('auto') not working?
  • Reduce flickering on render - likely need to use a stencil
  • Allow creator to specify position
  • Allow creator to specify width/height: initial, to reduce flickering and actual

Checklist

  • Add tests: I'll circle back tomorrow (Thursday) to write some tests
  • Designate a primary reviewer: @BLoe

@twschiller twschiller added the do not merge Merging of this PR is blocked by another one label Jan 15, 2023
@twschiller twschiller changed the title POC of Display Temporary Information for popovers POC of Display Temporary Information via element popovers Jan 15, 2023
@twschiller twschiller self-assigned this Jan 15, 2023
@twschiller twschiller added this to the 1.7.18 milestone Jan 25, 2023
Clear existing popovers

Vendor hover intent; smooth out popover

Namespace tooltips container
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #5023 (5bd588e) into main (3619d1f) will decrease coverage by 0.08%.
The diff coverage is 45.16%.

❗ Current head 5bd588e differs from pull request most recent head 55aadeb. Consider uploading reports for the commit 55aadeb to get more accurate results

@@            Coverage Diff             @@
##             main    #5023      +/-   ##
==========================================
- Coverage   60.54%   60.47%   -0.08%     
==========================================
  Files         962      964       +2     
  Lines       29223    29316      +93     
  Branches     5608     5625      +17     
==========================================
+ Hits        17694    17728      +34     
- Misses      11529    11588      +59     
Impacted Files Coverage Δ
src/baseRegistry.ts 85.00% <ø> (-0.15%) ⬇️
...ocks/transformers/temporaryInfo/EphemeralPanel.tsx 0.00% <0.00%> (ø)
src/extensionPoints/menuItemExtension.ts 64.26% <ø> (ø)
src/pageEditor/exampleBlockConfigs.ts 87.17% <ø> (ø)
...c/pageEditor/tabs/trigger/TriggerConfiguration.tsx 58.49% <ø> (ø)
src/tinyPages/ephemeralPanel.tsx 0.00% <ø> (ø)
.../blocks/transformers/temporaryInfo/popoverUtils.ts 11.42% <11.42%> (ø)
...transformers/temporaryInfo/DisplayTemporaryInfo.ts 71.01% <54.28%> (-10.99%) ⬇️
src/extensionPoints/triggerExtension.ts 58.86% <77.27%> (+0.52%) ⬆️
...ansformers/temporaryInfo/temporaryPanelProtocol.ts 89.58% <78.94%> (-7.39%) ⬇️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -0,0 +1,208 @@
/*!
Copy link
Contributor Author

@twschiller twschiller Jan 25, 2023

Choose a reason for hiding this comment

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

Vendored from http://briancherne.github.io/jquery-hoverIntent/ for module support

@twschiller twschiller removed low priority do not merge Merging of this PR is blocked by another one labels Jan 25, 2023
@twschiller twschiller changed the title POC of Display Temporary Information via element popovers #5078: support showing panel as popover Jan 25, 2023
@@ -90,12 +90,6 @@ export class Registry<
}

private notifyAll() {
console.debug(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logging is super noisy

@twschiller twschiller marked this pull request as ready for review January 25, 2023 22:51
@twschiller twschiller requested review from BLoe and BALEHOK and removed request for BLoe January 25, 2023 22:52
@@ -89,65 +98,101 @@ class DisplayTemporaryInfo extends Transformer {
title,
body: bodyPipeline,
location = "panel",
isRootAware = false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Safe default

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the brick isRootAware() "safe default" true, but the transform() input param one is false?

Copy link
Contributor Author

@twschiller twschiller Jan 26, 2023

Choose a reason for hiding this comment

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

See this PR for more details on the approach: #4910

The idea is that:

  • isRootAware is overridden so the runtime sees the brick as root aware
  • The brick exposes an isRootAware param, but it defaults to false in calls for backward compatability. It controls whether the brick actually considers the root or not in brick execution
  • In the JSONSchema, isRootAware defaults to "true", so new calls create in the Page Editor pass true
  • The Brick Configuration looks at the arg to determine which fields to show

default: "panel",
description: "The location of the information (default='panel')",
},
...IS_ROOT_AWARE_BRICK_PROPS,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking same approach as other PR for upgrading the brick to be root aware

target
)) as PanelPayload;

switch (location) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch to a "switch" statement. The whitespace in the diff is bad

@fregante
Copy link
Contributor

Can this be implemented with a shadowdom instead of iframe? It contains style and the JS still lives in the content script context, similarly to how the QuickBar and notifications work

Copy link
Contributor

@BLoe BLoe left a comment

Choose a reason for hiding this comment

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

Just a few nits and minor questions, code seems good overall though 👍

I didn't check out the branch and do any local QA on the UX for this though.

@@ -89,65 +98,101 @@ class DisplayTemporaryInfo extends Transformer {
title,
body: bodyPipeline,
location = "panel",
isRootAware = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the brick isRootAware() "safe default" true, but the transform() input param one is false?

const [entry, isLoading, error] = useAsyncState(
async () => getPanelDefinition(target, nonce),
[nonce]
);

useEffect(() => {
document.dispatchEvent(
new CustomEvent("@@pixiebrix/PANEL_MOUNTED", { detail: nonce })
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably put this event name in a constant in constants.ts with our other custom events there

@@ -123,7 +148,7 @@ export async function resolveTemporaryPanel(nonce: UUID, action: PanelAction) {
* Cancel some temporary panels' deferred promises
* @param nonces The nonces of the panels to reject with a CancelError
*/
export async function cancelTemporaryPanels(nonces: UUID[]) {
export async function cancelTemporaryPanels(nonces: UUID[]): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Make this a varargs param so we don't have to create arrays at all the call sites.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer not to unless we're sure that we won't want to add an optional options arg on later. Personally, I'm not a big fan of var args for lists of things

// `hoverIntent` JQuery plugin has custom event names
$elements.off("mouseenter.hoverIntent");
$elements.off("mouseleave.hoverIntent");
$elements.hoverIntent({
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, do we want to pass in a timeout delay here to hoverIntent options? Just want to make sure that calling the handler instantly on mouse out event is fine here for the UX on the popovers.

Copy link
Contributor Author

@twschiller twschiller Jan 26, 2023

Choose a reason for hiding this comment

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

It's OK to call instantly, since the event has already fired at that point. There's no notion of a "hover end" trigger. We're really only using the hoverIntent for the "hover start"

@@ -120,6 +120,7 @@ const TriggerConfiguration: React.FC<{
<option value="dblclick">Double Click</option>
<option value="blur">Blur</option>
<option value="mouseover">Mouseover</option>
<option value="hover">Hover</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are users going to be confused about the difference between Mouseover and Hover here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are users going to be confused about the difference between Mouseover and Hover here?

Probably? We'll need to clean up all out trigger names to better clarify what they are. E.g., most users won't have a way of knowing what "blur" means

@github-actions
Copy link

When the PR is merged, the first loom link found on this PR will be posted to #sprint-demo on Slack. Do not edit this comment manually.

@twschiller
Copy link
Contributor Author

twschiller commented Jan 26, 2023

Can this be implemented with a shadowdom instead of iframe?

Sadly I don't think - we run into the same issue we do with forms. We want to isolate the content completely from the CSS (because out document builder uses bootstrap). And certain things like root font-size REM aren't isolated by the shadow dom

In the future, we might be able to get away with it by doing a custom build of bootstrap for forms/panels with CSS rules that can't be effected by any of the CSS props that leak into the shadow root

@fregante
Copy link
Contributor

Ah yes it's a rem unit issue. Keeping a custom stylesheet where we replace this unit would probably be beneficial to avoid many of the iframes we have, making them faster to load and easier to handle

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.

3 participants