@san-siva/blogkit 1.1.20 → 1.1.22

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.
Files changed (74) hide show
  1. package/dist/cjs/components/BlogSection.js +2 -2
  2. package/dist/cjs/components/BlogSection.js.map +1 -1
  3. package/dist/cjs/dynamicComponents/BlogDynamic.js +31 -181
  4. package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -1
  5. package/dist/cjs/dynamicComponents/BlogSectionDynamic.js +16 -8
  6. package/dist/cjs/dynamicComponents/BlogSectionDynamic.js.map +1 -1
  7. package/dist/cjs/hooks/useCategoryTitles.js +104 -0
  8. package/dist/cjs/hooks/useCategoryTitles.js.map +1 -0
  9. package/dist/cjs/hooks/useSectionObserver.js +89 -0
  10. package/dist/cjs/hooks/useSectionObserver.js.map +1 -0
  11. package/dist/cjs/index.css +1 -1
  12. package/dist/cjs/index.css.map +1 -1
  13. package/dist/cjs/staticComponents/BlogSectionStatic.js +2 -5
  14. package/dist/cjs/staticComponents/BlogSectionStatic.js.map +1 -1
  15. package/dist/cjs/staticComponents/TocNodeStatic.js +16 -0
  16. package/dist/cjs/staticComponents/TocNodeStatic.js.map +1 -0
  17. package/dist/cjs/styles/Blog.module.scss.js +1 -1
  18. package/dist/cjs/styles/BlogSection.module.scss.js +1 -1
  19. package/dist/cjs/styles/Callout.module.scss.js +1 -1
  20. package/dist/cjs/styles/TocNode.module.scss.js +8 -0
  21. package/dist/cjs/styles/TocNode.module.scss.js.map +1 -0
  22. package/dist/esm/components/BlogSection.js +2 -2
  23. package/dist/esm/components/BlogSection.js.map +1 -1
  24. package/dist/esm/dynamicComponents/BlogDynamic.js +32 -182
  25. package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -1
  26. package/dist/esm/dynamicComponents/BlogSectionDynamic.js +17 -9
  27. package/dist/esm/dynamicComponents/BlogSectionDynamic.js.map +1 -1
  28. package/dist/esm/hooks/useCategoryTitles.js +102 -0
  29. package/dist/esm/hooks/useCategoryTitles.js.map +1 -0
  30. package/dist/esm/hooks/useSectionObserver.js +87 -0
  31. package/dist/esm/hooks/useSectionObserver.js.map +1 -0
  32. package/dist/esm/index.css +1 -1
  33. package/dist/esm/index.css.map +1 -1
  34. package/dist/esm/staticComponents/BlogSectionStatic.js +2 -5
  35. package/dist/esm/staticComponents/BlogSectionStatic.js.map +1 -1
  36. package/dist/esm/staticComponents/TocNodeStatic.js +12 -0
  37. package/dist/esm/staticComponents/TocNodeStatic.js.map +1 -0
  38. package/dist/esm/styles/Blog.module.scss.js +1 -1
  39. package/dist/esm/styles/BlogSection.module.scss.js +1 -1
  40. package/dist/esm/styles/Callout.module.scss.js +1 -1
  41. package/dist/esm/styles/TocNode.module.scss.js +4 -0
  42. package/dist/esm/styles/TocNode.module.scss.js.map +1 -0
  43. package/dist/types/components/BlogSection.d.ts +0 -1
  44. package/dist/types/components/BlogSection.d.ts.map +1 -1
  45. package/dist/types/dynamicComponents/BlogDynamic.d.ts +1 -1
  46. package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -1
  47. package/dist/types/dynamicComponents/BlogSectionDynamic.d.ts +0 -1
  48. package/dist/types/dynamicComponents/BlogSectionDynamic.d.ts.map +1 -1
  49. package/dist/types/hooks/useCategoryTitles.d.ts +22 -0
  50. package/dist/types/hooks/useCategoryTitles.d.ts.map +1 -0
  51. package/dist/types/hooks/useSectionObserver.d.ts +11 -0
  52. package/dist/types/hooks/useSectionObserver.d.ts.map +1 -0
  53. package/dist/types/staticComponents/BlogSectionStatic.d.ts +1 -2
  54. package/dist/types/staticComponents/BlogSectionStatic.d.ts.map +1 -1
  55. package/dist/types/staticComponents/TocNodeStatic.d.ts +16 -0
  56. package/dist/types/staticComponents/TocNodeStatic.d.ts.map +1 -0
  57. package/package.json +5 -3
  58. package/src/components/BlogSection.tsx +0 -4
  59. package/src/dynamicComponents/BlogDynamic.tsx +42 -253
  60. package/src/dynamicComponents/BlogSectionDynamic.tsx +38 -21
  61. package/src/hooks/useCategoryTitles.ts +148 -0
  62. package/src/hooks/useSectionObserver.ts +102 -0
  63. package/src/staticComponents/BlogSectionStatic.tsx +2 -13
  64. package/src/staticComponents/TocNodeStatic.tsx +52 -0
  65. package/src/styles/Blog.module.scss +0 -30
  66. package/src/styles/Blog.module.scss.d.ts +0 -4
  67. package/src/styles/BlogHeader.module.scss +6 -5
  68. package/src/styles/BlogLink.module.scss +1 -1
  69. package/src/styles/BlogSection.module.scss +26 -21
  70. package/src/styles/BlogSection.module.scss.d.ts +1 -2
  71. package/src/styles/CodeBlock.module.scss +2 -2
  72. package/src/styles/Table.module.scss +1 -1
  73. package/src/styles/TocNode.module.scss +49 -0
  74. package/src/styles/TocNode.module.scss.d.ts +11 -0
