mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 06:19:45 +00:00
Обработчик для "цитат"
This commit is contained in:
1 parent
ce924a4010
commit
9c24289c07
1 file changed
+29
-2
@@ -1,10 +1,37 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { PageHeader, PageContent } from "../components";
|
||||
import { MediaBlock, ProjectList } from "../../components";
|
||||
|
||||
import "./PagePost.styles.scss";
|
||||
|
||||
function PagePost({ post, isLab = false }) {
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
const parent = entry.target;
|
||||
const blockquoteElement = parent.querySelector('blockquote');
|
||||
|
||||
if (blockquoteElement) {
|
||||
const blockquoteHeight = blockquoteElement.offsetHeight;
|
||||
parent.style.marginBottom = `calc(${blockquoteHeight}px + 2em)`;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const setQuotesProps = () => {
|
||||
const parentElements = document.querySelectorAll('.wp-block-pullquote');
|
||||
|
||||
parentElements.forEach((tapeElement) => {
|
||||
resizeObserver.observe(tapeElement);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setQuotesProps();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={post.tag === 'custom' ? "custom" : ""}>
|
||||
<PageHeader className="header">
|
||||
<h1>{typeof post !== 'undefined' && post.name}</h1>
|
||||
</PageHeader>
|
||||
@@ -19,7 +46,7 @@ function PagePost({ post, isLab = false }) {
|
||||
}
|
||||
{post && isLab && <ProjectList laboratory={post.tag} />}
|
||||
</PageContent>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user