Skip to content

Commit e006bdd

Browse files
Roman-PRVfshabanov
andauthored
fix: repaire pdf titles ml-364 (#373)
* feat(bot): add requirement to start with a title ml-364 * fix(frontend): fix inconsistent header hierarchy for PDF ml-364 * feat(frontend): change heading size ml-364 --------- Co-authored-by: Farid Shabanov <[email protected]>
1 parent c027cba commit e006bdd

File tree

9 files changed

+110
-17
lines changed

9 files changed

+110
-17
lines changed

apps/frontend/src/libs/components/meeting-pdf/libs/components/render-node.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Text, View } from "~/libs/components/components.js";
2-
import { HEADING_LEVEL_PRIMARY } from "~/libs/constants/constants.js";
32
import {
43
type BlockContent,
54
type ListItem,
65
type PhrasingContent,
76
} from "~/libs/types/types.js";
87

8+
import { getHeadingStyle } from "../helpers/get-heading-style.js";
99
import { styles } from "../styles/meeting-pdf.styles.js";
1010

1111
type MdNode = BlockContent | ListItem | PhrasingContent;
@@ -42,10 +42,7 @@ const renderNode = (node: MdNode, key: string): React.ReactElement => {
4242

4343
switch (node.type) {
4444
case "heading": {
45-
const style =
46-
node.depth === HEADING_LEVEL_PRIMARY
47-
? styles.heading1
48-
: styles.heading2;
45+
const style = getHeadingStyle(node.depth);
4946

5047
return (
5148
<Text key={key} style={style}>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { HeadingLevel } from "~/libs/enums/enums.js";
2+
3+
import { styles } from "../styles/meeting-pdf.styles.js";
4+
5+
const getHeadingStyle = (
6+
depth: number,
7+
): {
8+
fontSize: number;
9+
fontWeight: string;
10+
marginBottom: number;
11+
} => {
12+
switch (depth) {
13+
case HeadingLevel.H1: {
14+
return styles.heading1;
15+
}
16+
17+
case HeadingLevel.H2: {
18+
return styles.heading2;
19+
}
20+
21+
case HeadingLevel.H3: {
22+
return styles.heading3;
23+
}
24+
25+
case HeadingLevel.H4: {
26+
return styles.heading4;
27+
}
28+
29+
case HeadingLevel.H5: {
30+
return styles.heading5;
31+
}
32+
33+
case HeadingLevel.H6: {
34+
return styles.heading6;
35+
}
36+
37+
default: {
38+
return styles.heading1;
39+
}
40+
}
41+
};
42+
43+
export { getHeadingStyle };

apps/frontend/src/libs/components/meeting-pdf/libs/styles/meeting-pdf.styles.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,57 @@ import { StyleSheet } from "@react-pdf/renderer";
33
const styles = StyleSheet.create({
44
bold: { fontWeight: "bold" },
55
bullet: { fontSize: 12, width: 10 },
6-
heading1: { fontSize: 18, fontWeight: "bold", marginBottom: 8 },
7-
heading2: { fontSize: 16, fontWeight: "bold", marginBottom: 7 },
6+
heading1: {
7+
fontSize: 20,
8+
fontWeight: "bold",
9+
marginBottom: 10,
10+
},
11+
heading2: {
12+
fontSize: 18,
13+
fontWeight: "bold",
14+
marginBottom: 8,
15+
},
16+
heading3: {
17+
fontSize: 16,
18+
fontWeight: "600",
19+
marginBottom: 7,
20+
},
21+
heading4: {
22+
fontSize: 16,
23+
fontStyle: "italic",
24+
fontWeight: "600",
25+
marginBottom: 6,
26+
},
27+
heading5: {
28+
fontSize: 14,
29+
fontStyle: "italic",
30+
fontWeight: "500",
31+
marginBottom: 5,
32+
},
33+
heading6: {
34+
fontSize: 12,
35+
fontStyle: "italic",
36+
fontWeight: "500",
37+
marginBottom: 4,
38+
},
839
italic: { fontStyle: "italic" },
40+
line: {
41+
borderBottomColor: "#000",
42+
borderBottomWidth: 1,
43+
marginVertical: 8,
44+
},
945
list: {},
1046
listItem: { flexDirection: "row" },
1147
page: { padding: 50 },
1248
paragraph: { fontSize: 12, lineHeight: 1.4, marginBottom: 6 },
1349
section: { marginBottom: 20 },
50+
sectionHeader: {
51+
fontSize: 20,
52+
fontWeight: "bold",
53+
margin: "auto",
54+
},
1455
text: { fontSize: 12, lineHeight: 1.5 },
15-
title: { fontSize: 20, fontWeight: "bold", marginBottom: 10 },
56+
title: { fontSize: 22, fontWeight: "bold", marginBottom: 10 },
1657
});
1758

1859
export { styles };

apps/frontend/src/libs/components/meeting-pdf/meeting-pdf.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ const MeetingPdf: React.FC<MeetingPdfProperties> = ({
2121
</Text>
2222
</View>
2323

24+
<Text style={styles.sectionHeader}>SUMMARY SECTION</Text>
25+
<View style={styles.line} />
2426
<View style={styles.section}>{renderMarkdown(summary)}</View>
2527

28+
<Text style={styles.sectionHeader}>ACTION POINTS</Text>
29+
<View style={styles.line} />
2630
<View style={styles.section}>{renderMarkdown(actionItems)}</View>
2731

2832
<View style={styles.section}>
29-
<Text style={styles.heading1}>Transcript</Text>
33+
<Text style={styles.sectionHeader}>TRANSCRIPTION</Text>
34+
<View style={styles.line} />
3035
{renderMarkdown(transcription)}
3136
</View>
3237
</Page>

apps/frontend/src/libs/constants/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { ACCEPTED_IMAGE_TYPES } from "./avatar-types.constant.js";
22
export { CREATE_MEETING_FORM_DEFAULT_VALUES } from "./create-meeting-form-default-values.constant.js";
3-
export { HEADING_LEVEL_PRIMARY } from "./heading-level-primary.js";
43
export { NAVIGATION_ITEMS } from "./navigation-items.constant.js";
54
export {
65
EMPTY_ARRAY_LENGTH,

apps/frontend/src/libs/constants/heading-level-primary.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/frontend/src/libs/enums/enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { ContactInfo } from "./contact-info.enum.js";
1010
export { DataStatus } from "./data-status.enum.js";
1111
export { DOMEvent } from "./dom-event.enum.js";
1212
export { FeatureAnimation } from "./feature-animation.enum.js";
13+
export { HeadingLevel } from "./heading-level.enum.js";
1314
export { InputPasswordType } from "./input-password-type.enum.js";
1415
export {
1516
LandingBgRingType,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const HeadingLevel = {
2+
H1: 1,
3+
H2: 2,
4+
H3: 3,
5+
H4: 4,
6+
H5: 5,
7+
H6: 6,
8+
} as const;
9+
10+
export { HeadingLevel };

package-lock.json

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

0 commit comments

Comments
 (0)