@@ -6,31 +6,20 @@ interface BlogSectionStaticProperties {
6
6
  title?: string;
7
7
  category?: string;
8
8
  children?: ReactNode;
9
- increaseMarginBottom?: boolean;
10
9
  }
11
10
 
12
11
  const BlogSectionStatic = ({
13
12
  title = '',
14
13
  category = '',
15
14
  children = null,
16
- increaseMarginBottom = false,
17
15
  }: BlogSectionStaticProperties) => {
18
16
  const titleWithCategory = category ? `${category} - ${title}` : title;
19
17
  const id = generateIdForBlogTitle(titleWithCategory);
20
18
 
21
19
  return (
22
- <div
23
- className={`${styles['blog-section']}
24
- ${
25
- increaseMarginBottom
26
- ? styles['margin-bottom--9']
27
- : styles['margin-bottom--6']
28
- }`}
29
- data-title={title}
30
- data-id={id}
31
- >
20
+ <div className={styles['blog-section']} data-title={title} data-id={id}>
32
21
  {title ? (
33
- <h4 className={styles['blog-section__title']}>{title}</h4>
22
+ <h3 className={styles['blog-section__title']}>{title}</h3>
34
23
  ) : null}
35
24
  {children}
36
25
  </div>
@@ -0,0 +1,52 @@
1
+ import type { MouseEvent } from 'react';
2
+
3
+ import styles from '../styles/TocNode.module.scss';
4
+
5
+ export interface TocNode {
6
+ id: string;
7
+ title: string;
8
+ depth: number;
9
+ children: TocNode[];
10
+ }
11
+
12
+ interface TocNodeProperties {
13
+ node: TocNode;
14
+ index: number;
15
+ visibleTitle: string | null;
16
+ onClick: (e: MouseEvent<HTMLParagraphElement>) => void;
17
+ }
18
+
19
+ const TocNode = ({ node, index, visibleTitle, onClick }: TocNodeProperties) => (
20
+ <div>
21
+ <p
22
+ data-idx={index}
23
+ data-id={node.id}
24
+ className={[
25
+ styles['toc-node__title'],
26
+ node.id === visibleTitle ? styles['toc-node__title--active'] : '',
27
+ node.depth === 1 ? styles['toc-node__title--sub'] : '',
28
+ node.depth === 2 ? styles['toc-node__title--sub-sub'] : '',
29
+ ].join(' ')}
30
+ onClick={onClick}
31
+ >
32
+ {node.title}
33
+ </p>
34
+ {node.children.length > 0 && (
35
+ <div
36
+ className={`${styles['toc-node__children']} ${styles[`toc-node__children--${node.depth === 0 ? 'sub' : 'sub-sub'}`]}`}
37
+ >
38
+ {node.children.map((child, i) => (
39
+ <TocNode
40
+ key={child.id}
41
+ node={child}
42
+ index={i}
43
+ visibleTitle={visibleTitle}
44
+ onClick={onClick}
45
+ />
46
+ ))}
47
+ </div>
48
+ )}
49
+ </div>
50
+ );
51
+
52
+ export default TocNode;
@@ -22,36 +22,6 @@
22
22
  padding-top: $top;
23
23
  padding-right: 0;
24
24
  border-radius: styles.$border-radius--1;
25
-
26
- > .category__title {
27
- display: block;
28
- margin-bottom: styles.space(1);
29
- font-size: styles.$font-size--p-small;
30
- font-weight: styles.$font-weight--500;
31
- cursor: pointer;
32
-
33
- animation: fadeInDown 0.3s ease-in-out;
34
- transition: all 0.3s ease-in-out;
35
-
36
- &--active,
37
- &:hover {
38
- text-decoration: underline;
39
- text-decoration-color: styles.$color--primary;
40
- }
41
-
42
- &--active {
43
- color: styles.$color--primary;
44
- }
45
-
46
- &--sub {
47
- font-size: styles.$font-size--small;
48
- font-weight: styles.$font-weight--400;
49
- }
50
-
51
- &:last-child {
52
- margin-bottom: 0;
53
- }
54
- }
55
25
  }
56
26
  }
