Skip to content

Commit e43797b

Browse files
committed
Initial commit
0 parents  commit e43797b

File tree

19 files changed

+8924
-0
lines changed

19 files changed

+8924
-0
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
name: Test ${{ matrix.php }} - ${{ matrix.testbench }}
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [ 8.0, 8.1, 8.2 ]
12+
testbench: [7.*]
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set Node.js 16.x
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 16.x
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
26+
coverage: none
27+
28+
- name: Install yarn dependencies
29+
uses: borales/actions-yarn@v4
30+
with:
31+
cmd: install
32+
33+
- name: Install composer dependencies
34+
run: |
35+
composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
36+
composer update --prefer-dist --no-interaction
37+
38+
- name: Test
39+
run: ./vendor/bin/pest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/vendor
3+
.phpunit.result.cache

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Jamie Schouten
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# React email for Laravel
2+
3+
This package allows you to easily send [React email](https://react.email/) emails with Laravel.
4+
5+
## Install
6+
7+
``` bash
8+
composer require maantje/react-email
9+
yarn add @maantje/react-email
10+
```
11+
12+
## Usage
13+
14+
Install React email ([automatic](https://react.email/docs/getting-started/automatic-setup), [manual](https://react.email/docs/getting-started/manual-setup)).
15+
16+
Create an email in the emails directory e.g. new-user.tsx, make sure the component is the default export.
17+
18+
``` tsx
19+
import { Html } from '@react-email/html';
20+
import { Text } from '@react-email/text';
21+
import * as React from 'react';
22+
23+
export default function Email({ user }) {
24+
return (
25+
<Html>
26+
<Text>Hello, {user.name}</Text>
27+
</Html>
28+
);
29+
}
30+
```
31+
32+
Set up the email directory in your Laravel .env.
33+
``` env
34+
REACT_EMAIL_DIRECTORY="/my/absolute/path/to/react-email-starter/emails/"
35+
```
36+
37+
Create a Laravel mailable.
38+
39+
``` bash
40+
php artisan make:mail NewUser
41+
```
42+
43+
Extend from ReactMailable instead of Mailable.
44+
45+
``` php
46+
use App\Models\User;
47+
use Maantje\ReactEmail\ReactMailable;
48+
49+
class NewUser extends ReactMailable
50+
{
51+
public function __construct(public User $user)
52+
{
53+
// public properties will be passed as props to the React email component
54+
// Alternatively use the with property of content
55+
}
56+
57+
public function envelope()
58+
{
59+
return new Envelope(
60+
subject: 'New User',
61+
);
62+
}
63+
64+
public function content()
65+
{
66+
return new Content(
67+
view: 'new-user', // name of the component file without extension
68+
);
69+
}
70+
}
71+
```
72+
73+
## Testing
74+
75+
``` bash
76+
./vendor/bin/pest
77+
```
78+
79+
## Security
80+
81+
If you discover any security related issues, please email author email instead of using the issue tracker.
82+
83+
## License
84+
85+
The MIT License (MIT). Please see [License File](/LICENSE) for more information.

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "maantje/react-email",
3+
"description": "React email for Laravel",
4+
"keywords": ["laravel", "react", "react email"],
5+
"homepage": "https://github.com/maantje/laravel-react-email",
6+
"type": "library",
7+
"license": "MIT",
8+
"autoload": {
9+
"psr-4": {
10+
"Maantje\\ReactEmail\\": "src/"
11+
}
12+
},
13+
"authors": [
14+
{
15+
"name": "Jamie Schouten",
16+
"email": "j4mie@hey.com"
17+
}
18+
],
19+
"extra": {
20+
"laravel": {
21+
"providers": [
22+
"Maantje\\ReactEmail\\ReactEmailServiceProvider"
23+
]
24+
}
25+
},
26+
"require-dev": {
27+
"orchestra/testbench": "^7.20",
28+
"pestphp/pest": "^1.22"
29+
},
30+
"config": {
31+
"allow-plugins": {
32+
"pestphp/pest-plugin": true
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)