Skip to content

Commit 290f6a0

Browse files
authored
Added Numbered List (#28)
* feat. numbered-list-item * docs.numbered-list-item
1 parent a863555 commit 290f6a0

File tree

7 files changed

+413
-4
lines changed

7 files changed

+413
-4
lines changed

packages/react-notion-custom/CONTRIBUTING-KR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ fetchNotionPage();
648648
| Heading 2 | ✅ Yes | `heading_2` | |
649649
| Heading 3 | ✅ Yes | `heading_3` | |
650650
| Bulleted List Item | ❌ No | `bulleted_list_item` | |
651-
| Numbered List Item | ❌ No | `numbered_list_item` | |
651+
| Numbered List Item | ✅ Yes | `numbered_list_item` | |
652652
| To-do | ❌ No | `to_do` | |
653653
| Toggle | ✅ Yes | `toggle` | |
654654
| Quote | ✅ Yes | `quote` | |

packages/react-notion-custom/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ Here's a list of Notion block types currently supported in react-notion-custom.
651651
| Heading 2 | ✅ Yes | `heading_2` | |
652652
| Heading 3 | ✅ Yes | `heading_3` | |
653653
| Bulleted List Item | ❌ No | `bulleted_list_item` | |
654-
| Numbered List Item | ❌ No | `numbered_list_item` | |
654+
| Numbered List Item | ✅ Yes | `numbered_list_item` | |
655655
| To-do | ❌ No | `to_do` | |
656656
| Toggle | ✅ Yes | `toggle` | |
657657
| Quote | ✅ Yes | `quote` | |

packages/react-notion-custom/src/lib/components/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import Headings from "./headings";
22
import Paragraph from "./paragraph";
33
import Toggle from "./toggle";
44
import Equation from "./equation";
5+
import NumberedListItem from "./numbered-list-item";
56
import Quote from "./quote";
7+
import Callout from "./callout";
68

79
export { Headings, Paragraph, Toggle, Equation, Quote,Callout };
8-
import Callout from "./callout";
910

10-
export { Headings, Paragraph, Toggle, Equation, Callout };
11+
export { Headings, Paragraph, Toggle, Equation, Callout,NumberedListItem };
1112

1213
export default {
1314
heading_1: Headings,
@@ -16,6 +17,7 @@ export default {
1617
paragraph: Paragraph,
1718
toggle: Toggle,
1819
equation: Equation,
20+
numbered_list_item: NumberedListItem,
1921
quote: Quote,
2022
callout: Callout,
2123
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use client";
2+
3+
import React from "react";
4+
import type { NumberedListItemArgs } from "../types";
5+
import { getColorCss, numberedListItemMarker } from "../utils";
6+
import RichText from "./internal/rich-text";
7+
8+
type NumberedListProps = {
9+
children?: React.ReactNode;
10+
} & NumberedListItemArgs;
11+
12+
const NumberedListItem: React.FC<NumberedListProps> = ({
13+
children,
14+
...props
15+
}) => {
16+
const {
17+
numbered_list_item: { rich_text: texts, color },
18+
} = props;
19+
const { marker, format } = numberedListItemMarker.getMarker(props);
20+
21+
return (
22+
<ol
23+
data-notion-marker-format={format}
24+
className={`notion-block notion-list-numbered ${getColorCss(color)}`}
25+
>
26+
<li className="notion-display-contents">
27+
<div className="notion-list-numbered-content">
28+
<span
29+
data-notion-marker-format={format}
30+
className="notion-list-marker"
31+
>
32+
{marker}
33+
</span>
34+
<p>
35+
<RichText props={texts} />
36+
</p>
37+
</div>
38+
{children}
39+
</li>
40+
</ol>
41+
);
42+
};
43+
44+
export default NumberedListItem;

packages/react-notion-custom/src/lib/index.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,41 @@
591591
background: var(--select-color-2);
592592
}
593593

594+
.notion-list-numbered {
595+
list-style-type: none;
596+
padding-left: 0;
597+
}
598+
599+
.notion-list-numbered[data-notion-marker-format="romans"]
600+
> .notion-display-contents
601+
> .notion-list-numbered-content
602+
> .notion-list-marker {
603+
width: 3em !important;
604+
margin-right: 0em;
605+
}
606+
607+
.notion-list-numbered[data-notion-marker-format="romans"] > li > .notion-block {
608+
margin-left: 2.9em;
609+
}
610+
611+
.notion-list-marker::after {
612+
content: ".";
613+
}
614+
615+
.notion-list-marker {
616+
width: 26px;
617+
display: inline-flex;
618+
flex-shrink: 0;
619+
justify-content: center;
620+
align-items: center;
621+
height: fit-content;
622+
}
623+
624+
.notion-list-numbered-content {
625+
padding-top: 4px;
626+
padding-bottom: 4px;
627+
display: flex;
628+
594629
.notion-quote-content {
595630
display: block;
596631
word-break: break-word;
@@ -602,6 +637,7 @@
602637
padding: 3px 2px;
603638
margin: 3px 0px 3px 1px;
604639
font-size: 1em;
640+
605641
.notion-callout {
606642
padding: 16px 16px 16px 12px;
607643
display: flex;

0 commit comments

Comments
 (0)