57
27
 
@@ -3,11 +3,7 @@ declare const styles: {
3
3
  readonly 'blog__content': string;
4
4
  readonly 'blog__sidebar': string;
5
5
  readonly 'margin-bottom--3': string;
6
- readonly 'margin-bottom-imp--2': string;
7
6
  readonly 'category__header': string;
8
- readonly 'category__title': string;
9
- readonly 'category__title--active': string;
10
- readonly 'category__title--sub': string;
11
7
  };
12
8
 
13
9
  export default styles;
@@ -1,12 +1,13 @@
1
1
  @use '@san-siva/stylekit/styles/index.module.scss' as stylekit;
2
2
 
3
3
  .blog-header {
4
- line-height: stylekit.$line-height--small;
4
+ line-height: stylekit.$line-height--small;
5
+ font-weight: stylekit.$font-weight--800;
5
6
  }
6
7
 
7
8
  .blog-date {
8
- display: block;
9
- margin-bottom: calc(#{stylekit.space(8)} * 2);
10
- color: stylekit.$color--dark;
11
- font-style: italic;
9
+ display: block;
10
+ margin-bottom: calc(#{stylekit.space(8)} * 2);
11
+ color: stylekit.$color--dark;
12
+ font-style: italic;
12
13
  }
@@ -29,7 +29,7 @@
29
29
  > p {
30
30
  font-weight: stylekit.$font-weight--500;
31
31
  font-family: stylekit.$font-family--primary;
32
- font-size: stylekit.$font-size--p-small;
32
+ font-size: stylekit.$font-size--small;
33
33
  margin-right: stylekit.space(0);
34
34
  }
35
35
  }
@@ -1,8 +1,18 @@
1
1
  @use '@san-siva/stylekit/styles/index.module.scss' as stylekit;
2
2
 
3
3
  .blog-section {
4
+ margin-bottom: stylekit.space(9);
5
+
4
6
  &__title {
7
+ margin-top: stylekit.space(4);
5
8
  margin-bottom: stylekit.space(2);
9
+ font-size: stylekit.$font-size--h3;
10
+ font-weight: stylekit.$font-weight--700;
11
+
12
+ &--empty > p {
13
+ color: transparent;
14
+ font-size: 0;
15
+ }
6
16
  }
7
17
 
8
18
  &__title-link {
@@ -18,29 +28,24 @@
18
28
  text-decoration-color: stylekit.$color--primary;
19
29
  }
20
30
  }
21
- }
22
-
23
- .blog-section .blog-section > .blog-section__title {
24
- font-size: stylekit.$font-size--h6;
25
- margin-bottom: stylekit.space(2);
26
- }
27
-
28
- .blog-section .blog-section > *:first-child {
29
- margin-top: stylekit.space(4);
30
- }
31
31
 
