Skip to content

feat!: replace HTML with YFMWrapper [WIP] #217

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gravity-ui/blog-constructor",
"version": "6.5.0",
"version": "7.0.0-alpha.2",
"description": "Gravity UI Blog Constructor",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -78,7 +78,7 @@
},
"peerDependencies": {
"@diplodoc/transform": "^4.10.7",
"@gravity-ui/page-constructor": "^5.0.0",
"@gravity-ui/page-constructor": "^6.0.0-alpha.2",
"@gravity-ui/uikit": "^6.26.0",
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
},
Expand All @@ -89,7 +89,7 @@
"@commitlint/config-conventional": "^17.4.3",
"@diplodoc/transform": "^4.10.8",
"@gravity-ui/eslint-config": "^3.1.1",
"@gravity-ui/page-constructor": "^5.27.0",
"@gravity-ui/page-constructor": "^6.0.0-alpha.2",
"@gravity-ui/prettier-config": "^1.1.0",
"@gravity-ui/stylelint-config": "^4.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/blocks/Suggest/Suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const Suggest = ({paddingTop = 'l', paddingBottom = 'l'}: SuggestProps) =
<SliderBlock
slidesToShow={{xl: 3, lg: 2, sm: 1}}
title={{text: i18n(Keyset.TitleSuggest)}}
lazyLoad={false}
>
{suggestedPosts.map((post) => (
<PostCard key={post.id} analyticsEvents={suggestGoals} post={post} />
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/YFM/YFM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const YFM = (props: YFMProps) => {
blog: true,
resetPaddings: true,
}}
className={b({'no-list-reset': true})}
contentClassName={b({'no-list-reset': true})}
/>
</Wrapper>
);
Expand Down
12 changes: 8 additions & 4 deletions src/components/PostCard/PostCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ $block: '.#{$namespace}post-card';
}

&__title {
margin-bottom: $indentXXXS;

&_size_s {
@include heading4();
@include add-specificity(&) {
@include heading4();
margin-bottom: $indentXXXS;
}
}

&_size_m {
@include heading2();
@include add-specificity(&) {
@include heading2();
margin-bottom: $indentXXXS;
}
}
}

Expand Down
24 changes: 14 additions & 10 deletions src/components/PostCard/PostCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useContext, useMemo} from 'react';
import {AnalyticsEventsProp, CardBase, HTML, YFMWrapper} from '@gravity-ui/page-constructor';
import {AnalyticsEventsProp, CardBase, YFMWrapper} from '@gravity-ui/page-constructor';
import {useUniqId} from '@gravity-ui/uikit';

import {LikesContext} from '../../contexts/LikesContext';
Expand Down Expand Up @@ -91,17 +91,21 @@ export const PostCard = ({
{tags[0].name}
</div>
)}
{title &&
React.createElement(
titleHeadingLevel,
{className: b('title', {size})},
<span>
<HTML id={titleId}>{title}</HTML>
</span>,
)}
{title && (
<YFMWrapper
contentClassName={b('title', {size})}
content={title}
modifiers={{
blog: true,
blogCard: true,
}}
id={titleId}
tagName={titleHeadingLevel}
/>
)}
{description && (
<YFMWrapper
className={b('description')}
contentClassName={b('description')}
content={description}
modifiers={{
blog: size === 'm',
Expand Down
2 changes: 1 addition & 1 deletion src/data/transformPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const transformPost = ({postData, lang, options: {plugins} = {}}: Transfo

return {
...post,
title,
title: yfmTransformer(lang, title as string, {plugins}),
tags,
textTitle: typografToText(title, lang),
htmlTitle: typografToHTML(title, lang),
Expand Down
42 changes: 21 additions & 21 deletions styles/yfm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@
@include text-size(body-3);
color: var(--g-color-text-primary);

h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child {
padding: 0;
margin-top: 0;
padding-top: 0;
}

h2 {
@include text-size(display-2);
}

h3 {
@include text-size(header-2);
}

h4 {
@include text-size(header-1);
}

@include add-specificity(&) {
h1,
h2,
Expand All @@ -40,6 +19,27 @@
padding-top: 0;
font-weight: var(--g-text-header-font-weight);
}

h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child {
padding: 0;
margin-top: 0;
padding-top: 0;
}

h2 {
@include text-size(display-2);
}

h3 {
@include text-size(header-2);
}

h4 {
@include text-size(header-1);
}
}

blockquote,
Expand Down