Skip to content

Commit 7946b89

Browse files
authored
feat: blog post header extra buttons (#266)
* feat: blog post header extra buttons * fix: tests * fix: tests * fix: requested changes
1 parent a8e30c7 commit 7946b89

16 files changed

+63
-17
lines changed

package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"@commitlint/config-conventional": "^17.4.3",
9999
"@diplodoc/transform": "^4.10.8",
100100
"@gravity-ui/eslint-config": "^3.2.0",
101+
"@gravity-ui/icons": "^2.13.0",
101102
"@gravity-ui/page-constructor": "^6.6.1",
102103
"@gravity-ui/prettier-config": "^1.1.0",
103104
"@gravity-ui/stylelint-config": "^4.0.1",
-1.13 KB
Loading
-205 Bytes
Loading

src/components/PostInfo/PostInfo.scss

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ $block: '.#{$namespace}post-info';
88
@include text-size(body-2);
99

1010
display: flex;
11-
padding-right: $indentSM;
12-
padding-top: $indentXXS;
1311
flex-wrap: nowrap;
1412
align-items: center;
13+
margin-top: $indentXXS;
14+
15+
&:not(:last-child) {
16+
margin-right: $indentSM;
17+
}
1518

1619
&_size {
1720
&_s {
@@ -24,23 +27,20 @@ $block: '.#{$namespace}post-info';
2427
}
2528

2629
&_save {
30+
padding: 0;
2731
background: none;
2832
color: inherit;
2933
border: none;
30-
padding: 0;
31-
font: inherit;
34+
font-family: inherit;
35+
font-weight: inherit;
3236
cursor: pointer;
3337
}
34-
}
35-
36-
&__item:last-child {
37-
@include text-size(body-2);
3838

39-
display: flex;
40-
padding-right: 0px;
41-
padding-top: $indentXXS;
42-
flex-wrap: nowrap;
43-
align-items: center;
39+
&_extra {
40+
&:hover {
41+
color: var(--g-color-text-primary);
42+
}
43+
}
4444
}
4545

4646
&__switcher {
@@ -71,6 +71,7 @@ $block: '.#{$namespace}post-info';
7171
}
7272
}
7373

74+
$block: &;
7475
&__container {
7576
display: flex;
7677
align-items: flex-start;
@@ -81,6 +82,10 @@ $block: '.#{$namespace}post-info';
8182
&_theme {
8283
&_dark {
8384
color: var(--g-color-text-light-secondary);
85+
86+
#{$block}__item_extra:hover {
87+
color: var(--g-color-text-light-primary);
88+
}
8489
}
8590
}
8691
}

src/components/PostInfo/PostInfo.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ import {Sharing} from './components/Sharing';
1212
import {getQaAttributes} from '../../utils/common';
1313

1414
import './PostInfo.scss';
15+
import {SettingsContext} from '../../contexts/SettingsContext';
1516

1617
const b = block('post-info');
1718

19+
export type CustomInfoItemComponent = React.ComponentType<{post: PostData}>;
20+
1821
type PostInfoProps = QAProps & {
1922
postId: PostData['id'];
2023
readingTime: PostData['readingTime'];
@@ -43,7 +46,8 @@ export const PostInfo = ({
4346
qa,
4447
analyticsEventsContainer,
4548
}: PostInfoProps) => {
46-
const {likes} = React.useContext(PostPageContext);
49+
const {post, likes} = React.useContext(PostPageContext);
50+
const {extraInfoItems} = React.useContext(SettingsContext);
4751
const qaAttributes = getQaAttributes(qa, 'date', 'reading-time', 'save');
4852

4953
return (
@@ -62,6 +66,11 @@ export const PostInfo = ({
6266
qa={qaAttributes.save}
6367
/>
6468
)}
69+
{extraInfoItems?.map((Component, index) => (
70+
<div key={index} className={b('item', {extra: true})}>
71+
<Component post={post} />
72+
</div>
73+
))}
6574
</div>
6675
);
6776
};
-1.18 KB
Loading
-39 Bytes
Loading
Loading
Loading

0 commit comments

Comments
 (0)