diff --git a/library/lib/svgs/classDiagram/ClassSVG.tsx b/library/lib/svgs/classDiagram/ClassSVG.tsx
index 6787f76..32b12b1 100644
--- a/library/lib/svgs/classDiagram/ClassSVG.tsx
+++ b/library/lib/svgs/classDiagram/ClassSVG.tsx
@@ -24,25 +24,20 @@ export function ClassSVG({
transformScale,
svgAttributes,
}: ClassSVGProps) {
- const headerHeight = 50
- const attributeHeight = 30
- const methodHeight = 30
+ const margin = 2 // Padding inside the SVG content
+ const headerHeight = 50 // Height of the header section
+ const attributeHeight = 30 // Height per attribute
+ const methodHeight = 30 // Height per method
+ const innerWidth = width - 2 * margin // Adjusted content width
+ const padding = 10 // Inner padding for text
+ const maxTextWidth = innerWidth - 2 * padding // Maximum width for text
- const padding = 10 // Padding inside the SVG
- const maxTextWidth = width - 2 * padding // Maximum width for text
-
- // Helper function to truncate individual lines
const truncateText = (text: string, maxWidth: number): string => {
- const approxCharWidth = 7 // Approximation for character width in font size 14px
+ const approxCharWidth = 7 // Approximate width of a character in font size 14px
const maxChars = Math.floor(maxWidth / approxCharWidth)
-
- if (text.length > maxChars) {
- return `${text.slice(0, maxChars - 3)}...` // Truncate and add ellipsis
- }
- return text
+ return text.length > maxChars ? `${text.slice(0, maxChars - 3)}...` : text
}
- // Memoized truncated attributes
const truncatedAttributes = useMemo(
() =>
attributes.map((attribute) => ({
@@ -52,7 +47,6 @@ export function ClassSVG({
[attributes, maxTextWidth]
)
- // Memoized truncated methods
const truncatedMethods = useMemo(
() =>
methods.map((method) => ({
@@ -71,32 +65,42 @@ export function ClassSVG({
)
diff --git a/library/lib/svgs/classDiagram/PackageSVG.tsx b/library/lib/svgs/classDiagram/PackageSVG.tsx
index 41444a7..6a7b933 100644
--- a/library/lib/svgs/classDiagram/PackageSVG.tsx
+++ b/library/lib/svgs/classDiagram/PackageSVG.tsx
@@ -16,10 +16,11 @@ export const PackageSVG = ({
svgAttributes,
transformScale,
}: PackageSVGProps) => {
- const padding = 5 // Padding inside the SVG content
+ const margin = 2 // Padding inside the SVG content
const headerHeight = 10 // Height of the top path
- const innerWidth = width - 2 * padding // Adjusted content width
- const innerHeight = height - 2 * padding // Adjusted content height
+ const innerWidth = width - 2 * margin // Adjusted content width
+ const innerHeight = height - 2 * margin // Adjusted content height
+ const padding = 5
return (