Skip to content

Commit

Permalink
Check for block content and use as header if exists, updated twitter …
Browse files Browse the repository at this point in the history
…icon ref
  • Loading branch information
ryanmparrish committed Mar 8, 2024
1 parent 80371d3 commit c4ec916
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion libs/blocks/share/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@

.share.inline {
margin: 0 auto;
text-align: center;
text-align: unset;
padding: 8px 0 16px;
}

.share.inline .tracking-header {
margin-bottom: 1em;
}

.share.inline p.icon-container {
justify-content: flex-start;
margin: 0;
Expand Down
10 changes: 7 additions & 3 deletions libs/blocks/share/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default async function decorate(block) {
'pinterest',
'reddit',
];
block.innerHTML = '';
const clipboardSupport = !!navigator.clipboard;
if (clipboardSupport) platforms.push('clipboard');
const svgs = await getSVGsfromFile(
Expand Down Expand Up @@ -101,8 +100,13 @@ export default async function decorate(block) {
return null;
}
};
if (!block.classList.contains('inline')) {
const heading = toSentenceCase(await replaceKey('share-this-page', config));
const authoredContent = block.innerText.trim() !== '';
if (authoredContent) {
const rows = block.querySelectorAll(':scope > div');
rows[0].classList.add('tracking-header');
} else if (!authoredContent && !block.classList.contains('inline')) {
const heading = toSentenceCase(await replaceKey('share-this-page', config));
block.innerHTML = '';
block.append(createTag('p', { class: 'tracking-header' }, heading));
}
const container = createTag('p', { class: 'icon-container' });
Expand Down
9 changes: 8 additions & 1 deletion libs/blocks/share/share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c4ec916

Please sign in to comment.