File tree Expand file tree Collapse file tree 6 files changed +96
-45
lines changed
packages/notion-to-jsx/src/components/Renderer Expand file tree Collapse file tree 6 files changed +96
-45
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { list , listItem } from './styles.css' ;
3
+
4
+ interface ListProps
5
+ extends React . HTMLAttributes < HTMLUListElement | HTMLOListElement > {
6
+ as ?: 'ul' | 'ol' ;
7
+ type : 'bulleted' | 'numbered' ;
8
+ children : React . ReactNode ;
9
+ }
10
+
11
+ export const List : React . FC < ListProps > = ( {
12
+ as : Component = 'ul' ,
13
+ type,
14
+ className,
15
+ children,
16
+ ...props
17
+ } ) => {
18
+ return (
19
+ < Component className = { list ( { type } ) } { ...props } >
20
+ { children }
21
+ </ Component >
22
+ ) ;
23
+ } ;
24
+
25
+ interface ListItemProps extends React . HTMLAttributes < HTMLLIElement > {
26
+ children : React . ReactNode ;
27
+ }
28
+
29
+ export const ListItem : React . FC < ListItemProps > = ( {
30
+ className,
31
+ children,
32
+ ...props
33
+ } ) => {
34
+ return (
35
+ < li className = { listItem } { ...props } >
36
+ { children }
37
+ </ li >
38
+ ) ;
39
+ } ;
Original file line number Diff line number Diff line change 1
1
import { BlockRenderer } from '../Block' ;
2
- import { List } from './styles ' ;
2
+ import { List } from './List ' ;
3
3
4
4
export interface Props {
5
5
blocks : any [ ] ;
Original file line number Diff line number Diff line change
1
+ export { List , ListItem } from './List' ;
1
2
export { default as ListBlocksRenderer } from './ListBlocksRenderer' ;
2
- export * from './styles' ;
Original file line number Diff line number Diff line change
1
+ import { style } from '@vanilla-extract/css' ;
2
+ import { recipe } from '@vanilla-extract/recipes' ;
3
+ import { vars } from '../../../../styles/theme.css' ;
4
+
5
+ export const list = recipe ( {
6
+ base : {
7
+ margin : `${ vars . spacing . sm } 0` ,
8
+ paddingLeft : vars . spacing . xl ,
9
+ } ,
10
+ variants : {
11
+ type : {
12
+ bulleted : {
13
+ listStyleType : 'disc' ,
14
+ } ,
15
+ numbered : {
16
+ listStyleType : 'decimal' ,
17
+ } ,
18
+ } ,
19
+ } ,
20
+ } ) ;
21
+
22
+ export const listItem = style ( {
23
+ margin : `${ vars . spacing . xs } 0` ,
24
+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { NotionBlock } from '../../types';
6
6
import testData from '../../constants/test.json' ;
7
7
import { useKeyboardNavigation } from '../../hooks/useKeyboardNavigation' ;
8
8
import { darkTheme , lightTheme } from '../../styles/theme.css' ;
9
+ import { List } from './components/List' ;
9
10
// import { BlockRenderer } from './components/Block';
10
11
// import { List, ListBlocksRenderer } from './components/List';
11
12
@@ -65,22 +66,21 @@ export const Renderer: React.FC<Props> = React.memo(
65
66
block . type === 'bulleted_list_item' &&
66
67
( i === 0 || blocks [ i - 1 ] ?. type !== 'bulleted_list_item' )
67
68
) {
68
- result
69
- . push
70
- // <List
71
- // as="ul"
72
- // type="bulleted"
73
- // role="list"
74
- // aria-label="Bulleted list"
75
- // key={block.id}
76
- // >
77
- // <ListBlocksRenderer
78
- // blocks={blocks}
79
- // startIndex={i}
80
- // type="bulleted"
81
- // />
82
- // </List>
83
- ( ) ;
69
+ result . push (
70
+ < List
71
+ as = "ul"
72
+ type = "bulleted"
73
+ role = "list"
74
+ aria-label = "Bulleted list"
75
+ key = { block . id }
76
+ >
77
+ { /* <ListBlocksRenderer
78
+ blocks={blocks}
79
+ startIndex={i}
80
+ type="bulleted"
81
+ /> */ }
82
+ </ List >
83
+ ) ;
84
84
while (
85
85
i + 1 < blocks . length &&
86
86
blocks [ i + 1 ] &&
@@ -92,22 +92,21 @@ export const Renderer: React.FC<Props> = React.memo(
92
92
block . type === 'numbered_list_item' &&
93
93
( i === 0 || blocks [ i - 1 ] ?. type !== 'numbered_list_item' )
94
94
) {
95
- result
96
- . push
97
- // <List
98
- // as="ol"
99
- // type="1"
100
- // role="list"
101
- // aria-label="Numbered list"
102
- // key={block.id}
103
- // >
104
- // <ListBlocksRenderer
105
- // blocks={blocks}
106
- // startIndex={i}
107
- // type="numbered"
108
- // />
109
- // </List>
110
- ( ) ;
95
+ result . push (
96
+ < List
97
+ as = "ol"
98
+ type = "1"
99
+ role = "list"
100
+ aria-label = "Numbered list"
101
+ key = { block . id }
102
+ >
103
+ { /* <ListBlocksRenderer
104
+ blocks={blocks}
105
+ startIndex={i}
106
+ type="numbered"
107
+ /> */ }
108
+ </ List >
109
+ ) ;
111
110
while (
112
111
i + 1 < blocks . length &&
113
112
blocks [ i + 1 ] &&
You can’t perform that action at this time.
0 commit comments