Skip to content

Commit

Permalink
initiating work with 2 basic form elements
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai committed Mar 30, 2024
1 parent f109783 commit 4b965f8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
Empty file.
3 changes: 3 additions & 0 deletions blocks/checkbox-fieldset/checkbox-fieldset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function init(el) {
console.log('checkbox loaded.');
}
4 changes: 2 additions & 2 deletions blocks/events-form/events-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ async function updateDynamicContent(bp) {
await Promise.all([
import(`${getLibs()}/utils/getUuid.js`),
import('../../utils/event-apis.js'),
import('../page-server/page-server.js'),
import('../../utils/utils.js'),
]).then(async ([{ default: getUuid }, caasApiMod, { autoUpdateContent }]) => {
const hash = await getUuid(window.location.pathname);
let profile;
Expand All @@ -373,7 +373,7 @@ async function updateDynamicContent(bp) {
await decorateRSVPStatus(bp, profile);
}

await autoUpdateContent(block, { ...await caasApiMod.default(hash), ...profile }, true);
await autoUpdateContent(block, { ...await caasApiMod.default(hash), ...profile });
eventHero.classList.remove('loading');
personalizeForm(block, profile);
});
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function init(el) {
console.log('handler loaded');
}
13 changes: 11 additions & 2 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ export function yieldToMain() {
});
}

export function getIcon(tag) {
const img = document.createElement('img');
img.className = `icon icon-${tag}`;
img.src = `/icons/${tag}.svg`;
img.alt = tag;

return img;
}

function handleRegisterButton(a) {
const signIn = () => {
if (typeof window.adobeIMS?.signIn !== 'function') {
Expand Down Expand Up @@ -97,14 +106,14 @@ function updateTextNode(child, matchCallback) {
}

// data -> dom gills
export function autoUpdateContent(parent) {
export function autoUpdateContent(parent, extraData) {
if (!parent) {
window.lana?.log('page server block cannot find its parent element');
return;
}

const getContent = (_match, p1, n) => {
const content = getMetadata(p1) || '';
const content = getMetadata(p1) || extraData?.[p1] || '';
if (preserveFormatKeys.includes(p1)) {
n.parentNode?.classList.add('preserve-format');
}
Expand Down

0 comments on commit 4b965f8

Please sign in to comment.