generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1317 from hlxsites/1316-spline-fragment
Created for spline-fragment
- Loading branch information
Showing
4 changed files
with
32 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,18 @@ | ||
import { getFragmentFromFile } from '../../scripts/scripts.js'; | ||
|
||
export default async function decorate(block) { | ||
try { | ||
// get the content | ||
const fragment = await getFragmentFromFile('/fragments/spline.html'); | ||
block.innerHTML = ''; | ||
const parser = new DOMParser(); | ||
const fragmentHtml = parser.parseFromString(fragment, 'text/html'); | ||
[...fragmentHtml.body.children].forEach((item) => { | ||
block.append(item); | ||
}); | ||
} catch (e) { | ||
block.textContent = ''; | ||
// eslint-disable-next-line no-console | ||
console.warn(`cannot load snippet at ${e}`); | ||
} | ||
} |
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,2 @@ | ||
<script type="module" src="https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js"></script> | ||
<spline-viewer url="https://prod.spline.design/UBAIdqMtOkuDExkL/scene.splinecode"></spline-viewer> |
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
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,10 @@ | ||
/* global WebImporter */ | ||
const splineViewer = (main, document) => { | ||
const splineViewerEl = main.querySelector('div#spline-viewer'); | ||
if (splineViewerEl) { | ||
const block = [['Spline Viewer'], ['']]; | ||
const table = WebImporter.DOMUtils.createTable(block, document); | ||
splineViewerEl.replaceWith(table); | ||
} | ||
}; | ||
export default splineViewer; |