Skip to content

Commit aa0dbfa

Browse files
committed
feat: Cover, Title UI 추가
1 parent ec5f8d1 commit aa0dbfa

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { cover } from './styles.css';
2+
3+
interface CoverProps {
4+
src: string;
5+
alt: string;
6+
}
7+
8+
const Cover = ({ src, alt }: CoverProps) => {
9+
return <img src={src} alt={alt} className={cover} />;
10+
};
11+
12+
export default Cover;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { style } from '@vanilla-extract/css';
2+
3+
export const cover = style({
4+
width: '100%',
5+
maxWidth: '56.25rem',
6+
height: '30vh',
7+
display: 'block',
8+
objectFit: 'cover',
9+
objectPosition: 'center 50%',
10+
borderRadius: '1.5rem',
11+
});

packages/notion-to-jsx/src/components/Renderer/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import { ListBlocksRenderer } from './components/List';
77
import { BlockRenderer } from './components/Block';
88
import '../../styles/reset.css';
99
import { darkTheme, lightTheme } from '../../styles/theme.css';
10+
import Title from '../Title';
11+
import Cover from '../Cover';
1012

1113
interface Props {
1214
blocks: NotionBlock[];
15+
title?: string;
16+
cover?: string;
1317
isDarkMode?: boolean;
1418
onBlockFocus?: (index: number) => void;
1519
}
1620
export const Renderer: React.FC<Props> = React.memo(
17-
({ blocks, isDarkMode = false, onBlockFocus }) => {
21+
({ blocks, isDarkMode = false, title, cover, onBlockFocus }) => {
1822
const theme = isDarkMode ? darkTheme : lightTheme;
1923
const [focusedIndex, setFocusedIndex] = useState<number>(-1);
2024

@@ -86,12 +90,16 @@ export const Renderer: React.FC<Props> = React.memo(
8690
}, [blocks, handleBlockFocus]);
8791

8892
return (
89-
<article
90-
className={`${theme} ${container}`}
91-
aria-label="Notion page content"
92-
>
93-
{renderedBlocks}
94-
</article>
93+
<>
94+
{cover && <Cover src={cover} alt={title || 'Notion page content'} />}
95+
<article
96+
className={`${theme} ${container}`}
97+
aria-label={title || 'Notion page content'}
98+
>
99+
{title && <Title title={title} />}
100+
{renderedBlocks}
101+
</article>
102+
</>
95103
);
96104
}
97105
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Heading1 } from '../Renderer/components/Typography';
2+
3+
interface Props {
4+
title: string;
5+
}
6+
const Title = ({ title }: Props) => {
7+
return <Heading1>{title}</Heading1>;
8+
};
9+
10+
export default Title;

packages/notion-to-jsx/src/styles/theme.css.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export const vars = createThemeContract({
6161
sm: null,
6262
md: null,
6363
lg: null,
64+
xl: null,
65+
xxl: null,
6466
},
6567
shadows: {
6668
sm: null,
@@ -114,6 +116,8 @@ const commonThemeValues = {
114116
sm: '0.25rem',
115117
md: '0.375rem',
116118
lg: '0.5rem',
119+
xl: '0.75rem',
120+
xxl: '1rem',
117121
},
118122
};
119123

0 commit comments

Comments
 (0)