Skip to content

Commit c9ecdee

Browse files
committed
Fix klavyio compatibility
1 parent 6b3a109 commit c9ecdee

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

packages/container/src/container.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ import * as React from 'react';
33
export type ContainerProps = Readonly<React.ComponentPropsWithoutRef<'table'>>;
44

55
export const Container = React.forwardRef<HTMLTableElement, ContainerProps>(
6-
({ children, style, ...props }, ref) => {
6+
({ children, style = {}, ...props }, ref) => {
7+
// Destructure padding to improve compatibility with Klavyio and Outlook.
8+
const {
9+
padding,
10+
paddingTop,
11+
paddingRight,
12+
paddingBottom,
13+
paddingLeft,
14+
...tableStyle
15+
} = style;
16+
17+
const tdStyle = {
18+
padding,
19+
paddingTop,
20+
paddingRight,
21+
paddingBottom,
22+
paddingLeft,
23+
};
24+
725
return (
826
<table
927
align="center"
@@ -14,11 +32,11 @@ export const Container = React.forwardRef<HTMLTableElement, ContainerProps>(
1432
cellSpacing="0"
1533
ref={ref}
1634
role="presentation"
17-
style={{ maxWidth: '37.5em', ...style }}
35+
style={{ maxWidth: '37.5em', ...tableStyle }}
1836
>
1937
<tbody>
2038
<tr style={{ width: '100%' }}>
21-
<td>{children}</td>
39+
<td style={tdStyle}>{children}</td>
2240
</tr>
2341
</tbody>
2442
</table>

packages/section/src/section.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ import * as React from 'react';
33
export type SectionProps = Readonly<React.ComponentPropsWithoutRef<'table'>>;
44

55
export const Section = React.forwardRef<HTMLTableElement, SectionProps>(
6-
({ children, style, ...props }, ref) => {
6+
({ children, style = {}, ...props }, ref) => {
7+
// Destructure padding to improve compatibility with Klavyio and Outlook.
8+
const {
9+
padding,
10+
paddingTop,
11+
paddingRight,
12+
paddingBottom,
13+
paddingLeft,
14+
...tableStyle
15+
} = style;
16+
17+
const tdStyle = {
18+
padding,
19+
paddingTop,
20+
paddingRight,
21+
paddingBottom,
22+
paddingLeft,
23+
};
24+
725
return (
826
<table
927
align="center"
@@ -14,11 +32,11 @@ export const Section = React.forwardRef<HTMLTableElement, SectionProps>(
1432
role="presentation"
1533
{...props}
1634
ref={ref}
17-
style={style}
35+
style={tableStyle}
1836
>
1937
<tbody>
2038
<tr>
21-
<td>{children}</td>
39+
<td style={tdStyle}>{children}</td>
2240
</tr>
2341
</tbody>
2442
</table>

0 commit comments

Comments
 (0)