Skip to content

Commit 040c625

Browse files
Merge pull request #630 from LooseLi/feat-table-header-style
2 parents 07fe5fb + a14c73f commit 040c625

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/react-notion-x/src/block.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ export function Block(props: BlockProps) {
789789
const formatMap = tableBlock.format?.table_block_column_format
790790
const backgroundColor = block.format?.block_color
791791

792+
const hasRowHeader = tableBlock.format?.table_block_column_header === true
793+
const hasColumnHeader = tableBlock.format?.table_block_row_header === true
794+
795+
const isHeaderRow = hasRowHeader && tableBlock.content?.[0] === block.id
796+
792797
if (!tableBlock || !order) {
793798
return null
794799
}
@@ -798,16 +803,22 @@ export function Block(props: BlockProps) {
798803
className={cs(
799804
'notion-simple-table-row',
800805
backgroundColor && `notion-${backgroundColor}`,
806+
isHeaderRow && 'notion-simple-table-header-row',
801807
blockId
802808
)}
803809
>
804-
{order.map((column) => {
810+
{order.map((column, columnIndex) => {
805811
const color = formatMap?.[column]?.color
806812

813+
const isHeaderColumn = hasColumnHeader && columnIndex === 0
814+
807815
return (
808816
<td
809817
key={column}
810-
className={color ? `notion-${color}` : ''}
818+
className={cs(
819+
color ? `notion-${color}` : '',
820+
isHeaderColumn && 'notion-simple-table-header-cell'
821+
)}
811822
style={{
812823
width: formatMap?.[column]?.width || 120
813824
}}

packages/react-notion-x/src/styles.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,14 @@ svg.notion-page-icon {
26742674
font-size: 14px;
26752675
}
26762676

2677-
.notion-simple-table tr:first-child td {
2677+
/* simple table header */
2678+
/* row header */
2679+
.notion-simple-table-header-row td {
2680+
background: var(--bg-color-0);
2681+
}
2682+
2683+
/* column header */
2684+
.notion-simple-table-header-cell {
26782685
background: var(--bg-color-0);
26792686
}
26802687

0 commit comments

Comments
 (0)