Skip to content

Commit a3a10f3

Browse files
authored
Update to latest version @react-email/render (#13)
* Add trait, emails relative from basepath by default, update readme. * Npm install from vendor directory * Drop php 8.1 from CI * Update readme
1 parent 66f7674 commit a3a10f3

15 files changed

+849
-10356
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ jobs:
88
strategy:
99
fail-fast: true
1010
matrix:
11-
php: [ 8.1, 8.2 ]
12-
testbench: [7.*, 8.*]
11+
php: [ 8.2, 8.3, 8.4]
12+
testbench: [7.*, 8.*, 9.*, 10.*]
1313
steps:
1414
- uses: actions/checkout@v3
1515

16-
- name: Set Node.js 16.x
17-
uses: actions/setup-node@v3
16+
- uses: pnpm/action-setup@v4
17+
name: Install pnpm
1818
with:
19-
node-version: 16.x
19+
version: 10
20+
run_install: false
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
cache: 'pnpm'
27+
28+
- name: Install dependencies
29+
run: pnpm install
2030

2131
- name: Setup PHP
2232
uses: shivammathur/setup-php@v2
@@ -25,11 +35,6 @@ jobs:
2535
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
2636
coverage: none
2737

28-
- name: Install yarn dependencies
29-
uses: borales/actions-yarn@v4
30-
with:
31-
cmd: install
32-
3338
- name: Install composer dependencies
3439
run: |
3540
composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/vendor
33
.phpunit.result.cache
44
.phpunit.cache
5+
composer.lock

README.md

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1-
# React email for Laravel
1+
# React Email for Laravel
22

3-
This package allows you to easily send [React email](https://react.email/) emails with Laravel.
3+
Easily send [React Email](https://react.email/) emails with Laravel using this package.
44

5-
## Install
5+
## Installation
66

7-
``` bash
7+
First, install the package via Composer:
8+
9+
```bash
810
composer require maantje/react-email
9-
yarn add @j4mie/react-email
1011
```
1112

12-
## Usage
13+
Then, install the required Node dependencies:
14+
15+
```bash
16+
npm install vendor/maantje/react-email
17+
```
18+
19+
## Getting Started
1320

14-
Install React email ([automatic](https://react.email/docs/getting-started/automatic-setup), [manual](https://react.email/docs/getting-started/manual-setup)).
21+
1. Install React Email using the [automatic](https://react.email/docs/getting-started/automatic-setup) or [manual](https://react.email/docs/getting-started/manual-setup) setup.
22+
2. Create an email component in the `emails` directory (e.g., `new-user.tsx`). Ensure the component is the default export.
1523

16-
Create an email in the emails directory e.g. new-user.tsx, make sure the component is the default export.
24+
Example email component:
1725

18-
``` tsx
19-
import { Html } from '@react-email/html';
20-
import { Text } from '@react-email/text';
26+
```tsx
2127
import * as React from 'react';
28+
import { Text, Html } from '@react-email/components';
2229

2330
export default function Email({ user }) {
2431
return (
@@ -29,29 +36,35 @@ export default function Email({ user }) {
2936
}
3037
```
3138

32-
Set up the email directory in your Laravel .env.
33-
``` env
34-
REACT_EMAIL_DIRECTORY="/my/absolute/path/to/react-email-starter/emails/"
39+
3. Define the email directory path in your Laravel `.env` file:
40+
41+
```env
42+
REACT_EMAIL_DIRECTORY="emails/directory/relative/from/laravel/root"
3543
```
3644

37-
Create a Laravel mailable.
45+
4. Generate a new Laravel Mailable class:
3846

39-
``` bash
47+
```bash
4048
php artisan make:mail NewUser
4149
```
4250

43-
Extend from ReactMailable instead of Mailable.
51+
5. Use `ReactMailView` in your `Mailable`, or extend your `Mailable` from `ReactMailable``
4452

45-
``` php
53+
```php
4654
use App\Models\User;
4755
use Maantje\ReactEmail\ReactMailable;
56+
use Illuminate\Mail\Mailables\Envelope;
57+
use Illuminate\Mail\Mailables\Content;
58+
use Maantje\ReactEmail\ReactMailView;
4859

49-
class NewUser extends ReactMailable
60+
class NewUser extends ReactMailable // Extend, from \Maantje\ReactEmail\ReactMailable
5061
{
51-
public function __construct(public User $user)
62+
use ReactMailView; // or use \Maantje\ReactEmail\ReactMailView
63+
64+
public function __construct(public User $user)
5265
{
53-
// public properties will be passed as props to the React email component
54-
// Alternatively use the with property of content
66+
// Public properties will be passed as props to the React email component.
67+
// Alternatively, use the `with` property of `content`.
5568
}
5669

5770
public function envelope()
@@ -64,22 +77,25 @@ class NewUser extends ReactMailable
6477
public function content()
6578
{
6679
return new Content(
67-
view: 'new-user', // name of the component file without extension
80+
view: 'new-user', // Component filename without the extension
6881
);
6982
}
7083
}
7184
```
7285

73-
## Testing
86+
## Running Tests
7487

75-
``` bash
88+
Run tests using [Pest](https://pestphp.com/):
89+
90+
```bash
7691
./vendor/bin/pest
7792
```
7893

7994
## Security
8095

81-
If you discover any security related issues, please email author email instead of using the issue tracker.
96+
If you discover any security-related issues, please email the author instead of using the issue tracker.
8297

8398
## License
8499

85-
The MIT License (MIT). Please see [License File](/LICENSE) for more information.
100+
This package is open-source and licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.~~
101+

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
}
2525
},
2626
"require-dev": {
27-
"orchestra/testbench": "^7.20 || ^8.0 || ^9.0",
28-
"pestphp/pest": "^1.20 || ^2.0"
27+
"orchestra/testbench": "^7.20 || ^8.0 || ^9.0 || ^10",
28+
"pestphp/pest": "^1.20 || ^2.0 || ^3"
2929
},
3030
"config": {
3131
"allow-plugins": {

0 commit comments

Comments
 (0)