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 11import { BlockRenderer } from '../Block' ;
2- import { List } from './styles ' ;
2+ import { List } from './List ' ;
33
44export interface Props {
55 blocks : any [ ] ;
Original file line number Diff line number Diff line change 1+ export { List , ListItem } from './List' ;
12export { 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';
66import testData from '../../constants/test.json' ;
77import { useKeyboardNavigation } from '../../hooks/useKeyboardNavigation' ;
88import { darkTheme , lightTheme } from '../../styles/theme.css' ;
9+ import { List } from './components/List' ;
910// import { BlockRenderer } from './components/Block';
1011// import { List, ListBlocksRenderer } from './components/List';
1112
@@ -65,22 +66,21 @@ export const Renderer: React.FC<Props> = React.memo(
6566 block . type === 'bulleted_list_item' &&
6667 ( i === 0 || blocks [ i - 1 ] ?. type !== 'bulleted_list_item' )
6768 ) {
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+ ) ;
8484 while (
8585 i + 1 < blocks . length &&
8686 blocks [ i + 1 ] &&
@@ -92,22 +92,21 @@ export const Renderer: React.FC<Props> = React.memo(
9292 block . type === 'numbered_list_item' &&
9393 ( i === 0 || blocks [ i - 1 ] ?. type !== 'numbered_list_item' )
9494 ) {
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+ ) ;
111110 while (
112111 i + 1 < blocks . length &&
113112 blocks [ i + 1 ] &&
You can’t perform that action at this time.
0 commit comments