Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jsx-email): add new components (graph, background), update components (html, head, container) #198

Merged
merged 42 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
609e387
feat(jsx-email): add `rem-to-px` preset to `unoconfig` (#189)
lordelogos Apr 17, 2024
bd75c72
feat(jsx-email): add meta tags to `head` and update test suite (#187)
lordelogos Apr 17, 2024
8be1ca4
chore(release): jsx-email v1.11.0
Apr 17, 2024
2fe4ed3
feat(jsx-email): add `bgImage` and `bgColor` props to `<Column>` (#188)
lordelogos Apr 19, 2024
adc87df
chore(release): jsx-email v1.12.0
Apr 19, 2024
6d6dd40
fix(app-preview): add logic for mobile sidebar and update ui (#190)
shellscape Apr 20, 2024
082c217
chore(release): app-preview v1.2.6
Apr 20, 2024
f77ece7
docs: fix a few typos (#193)
blx May 6, 2024
28c4e39
fix(jsx-email): build process broken on Windows, fixes #194 (#195)
thomasdondorf May 9, 2024
545ad75
chore(release): jsx-email v1.12.1
May 9, 2024
4c909a0
feat: update head and head docs
lordelogos Jun 2, 2024
1700e4f
feat: add background component and docs
lordelogos Jun 2, 2024
0d47234
feat: update condtional component and docs
lordelogos Jun 2, 2024
5984fac
feat: add graph component and docs
lordelogos Jun 2, 2024
293dae5
feat: update html component and docs
lordelogos Jun 2, 2024
dac42e2
feat: update container component
lordelogos Jun 2, 2024
49bbaae
feat: move old button to legacy
lordelogos Jun 2, 2024
d810bea
feat: update debug props for graph and background
lordelogos Jun 2, 2024
76cb83f
feat: add button component and docs
lordelogos Jun 2, 2024
c57cbc7
feat: update button logic, update exports
lordelogos Jun 2, 2024
006195c
feat: update html tests
lordelogos Jun 3, 2024
9feffa9
feat: update head tests
lordelogos Jun 3, 2024
e896365
feat: update container and tests
lordelogos Jun 3, 2024
6e13b32
feat: update conditional tests
lordelogos Jun 3, 2024
1279865
feat: update button-legacy and tests
lordelogos Jun 3, 2024
0d56201
feat: update tests with html and head
lordelogos Jun 3, 2024
141f052
feat: add button tests
lordelogos Jun 3, 2024
b36b4ca
feat: add graph tests
lordelogos Jun 3, 2024
9065670
feat: add background tests
lordelogos Jun 3, 2024
fa708d8
feat: update graph test
lordelogos Jun 3, 2024
01574cb
feat: update test tailwind template
lordelogos Jun 3, 2024
787d249
feat: update button in playwright tests
lordelogos Jun 3, 2024
d839fa0
feat: update playwright snapshots
lordelogos Jun 3, 2024
a2d865d
Merge branch 'release/v2' into feat/v2/new-components
lordelogos Jun 4, 2024
db07ac9
feat: update test snapshots
lordelogos Jun 4, 2024
60a1efa
reset CHANGELOG.md
shellscape Jul 3, 2024
fbb17f8
chore: build logic
shellscape Jul 3, 2024
76053d2
fix: inline plugin, config merging
shellscape Jul 4, 2024
1cdac08
chore: clean up smoke tests
shellscape Jul 4, 2024
5d02daf
chore: test snapshots
shellscape Jul 4, 2024
9d0a45b
chore: force color in ci
shellscape Jul 4, 2024
273c46b
chore: smoke snaps
shellscape Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
moon run :build --query "project~plugin-*"

- name: Package Tests
env:
FORCE_COLOR: 1
run: moon run :test --affected --concurrency 1 --remote

- name: Smoke Test
Expand Down
2 changes: 1 addition & 1 deletion apps/preview/app/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const gather = async () => {
const absHtmlPath = `${path
.replace(relativePath, absBuildPath)
.replace(/\.(jsx|tsx)$/, '')}.html`;
const templateName = templateNameMap[absHtmlPath];
const templateName = templateNameMap[absHtmlPath] || basePath.split('/').at(-1);
return {
...acc,
[path]: {
Expand Down
76 changes: 76 additions & 0 deletions docs/components/background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: 'Background'
description: 'A JSX email component for background images in your Email template'
slug: background
type: component
---

<!--@include: @/include/header.md-->

<!--@include: @/include/install.md-->

## Usage

Add the background component to your email template.

```jsx
import { Body, Column, Html, Section } from 'jsx-email';

const Email = () => {
return (
<Html lang="en">
<Body>
<Background src="link-to-image" bgColor="#FFFFFF" width={600}>
<Row>
<Column>Content goes here</Column>
</Row>
</Background>
</Body>
</Html>
);
};
```

## Component Props

```tsx
interface BackgroundProps
extends Omit<React.ComponentPropsWithoutRef<'td'>, 'height' | 'width' | 'bgcolor'> {
src: string;
bgColor?: string;
bgRepeat?: 'repeat' | 'no-repeat';
height?: number;
width?: number;
}
```

```tsx
src: string;
```

The path to the image

```tsx
bgColor?: string;
```

The hex code that represents the fallback `background-color` incase the image doesn't load

```tsx
bgRepeat?: 'repeat' | 'no-repeat';
```

A string that represents the value of `background-repeat`.
Default value is `no-repeat`

```tsx
height?: number;
```

The `height` of the container in pixels

```tsx
width?: number;
```

The `width` of the container in pixels
48 changes: 48 additions & 0 deletions docs/components/button-legacy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: 'Button'
description: A JSX email component which styles an anchor element to appear as a button
slug: button
type: component
---

<!--@include: @/include/header.md-->

::: tip
Semantics: Quite often in the email world we talk about buttons when we actually mean links. Behind the scenes this component is a `<a>` element which is styled like a `<button>` element.
:::

<!--@include: @/include/install.md-->

## Usage

Add the component to your email template. Include styles where needed.

```jsx
import { Button } from 'jsx-email';

const Email = () => {
return (
<Button href="https://example.com" style={{ color: '#61dafb', padding: '10px 20px' }}>
Click me
</Button>
);
};
```

## Component Props

```ts
href: string;
```

The url to navigate to when the button is clicked.

```ts
target?: string;
```

Specifies the value of the `"target"` attribute for the button `target`.

:::tip
This component also expresses all of the [Common Component Props](https://react.dev/reference/react-dom/components/common) for `ComponentProps<'a'>`.
:::
86 changes: 83 additions & 3 deletions docs/components/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { Button } from 'jsx-email';

const Email = () => {
return (
<Button href="https://example.com" style={{ color: '#61dafb', padding: '10px 20px' }}>
Click me
<Button width={160} height={60} href="https://jsx.email" target="_blank">
JOIN US
</Button>
);
};
Expand All @@ -32,17 +32,97 @@ const Email = () => {
## Component Props

```ts
href: string;
export interface ButtonProps extends BaseProps<'a'> {
width: number;
height: number;
href?: string;
align?: 'left' | 'center' | 'right';
backgroundColor?: string;
borderColor?: string;
borderRadius?: number;
borderSize?: number;
fontSize?: number;
textColor?: string;
withBackground?: boolean;
}
```

:::tip
It is **highly reccommended** to use the component props to set these values rather than css for **optimal email client compatibility** especially in Outlook clients
:::

```ts
href?: string;
```

The url to navigate to when the button is clicked.

```ts
width: number;
```

Specifies the `width` of the Button in pixels

```ts
height: number;
```

Specifies the `height` of the Button in pixels

```ts
align?: 'left' | 'center' | 'right';
```

Specifies the horizontal alignment of the Button in the container. Default value is `left`

```ts
target?: string;
```

Specifies the value of the `"target"` attribute for the button `target`.

```ts
backgroundColor?: string;
```

Specifies the hex value for the `background-color` of the button

```ts
borderColor?: string;
```

Specifies the hex value `border-color` for the button

```ts
borderRadius?: number;
```

Specifies the `border-radius` value for the button in pixels

```ts
borderSize?: number;
```

Specifies the `border-width` value in pixels

```ts
fontSize?: number;
```

Specifies the `font-size` value in pixels

```ts
textColor?: string;
```

Specifies the hex value for the `color` of the text

```ts
withBackground?: boolean;
```

Set to `true` if `Button` is nested in a `Background` component. Neccessary for good Outlook compatibility.

:::tip
This component also expresses all of the [Common Component Props](https://react.dev/reference/react-dom/components/common) for `ComponentProps<'a'>`.
:::
23 changes: 22 additions & 1 deletion docs/components/column.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,25 @@ const Email = () => {

## Component Props

This component has no custom props, but expresses all of the [Common Component Props](https://react.dev/reference/react-dom/components/common) for `ComponentProps<'td'>`.
```tsx
export interface ColumnProps extends BaseProps<'td'> {
bgColor?: string;
bgImage?: string;
}
```

```tsx
bgColor: string;
```

Used to set the background color in HTML email by wrapping the `bgcolor` property of `<td>` elements

```tsx
bgImage: string;
```

Used to set background images in HTML email by wrapping the `background` property of `<td>` elements

:::tip
This component expresses all of the [Common Component Props](https://react.dev/reference/react-dom/components/common) for `ComponentProps<'td'>`.
:::
6 changes: 6 additions & 0 deletions docs/components/conditional.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ expression?: string;

If provided, the string will be used as the conditional expression within the HTML comment. e.g. a value of `lt ie 10` would result in a conditional comment block starting with `<!--[if lt ie 10]>`.

```ts
head?: boolean;
```

If `true`, the conditional expression will be placed in the `head` section of your email template.

```ts
mso?: boolean;
```
Expand Down
2 changes: 1 addition & 1 deletion docs/components/font.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface FontProps {
fallbackFontFamily: FallbackFont | FallbackFont[];
```

The fallback font family the system should you, if web fonts are not supported or the chosen font is not installed on the system.
The fallback font family the system should use, if web fonts are not supported or the chosen font is not installed on the system.

```ts
fontFamily: string;
Expand Down
91 changes: 91 additions & 0 deletions docs/components/graph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: 'Graph'
description: 'A JSX email component for displaying graphs in your Email template'
slug: graph
type: component
---

<!--@include: @/include/header.md-->

::: tip
This component is wrapper around [QuickChart API](https://quickchart.io/) for generating email compatible charts
:::

<!--@include: @/include/install.md-->

## Usage

Add the graph component to your email template.

```jsx
import { Html, Body, Section, Graph } from 'jsx-email';

const Email = () => {
return (
<Html lang="en">
<Body>
<Section>
<Graph
width={100}
height={100}
title="Graph with jsx-email"
config={{
type: 'bar',
data: {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
datasets: [
{
data: [10, 6.5, 3, 6, 4, 0.1, 0.5]
}
]
}
}}
/>
</Section>
</Body>
</Html>
);
};
```

## Component Props

```tsx
config: ChartConfiguration & Record<string, any>;
```

An object that contains the chart configuration settings, combining [ChartConfiguration](https://www.chartjs.org/docs/2.9.4/charts/) properties.

:::tip
You can play around with your chart configuration in this [playground](https://quickchart.io/sandbox)
:::

```tsx
title: string;
```

This is a required string that provides the title of the graph.

```tsx
background?: string;
```

An optional string that sets the background color of the graph.

```tsx
className?: string;
```

This is optional string that applies a custom CSS class to the graph component for additional styling.

```tsx
height?: number;
```

This is an optional number that specifies the height of the graph in pixels.

```tsx
width?: number;
```

This is an optional number that specifies the width of the graph in pixels.
Loading
Loading