Skip to content

Commit a14c73f

Browse files
committed
feat: implement table header styling for both rows and columns
1 parent a5f1030 commit a14c73f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ export function Block(props: BlockProps) {
790790
const backgroundColor = block.format?.block_color
791791

792792
const hasRowHeader = tableBlock.format?.table_block_column_header === true
793+
const hasColumnHeader = tableBlock.format?.table_block_row_header === true
793794

794795
const isHeaderRow = hasRowHeader && tableBlock.content?.[0] === block.id
795796

@@ -806,13 +807,18 @@ export function Block(props: BlockProps) {
806807
blockId
807808
)}
808809
>
809-
{order.map((column) => {
810+
{order.map((column, columnIndex) => {
810811
const color = formatMap?.[column]?.color
811812

813+
const isHeaderColumn = hasColumnHeader && columnIndex === 0
814+
812815
return (
813816
<td
814817
key={column}
815-
className={color ? `notion-${color}` : ''}
818+
className={cs(
819+
color ? `notion-${color}` : '',
820+
isHeaderColumn && 'notion-simple-table-header-cell'
821+
)}
816822
style={{
817823
width: formatMap?.[column]?.width || 120
818824
}}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,10 +2672,17 @@ svg.notion-page-icon {
26722672
font-size: 14px;
26732673
}
26742674

2675+
/* simple table header */
2676+
/* row header */
26752677
.notion-simple-table-header-row td {
26762678
background: var(--bg-color-0);
26772679
}
26782680

2681+
/* column header */
2682+
.notion-simple-table-header-cell {
2683+
background: var(--bg-color-0);
2684+
}
2685+
26792686
.notion-simple-table td {
26802687
border: 1px solid var(--fg-color-5);
26812688
padding: 8px 8px;

0 commit comments

Comments
 (0)