-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-154549 | Integrating unity Block in CC (#386)
Adding unity block in CC Resolves: MWPW-154549 Test URLs: Before: https://main--cc--adobecom.hlx.live/drafts/mathuria/unity/poc?unitylibs=stage&martech=off After: https://mwpw-154549--cc--adobecom.hlx.live/drafts/mathuria/unity/poc?unitylibs=stage&martech=off
- Loading branch information
1 parent
d6a1ebd
commit 3feca22
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.unity { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { loadStyle } from '../../scripts/utils.js'; | ||
|
||
function getUnityLibs(prodLibs = '/unitylibs') { | ||
const { hostname } = window.location; | ||
if (!hostname.includes('hlx.page') | ||
&& !hostname.includes('hlx.live') | ||
&& !hostname.includes('localhost')) { | ||
return prodLibs; | ||
} | ||
const branch = new URLSearchParams(window.location.search).get('unitylibs') || 'main'; | ||
if (branch.indexOf('--') > -1) return `https://${branch}.hlx.live/unitylibs`; | ||
return `https://${branch}--unity--adobecom.hlx.live/unitylibs`; | ||
} | ||
|
||
export default async function init(el) { | ||
const unitylibs = getUnityLibs(); | ||
const stylePromise = new Promise((resolve) => { | ||
loadStyle(`${unitylibs}/core/styles/styles.css`, resolve); | ||
}); | ||
await stylePromise; | ||
const { default: wfinit } = await import(`${unitylibs}/core/workflow/workflow.js`); | ||
await wfinit(el, 'cc', unitylibs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters