Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

641 product citations embeds #656

Merged
merged 13 commits into from
Jan 17, 2024
31 changes: 31 additions & 0 deletions blocks/product-citations/product-citations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { object } from '../../scripts/dom-builder.js';
import { loadScript } from '../../scripts/lib-franklin.js';

function buildCitations(id, data) {
const citations = object({
id,
type: 'text/html',
data,
style: 'width:100%; height: 193px',
});
return citations;
}

export default async function decorate(block) {
const attrs = { defer: true };
await loadScript('https://cdn.bioz.com/assets/jquery-2.2.4.js', attrs);
await loadScript('https://cdn.bioz.com/assets/bioz-w-api-6.0.min.js', attrs);

const biozDiv = `<div id="bioz-w-pb-3230-bzen-q" href="https://www.bioz.com/" target="_blank" style="font-size: 12px; text-decoration: none; color: rgb(10, 67, 133);">
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we build this html using dom-builder like in other blocks? and use tailwind / css for styling?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @duynguyen - I've made the required changes. Please have a look. Thanks.

<img src="https://cdn.bioz.com/assets/favicon.png"
style="width: 11px; height: 11px; vertical-align: baseline; padding-bottom: 0px; margin-left: 0px; margin-bottom: 0px; float: none;">
Powered by Bioz See more details on Bioz © 2024</div>`;

const citationsLinkEl = block.querySelector('a');
if (citationsLinkEl) {
const id = citationsLinkEl.getAttribute('title');
const data = citationsLinkEl.getAttribute('href');
block.innerHTML = biozDiv;
block.prepend(buildCitations(id, data));
}
}
1 change: 1 addition & 0 deletions scripts/dom-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ export function dl(...items) { return domEl('dl', ...items); }
export function dt(...items) { return domEl('dt', ...items); }
export function dd(...items) { return domEl('dd', ...items); }
export function hr(...items) { return domEl('hr', ...items); }
export function object(...items) { return domEl('object', ...items); }
2 changes: 1 addition & 1 deletion scripts/lib-franklin.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export function decorateButtons(element) {
const up = a.parentElement;
const twoup = a.parentElement.parentElement;
if (!a.querySelector('img') && twoup.tagName !== 'LI' && !a.closest('.call-to-action')
&& !a.closest('.mini-teasers') && !a.closest('.bg-color-right')) {
&& !a.closest('.mini-teasers') && !a.closest('.bg-color-right') && !a.closest('.product-citations')) {
if (up.childNodes.length === 1 && (up.tagName === 'P' || up.tagName === 'DIV')) {
a.className = 'btn btn-outline-primary'; // default
up.classList.add('button-container');
Expand Down