32
- .blog-section .blog-section:not(:last-child) {
33
- margin-bottom: stylekit.space(4);
34
- }
32
+ .blog-section {
33
+ margin-bottom: stylekit.space(6);
35
34
 
36
- .blog-section .blog-section:last-child {
37
- margin-bottom: stylekit.space(8);
38
- }
35
+ > .blog-section__title {
36
+ margin-top: stylekit.space(6);
37
+ font-weight: stylekit.$font-weight--600;
38
+ font-size: stylekit.$font-size--h5;
39
+ }
39
40
 
40
- .margin-bottom--6 {
41
- margin-bottom: stylekit.space(6);
42
- }
41
+ .blog-section {
42
+ margin-bottom: stylekit.space(4);
43
43
 
44
- .margin-bottom--9 {
45
- margin-bottom: stylekit.space(9);
44
+ > .blog-section__title {
45
+ margin-top: stylekit.space(4);
46
+ font-weight: stylekit.$font-weight--500;
47
+ font-size: stylekit.$font-size--h6;
48
+ }
49
+ }
50
+ }
46
51
  }
@@ -1,9 +1,8 @@
1
1
  declare const styles: {
2
2
  readonly 'blog-section': string;
3
3
  readonly 'blog-section__title': string;
4
+ readonly 'blog-section__title--empty': string;
4
5
  readonly 'blog-section__title-link': string;
5
- readonly 'margin-bottom--6': string;
6
- readonly 'margin-bottom--9': string;
7
6
  };
8
7
 
9
8
  export default styles;
@@ -62,7 +62,7 @@ $code-block-background-color: #282a36;
62
62
  > code,
63
63
  > code > * {
64
64
  font-family: stylekit.$font-family--code;
65
- font-size: stylekit.$font-size--p-small;
65
+ font-size: stylekit.$font-size--small;
66
66
  font-weight: unset;
67
67
  font-style: unset;
68
68
  line-height: stylekit.$line-height--normal;
@@ -120,5 +120,5 @@ $code-block-background-color: #282a36;
120
120
  .code-block--static code {
121
121
  color: stylekit.$color--base !important;
122
122
  font-family: stylekit.$font-family--code !important;
123
- font-size: stylekit.$font-size--p-small !important;
123
+ font-size: stylekit.$font-size--small !important;
124
124
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  @mixin cell-base {
4
4
  padding: styles.rem(12) styles.rem(16);
5
- font-size: styles.$font-size--p-small;
5
+ font-size: styles.$font-size--small;
6
6
  font-family: styles.$font-family--code;
7
7
  word-wrap: break-word;
8
8
  overflow-wrap: break-word;
@@ -0,0 +1,49 @@
1
+ @use '@san-siva/stylekit/styles/index.module.scss' as styles;
2
+
3
+ .toc-node {
4
+ &__title {
5
+ display: block;
6
+ margin-bottom: styles.space(1);
7
+ font-size: styles.$font-size--small;
8
+ font-weight: styles.$font-weight--500;
9
+ cursor: pointer;
10
+
11
+ animation: fadeInDown 0.3s ease-in-out;
12
+ transition: all 0.3s ease-in-out;
13
+
14
+ &--active,
15
+ &:hover {
16
+ text-decoration: underline;
17
+ text-decoration-color: styles.$color--primary;
18
+ }
19
+
20
+ &--active {
21
+ color: styles.$color--primary;
22
+ }
23
+
24
+ &--sub {
25
+ font-size: styles.$font-size--very-small;
26
+ }
27
+
28
+ &--sub-sub {
29
+ font-size: styles.$font-size--very-small;
30
+ font-weight: styles.$font-weight--400;
31
+ }
32
+
33
+ &:not(:last-child) {
34
+ margin-bottom: 0;
35
+ }
36
+ }
37
+
38
+ &__children {
39
+ &--sub-sub,
40
+ &--sub {
41
+ padding: styles.space(1) styles.space(2);
42
+ margin: styles.space(1);
43
+ border-left: 1px solid styles.$color--border;
44
+ }
45
+
46
+ &--sub-sub {
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ declare const styles: {
2
+ readonly 'toc-node__title': string;
3
+ readonly 'toc-node__title--active': string;
4
+ readonly 'toc-node__title--sub': string;
5
+ readonly 'toc-node__title--sub-sub': string;
6
+ readonly 'toc-node__children': string;
7
+ readonly 'toc-node__children--sub': string;
8
+ readonly 'toc-node__children--sub-sub': string;
9
+ };
10
+
11
+ export default styles;