Докрутил парсер, добавил стили проектов

This commit is contained in:
ifraimka1 committed 2025-04-30 12:30:33 +03:00
1 parent ac25dff111
commit f22179654b
3 files changed
+145 -4

No files matched your search

+4 -1
View File
@@ -19,7 +19,7 @@ export const parseContent = (html: string): ParsedContent[] => {
} }
// Обработка медиа-элементов (img внутри figure) // Обработка медиа-элементов (img внутри figure)
if (node.type === "figure") { if (node.type === "figure" && node.props.className.includes('wp-block-image')) {
const imgSrc = node.props.children?.props?.src; const imgSrc = node.props.children?.props?.src;
if (imgSrc) { if (imgSrc) {
mediaBuffer.push(imgSrc); mediaBuffer.push(imgSrc);
@@ -48,5 +48,8 @@ export const parseContent = (html: string): ParsedContent[] => {
result.push({ type: "mediablock", value: [...mediaBuffer] }); result.push({ type: "mediablock", value: [...mediaBuffer] });
} }
console.log('nonParsedElements', elements);
console.log('parsedElements', result);
return result; return result;
}; };
+137
View File
@@ -0,0 +1,137 @@
$color-highlight: #072AC8;
$table-header-color: #EEEEEE;
$table-body-bg: #ffffff;
$color-usual: #ACACAC;
$border-raduis: 16px;
$background-tape: #F5F5F7;
:root {
--wp--preset--spacing--10: 5%;
--wp--preset--spacing--20: 10%;
--wp--preset--spacing--30: 15%;
--wp--preset--spacing--40: 20%;
--wp--preset--spacing--50: 25%;
--wp--preset--spacing--60: 30%;
}
.project {
.header {
text-align: center;
margin-bottom: 4em;
}
.wp-block-columns {
margin-bottom: 2em;
}
.is-layout-flex {
display: flex;
justify-content: space-between;
gap: 2em;
figure {
img {
max-width: 100%;
height: auto;
object-fit: contain !important; // Wordpress накидывает styles к элементу, приходится перебивать
}
}
}
.has-text-align-center {
text-align: center;
}
.has-text-align-justify {
text-align: justify;
}
.is-style-rounded * {
border-radius: 16px;
}
.wp-block-pullquote {
* {
margin-bottom: 0;
}
blockquote {
display: flex;
justify-content: center;
position: absolute;
left: 0;
width: 100%;
padding: 16px 0;
background: $background-tape;
p {
display: inline-block;
max-width: 40%;
text-align: center;
}
}
}
.table-wrapper {
border: 1px solid $table-header-color;
border-radius: $border-raduis;
overflow-x: auto;
background: $table-header-color;
.comparison-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
font-size: 20px;
th,
td {
max-width: 200px;
border: none;
padding: 12px 16px;
vertical-align: middle;
background: $table-body-bg;
}
tr:not(:last-child) th,
tr:not(:last-child) td {
border-bottom: 1px solid $table-header-color;
}
tr:last-child th,
tr:last-child td {
border-bottom: 1px solid $table-body-bg;
}
thead th {
background-color: $table-header-color;
font-weight: 400;
padding: 12px 16px;
border: none;
}
tbody td:not(:first-child),
thead th:not(:first-child) {
text-align: center;
}
thead th.highlight {
font-weight: 600;
font-size: 24px;
border-radius: 10px 10px 0 0;
border-bottom: 1px solid $color-highlight;
color: #ffffff;
background-color: $color-highlight;
}
tbody td.highlight {
border: 1px solid $color-highlight;
border-top: none;
.icon {
filter: brightness(0) saturate(100%) invert(26%) sepia(94%) saturate(2350%) hue-rotate(225deg) brightness(95%) contrast(93%);
}
}
}
}
}
+4 -3
View File
@@ -1,10 +1,11 @@
import { ReactNode } from "react"; import { ReactNode } from "react";
import MediaBlock from "@/widgets/MediaBlock/MediaBlock"; import MediaBlock from "@/widgets/MediaBlock/MediaBlock";
import { PageContent, PageHeader } from "@/widgets/WpPost"; import { PageContent, PageHeader } from "@/widgets/WpPost";
import { App } from "@/shared/types/app"; import { App } from "@/shared/types/app";
import "./Projects.scss";
interface WpPostProps { interface WpPostProps {
post: App.WpPostPage; post: App.WpPostPage;
children?: ReactNode; children?: ReactNode;
@@ -15,7 +16,7 @@ export default function WpPost({
children, children,
}: WpPostProps) { }: WpPostProps) {
return ( return (
<> <div className={post.categories?.includes('projects') ? "project" : ""}>
<PageHeader className="header"> <PageHeader className="header">
<h1>{post.title}</h1> <h1>{post.title}</h1>
</PageHeader> </PageHeader>
@@ -29,6 +30,6 @@ export default function WpPost({
})} })}
{children} {children}
</PageContent> </PageContent>
</> </div>
); );
} }