diff --git a/acrobat/blocks/prompt-card/prompt-card.css b/acrobat/blocks/prompt-card/prompt-card.css index 95406622..94506c3c 100644 --- a/acrobat/blocks/prompt-card/prompt-card.css +++ b/acrobat/blocks/prompt-card/prompt-card.css @@ -69,14 +69,14 @@ flex: 1 0 0; flex-direction: column; justify-content: space-between; - padding: 20px 20px 24px; + padding: 16px 16px 24px; transition-delay: 3s; transition-property: border; max-width: 276px; } .prompt-blade:hover { - box-shadow: 3px 6px 6px 0 rgba(0, 0, 0, .16) + box-shadow: 0 3px 6px rgba(0, 0, 0, 16%) } .prompt-blade:active { @@ -153,7 +153,7 @@ font-style: normal; font-weight: 400; line-height: 150%; - padding: 2px 8px + padding: 2px 16px } .prompt-copy-btn:after { diff --git a/acrobat/blocks/prompt-card/prompt-card.js b/acrobat/blocks/prompt-card/prompt-card.js index c53d30a4..69fce998 100644 --- a/acrobat/blocks/prompt-card/prompt-card.js +++ b/acrobat/blocks/prompt-card/prompt-card.js @@ -81,7 +81,7 @@ async function createBlocks(element, blockArray, templateCfg) { } element.remove(); - if (templateCfg.rows && parentNode.classList.contains('section')) { + if (templateCfg?.rows && parentNode.classList.contains('section')) { const resizeObserver = new ResizeObserver(() => { const computedStyle = window.getComputedStyle(parentNode); if (/^(\d+(\.\d+)?(px|fr|em|rem|%))( (\d+(\.\d+)?(px|fr|em|rem|%)))*$/.test(computedStyle.gridTemplateColumns)) { diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index 55984a15..d2f6a102 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -5,8 +5,32 @@ import verbAnalytics from '../../scripts/alloy/verb-widget.js'; const miloLibs = setLibs('/libs'); const { createTag } = await import(`${miloLibs}/utils/utils.js`); +const fallBack = 'https://www.adobe.com/go/acrobat-overview'; const EOLBrowserPage = 'https://acrobat.adobe.com/home/index-browser-eol.html'; +const verbRedirMap = { + createpdf: 'createpdf', + 'crop-pages': 'crop', + 'delete-pages': 'deletepages', + 'extract-pages': 'extract', + 'combine-pdf': 'combine', + 'protect-pdf': 'protect', + 'add-comment': 'addcomment', + 'pdf-to-image': 'pdftoimage', + 'reorder-pages': 'reorderpages', + sendforsignature: 'sendforsignature', + 'rotate-pages': 'rotatepages', + fillsign: 'fillsign', + 'split-pdf': 'split', + 'insert-pdf': 'insert', + 'compress-pdf': 'compress', + 'png-to-pdf': 'jpgtopdf', + 'number-pages': 'number', + 'ocr-pdf': 'ocr', + 'chat-pdf': 'chat', + 'chat-pdf-student': 'study', +}; + const setUser = () => { localStorage.setItem('unity.user', 'true'); }; @@ -36,6 +60,19 @@ function initiatePrefetch(verb) { } } +function redDir(verb) { + const hostname = window?.location?.hostname; + const ENV = getEnv(); + const VERB = verb; + let newLocation; + if (hostname !== 'www.adobe.com' && hostname !== 'sign.ing' && hostname !== 'edit.ing') { + newLocation = `https://www.adobe.com/go/acrobat-${verbRedirMap[VERB] || VERB.split('-').join('')}-${ENV}`; + } else { + newLocation = `https://www.adobe.com/go/acrobat-${verbRedirMap[VERB] || VERB.split('-').join('')}` || fallBack; + } + window.location.href = newLocation; +} + export default async function init(element) { if (isOldBrowser()) { window.location.href = EOLBrowserPage; @@ -99,6 +136,21 @@ export default async function init(element) { element.append(widget, footer); + // Redirect after IMS:Ready + window.addEventListener('IMS:Ready', () => { + console.log('IMS:Ready 😎'); + if (window.adobeIMS.isSignedInUser() + && window.adobeIMS.getAccountType() !== 'type1') { + redDir(VERB); + } + }); + // Race Condition + if (window.adobeIMS?.isSignedInUser() + && window.adobeIMS?.getAccountType() !== 'type1') { + console.log('Race Con ⏩'); + redDir(VERB); + } + // Analytics verbAnalytics('landing:shown', VERB); @@ -110,6 +162,7 @@ export default async function init(element) { button.addEventListener('click', () => { verbAnalytics('filepicker:shown', VERB); + verbAnalytics('dropzone:choose-file-clicked', VERB); initiatePrefetch(VERB); }); @@ -139,7 +192,7 @@ export default async function init(element) { window.addEventListener('unity:track-analytics', (e) => { if (e.detail?.event === 'change') { - verbAnalytics('choose-file:open', VERB); + verbAnalytics('choose-file:open', VERB, e.detail?.data); setUser(); } // maybe new event name files-dropped? @@ -148,10 +201,6 @@ export default async function init(element) { setDraggingClass(widget, false); setUser(); } - if (e.detail?.event === 'choose-file-clicked') { - verbAnalytics('dropzone:choose-file-clicked', VERB, e.detail?.data); - setUser(); - } if (e.detail?.event === 'uploading') { verbAnalytics('job:uploading', VERB, e.detail?.data); diff --git a/test/scripts/scripts-preloads.test.js b/test/scripts/scripts-preloads.test.js index 0d00f757..4aa79465 100644 --- a/test/scripts/scripts-preloads.test.js +++ b/test/scripts/scripts-preloads.test.js @@ -1,15 +1,16 @@ import { expect } from '@esm-bundle/chai'; +import { waitForElement } from '../helpers/waitfor.js'; describe('Test scripts.js configurable preloads', () => { it('has preload metadata', async () => { document.head.innerHTML = ''; document.body.innerHTML = '
'; await import('../../acrobat/scripts/scripts.js'); - const js = document.querySelector('link[rel="preload"][href="https://main--milo--adobecom.hlx.page/libs/blocks/marquee/marquee.js"]'); - const css = document.querySelector('link[rel="stylesheet"][href="https://main--milo--adobecom.hlx.page/libs/blocks/marquee/marquee.css"]'); + const js = document.querySelector('link[rel="preload"][href="https://main--milo--adobecom.hlx.live/libs/blocks/marquee/marquee.js"]'); + const css = document.querySelector('link[rel="stylesheet"][href="https://main--milo--adobecom.hlx.live/libs/blocks/marquee/marquee.css"]'); const other = document.querySelector('link[rel="preload"][href="https://www.example.com/abc.js"]'); const acrobatcss = document.querySelector('link[rel="stylesheet"][href="/acrobat/styles/styles.css"]'); - const milocss = document.querySelector('link[rel="stylesheet"][href="https://main--milo--adobecom.hlx.page/libs/styles/styles.css"]'); + const milocss = document.querySelector('link[rel="stylesheet"][href="https://main--milo--adobecom.hlx.live/libs/styles/styles.css"]'); expect(js).not.to.be.null; expect(css).not.to.be.null; expect(other).not.to.be.null;