-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsx-email): allow preview server to serve files outside of worksp…
…ace root (#105) Co-authored-by: Affan Shahid <[email protected]> Co-authored-by: Paul Ehikhuemen <[email protected]> Co-authored-by: Andrew Powell <[email protected]>
- Loading branch information
1 parent
df9347e
commit 5747cc4
Showing
7 changed files
with
155 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Body, Container, Head, Hr, Html, Img, Link, Preview, Section, Text } from 'jsx-email'; | ||
|
||
import * as React from 'react'; | ||
|
||
export const TemplateName = 'local-assets'; | ||
|
||
const main = { | ||
backgroundColor: '#f6f9fc', | ||
fontFamily: | ||
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Ubuntu,sans-serif' | ||
}; | ||
|
||
const container = { | ||
backgroundColor: '#ffffff', | ||
margin: '0 auto', | ||
marginBottom: '64px', | ||
padding: '20px 0 48px' | ||
}; | ||
|
||
const box = { | ||
padding: '0 48px' | ||
}; | ||
|
||
const hr = { | ||
borderColor: '#e6ebf1', | ||
margin: '20px 0' | ||
}; | ||
|
||
const paragraph = { | ||
color: '#777', | ||
fontSize: '16px', | ||
lineHeight: '24px', | ||
textAlign: 'left' as const | ||
}; | ||
|
||
const anchor: React.CSSProperties = { | ||
color: '#3869d4', | ||
textDecoration: 'underline' | ||
}; | ||
|
||
const baseUrl = import.meta.env.DEV | ||
? import.meta.resolve('./static/') | ||
: 'https://assets.example.com/'; | ||
|
||
export const Template = () => { | ||
const catUrl = `${baseUrl}cat.jpeg`; | ||
return ( | ||
<Html> | ||
<Head /> | ||
<Preview>This is our email preview text for </Preview> | ||
<Body style={main}> | ||
<Container style={container}> | ||
<Section style={box}> | ||
<Img src={catUrl} alt="Cat" width="200" height="200" /> | ||
<Hr style={hr} /> | ||
<Text style={paragraph}> | ||
URL: | ||
<br /> | ||
<Link style={anchor} href={catUrl}> | ||
{catUrl} | ||
</Link> | ||
</Text> | ||
</Section> | ||
</Container> | ||
</Body> | ||
</Html> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
}, | ||
"dependencies": { | ||
"jsx-email": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.10.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../shared/tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"types": ["./node_modules/jsx-email/node_modules/vite/client", "./node_modules/@types/node"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.