Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JasonHowellSlavin
Copy link

@JasonHowellSlavin JasonHowellSlavin commented Aug 14, 2025

Modifies the previous branch to include better UX

Description

  1. Preview button is elevated to the main block entry (next to the caret). Adds lighter gray shade to these buttons for both templates and library.
  2. URLs for the blocks come from the getBlockVariants function which calls fetchAndParseHtml and appears to ensure urls fetch correctly from both da and aem urls.
  3. Previews for templates and blocks open in full sized modal.

Related Issue

Motivation and Context

Adds parity for template and block previews - changes made on code review comments for better UX

How Has This Been Tested?

  • Testing locally under aem-sandbox.
  • Opening and closing modal multiple times, hovering over button, comparing to main branch for parity.
  • @Dli3 will test as well

Screenshots (if appropriate):

Screen.Recording.2025-09-18.at.9.14.43.AM.mov

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

@chrischrischris chrischrischris left a comment

Choose a reason for hiding this comment

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

Looks good! I do wonder if we should open the block previews in a new tab/window instead of in the modal? Looks like css isn't applied in the modal?

@JasonHowellSlavin
Copy link
Author

JasonHowellSlavin commented Aug 19, 2025

Looks good! I do wonder if we should open the block previews in a new tab/window instead of in the modal? Looks like css isn't applied in the modal?

Thank you for the review!

I originally had them opening in a new tab using anchor links, but @auniverseaway mentioned a using full screen modal. I think it makes sense as it keeps the user in the da editor.

The blocks being pulled don't seem to have any css with them, and they look that way in a new window as well. If you try one of the templates, which point to bacom templates and they appear to load with css as expected.

@auniverseaway
Copy link
Member

The blocks being pulled don't seem to have any css with them, and they look that way in a new window as well. If you try one of the templates, which point to bacom templates and they appear to load with css as expected.

This is what I was getting at with my other comment. You have three formats of how people will enter their lists of blocks...

  1. Most common - https://content.da.live/...
  2. 2nd most common - https://main--{NAME_OF_SITE}...
  3. Least common, but possible: https://admin.da.live/source/.../page.html (note the .html addition)

For 1 & 2, you will need to detect and convert to the 2nd so you get a proper rendering of the page. Something like...

if (url.origin.includes('--') return url.href;
if (url.origin.includes('content.da.live') {
  const [, org, site, ...split] = url.pathname.split('/');
  return `https://main--${site}--${org}.aem.page/${split.join('/')}`;
}
if (url.origin.includes('admin.da.live') {
  return `Similar thing to content, but different`;
}

@JasonHowellSlavin
Copy link
Author

The blocks being pulled don't seem to have any css with them, and they look that way in a new window as well. If you try one of the templates, which point to bacom templates and they appear to load with css as expected.

This is what I was getting at with my other comment. You have three formats of how people will enter their lists of blocks...

  1. Most common - https://content.da.live/...
  2. 2nd most common - https://main--{NAME_OF_SITE}...
  3. Least common, but possible: https://admin.da.live/source/.../page.html (note the .html addition)

For 1 & 2, you will need to detect and convert to the 2nd so you get a proper rendering of the page. Something like...

if (url.origin.includes('--') return url.href;
if (url.origin.includes('content.da.live') {
  const [, org, site, ...split] = url.pathname.split('/');
  return `https://main--${site}--${org}.aem.page/${split.join('/')}`;
}
if (url.origin.includes('admin.da.live') {
  return `Similar thing to content, but different`;
}

Aah. thank you, that clarifies it a lot. Thank you both. I will get those changes made and push them up. Appreciate the review.

@JasonHowellSlavin
Copy link
Author

Hello @chrischrischris and @auniverseaway,

I was enacting the changes to modify the preview url to one that will load the user's repository code for a better preview when I realized there may be a permissions issue that crops up if we normalize the url to use aem.page:
Screenshot 2025-08-28 at 8 37 51 AM

This is what occurs for da-bacom when the url used is aem.page vs. aem.live in the config. Before I go down the path a little more, I wanted to get your advice: Do we check for a valid response from aem.page first before using it, or should we rely on users to know to use non-restricted paths?

We could easily fetch the HEAD to see if a Type Error is thrown, and then try using aem.live and if that fails, have a fallback message appear in the preview or even fall back to the content.da.live page. What do you think?

Thank you,
Jason

@auniverseaway
Copy link
Member

@JasonHowellSlavin I think we respect what people put in. If someone puts in aem.page, we use it (even if it 401s). If they put in aem.live, we use it. If someone puts in *.da.live we use aem.live.

Also: I have Github notifications turned off, so I didn't see this. Feel free to Slack me if you don't hear from us in a day or two.

Copy link
Contributor

@chrischrischris chrischrischris left a comment

Choose a reason for hiding this comment

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

Looks good! Some UI thoughts:

  • I think it'd be nice to have some sort of title at the top of the modal. "Library Preview"? "Name-of-block Preview"?
  • Close button looks weird in top left to me. I personally would prefer an X top right and then also a "Close" or "Ok" at bottom right. Then again I guess with the library on the left side is why you have it there?
  • There should be support for Esc key closing of preview

return `https://main--${site}--${org}.aem.page/${split.join('/')}`;
}
} catch {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit - can remove this as it will continue to line 270. Not sure if linter is ok with it though

Copy link
Author

Choose a reason for hiding this comment

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

The linter triggers a "no empty catch" rule. Would you prefer I remove that or disable the linter?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just put a comment.

@JasonHowellSlavin
Copy link
Author

Thank you Chris for the feedback. I made the changes you suggested. I did have one question regarding the last bullet:

  • There should be support for Esc key closing of preview

It appears that the library modal code closes on esc, but it uses the same functionality that I avoided with the preview initially. That is, it removes the entire modal, library included. See the attached video where I use the button to close out of the preview vs using escape.

Let me know what you think, and thank you again.

whole.library.removal.esc.mov

@chrischrischris
Copy link
Contributor

Re Closing with Esc, I personally rather have the key do something vs requiring a mouse.... but I'll defer to @auniverseaway

@auniverseaway auniverseaway merged commit ba03860 into adobe:libprev Dec 1, 2025
2 of 5 checks passed
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