@san-siva/blogkit 1.1.25 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"MermaidDynamic.d.ts","sourceRoot":"","sources":["../../../src/dynamicComponents/MermaidDynamic.tsx"],"names":[],"mappings":"AAQA,UAAU,iBAAiB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAmBD,QAAA,MAAM,OAAO,GAAI,2CAKd,iBAAiB,4CAsCnB,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"MermaidDynamic.d.ts","sourceRoot":"","sources":["../../../src/dynamicComponents/MermaidDynamic.tsx"],"names":[],"mappings":"AASA,UAAU,iBAAiB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAmBD,QAAA,MAAM,OAAO,GAAI,2CAKd,iBAAiB,4CAsDnB,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@san-siva/blogkit",
3
- "version": "1.1.25",
3
+ "version": "1.1.28",
4
4
  "description": "A reusable blog component library for React/Next.js applications with code highlighting, diagrams, and rich content features",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -61,6 +61,7 @@
61
61
  "@types/react": "^18.3.12",
62
62
  "@types/react-dom": "^18.3.1",
63
63
  "@types/react-syntax-highlighter": "^15.5.13",
64
+ "mermaid": "^10.0.0",
64
65
  "postcss": "^8.4.49",
65
66
  "postcss-url": "^10.1.3",
66
67
  "rollup": "^4.27.4",
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
 
5
5
  import mermaid from 'mermaid';
6
6
 
7
+ import CalloutStatic from '../staticComponents/CalloutStatic';
7
8
  import styles from '../styles/Mermaid.module.scss';
8
9
 
9
10
  interface MermaidProperties {
@@ -37,29 +38,31 @@ const Mermaid = ({
37
38
  hasMarginDown = false,
38
39
  }: MermaidProperties) => {
39
40
  const [enabled, setEnabled] = useState(false);
41
+ const [error, setError] = useState<string | null>(null);
40
42
  const mermaidReference = useRef<HTMLDivElement>(null);
43
+ const renderCount = useRef(0);
41
44
 
42
45
  const initializeMermaid = useCallback(async () => {
46
+ if (!mermaidReference.current || !code) return;
47
+ const renderId = `mermaid-diagram-${id}-${++renderCount.current}`;
48
+ document.getElementById(renderId)?.remove();
43
49
  try {
44
- if (!mermaidReference.current || !code) return;
45
- const { svg, bindFunctions } = await mermaid.render(
46
- `mermaid-diagram-${id}`,
47
- code
48
- );
49
- if (!svg) return;
50
- mermaidReference.current.innerHTML = svg || '';
50
+ const { svg, bindFunctions } = await mermaid.render(renderId, code);
51
+ if (!mermaidReference.current || !svg) return;
52
+ mermaidReference.current.innerHTML = svg;
51
53
  bindFunctions?.(mermaidReference.current);
52
54
  setEnabled(true);
53
- } catch (error) {
54
- console.error('Failed to render Mermaid diagram:', error);
55
+ } catch (err) {
56
+ const message =
57
+ err instanceof Error ? err.message : 'Failed to render diagram';
58
+ setError(message);
55
59
  }
56
60
  }, [code, id]);
57
61
 
58
62
  useEffect(() => {
59
- if (!code || !mermaidReference.current) return;
60
- const timer = setTimeout(async () => {
61
- await initializeMermaid();
62
- }, 100);
63
+ if (!code) return;
64
+ setError(null);
65
+ const timer = setTimeout(initializeMermaid, 100);
63
66
  return () => clearTimeout(timer);
64
67
  }, [code, initializeMermaid]);
65
68
 
@@ -69,8 +72,22 @@ const Mermaid = ({
69
72
  ${hasMarginUp ? styles['margin-top--1'] : ''}
70
73
  ${hasMarginDown ? styles['margin-bottom--2'] : ''}`}
71
74
  >
72
- {enabled ? null : <p>Diagram Loading...</p>}
73
- <div ref={mermaidReference} id={id}></div>
75
+ {error ? (
76
+ <CalloutStatic type="error">
77
+ <p>
78
+ <b>Diagram error:</b> {error}
79
+ </p>
80
+ </CalloutStatic>
81
+ ) : !enabled ? (
82
+ <CalloutStatic type="info">
83
+ <p>Rendering diagram...</p>
84
+ </CalloutStatic>
85
+ ) : null}
86
+ <div
87
+ ref={mermaidReference}
88
+ id={id}
89
+ style={enabled ? undefined : { display: 'none' }}
90
+ />
74
91
  </div>
75
92
  );
76
93
  };
@@ -46,6 +46,20 @@
46
46
  font-weight: stylekit.$font-weight--500;
47
47
  font-size: stylekit.$font-size--h6;
48
48
  }
49
+
50
+ .blog-section {
51
+ margin-bottom: stylekit.space(2);
52
+ > .blog-section__title {
53
+ margin-top: stylekit.space(2);
54
+ font-size: stylekit.$font-size--p;
55
+ }
56
+
57
+ .blog-section {
58
+ > .blog-section__title {
59
+ font-weight: stylekit.$font-weight--400;
60
+ }
61
+ }
62
+ }
49
63
  }
50
64
  }
51
65
  }
@@ -1,45 +1,45 @@
1
1
  @use '@san-siva/stylekit/styles/index.module.scss' as stylekit;
2
2
 
3
3
  .check-list {
4
- display: flex;
5
- flex-direction: column;
6
- gap: stylekit.space(1);
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: stylekit.space(1);
7
7
 
8
- &__item {
9
- display: flex;
10
- flex-direction: row;
11
- align-items: center;
12
- justify-content: flex-start;
8
+ &__item {
9
+ display: flex;
10
+ flex-direction: row;
11
+ align-items: center;
12
+ justify-content: flex-start;
13
13
 
14
- &__input {
15
- height: stylekit.rem(12);
16
- width: stylekit.rem(12);
17
- border: 1px solid stylekit.$color--grey-medium;
18
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
19
- margin-right: stylekit.space(1);
20
- flex-shrink: 0;
14
+ &__input {
15
+ height: stylekit.rem(12);
16
+ width: stylekit.rem(12);
17
+ border: 1px solid stylekit.$color--grey-medium;
18
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
19
+ margin-right: stylekit.space(1);
20
+ flex-shrink: 0;
21
21
 
22
- &--checked {
23
- height: stylekit.rem(14);
24
- width: stylekit.rem(14);
25
- background-color: stylekit.$color--base;
26
- border: 0px solid stylekit.$color--primary;
27
- background-image: url('../assets/tick.svg');
28
- background-size: cover;
29
- }
30
- }
22
+ &--checked {
23
+ height: stylekit.rem(14);
24
+ width: stylekit.rem(14);
25
+ background-color: stylekit.$color--base;
26
+ border: 0px solid stylekit.$color--primary;
27
+ background-image: url('../assets/tick.svg');
28
+ background-size: cover;
29
+ }
30
+ }
31
31
 
32
- > p {
33
- font-size: stylekit.$font-size--small;
34
- margin: 0;
35
- }
36
- }
32
+ > p {
33
+ font-size: stylekit.$font-size--small;
34
+ margin: 0;
35
+ }
36
+ }
37
37
  }
38
38
 
39
39
  .margin-top--1 {
40
- margin-top: stylekit.space(1);
40
+ margin-top: stylekit.space(1);
41
41
  }
42
42
 
43
43
  .margin-bottom--2 {
44
- margin-bottom: stylekit.space(2);
44
+ margin-bottom: stylekit.space(2);
45
45
  }