Skip to content

Commit af3f975

Browse files
committed
feat: load tailwind from config
1 parent 7a06555 commit af3f975

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

playground/src/components/Test.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const tokens = await codeToThemedTokens('<div class="foo">bar</div>', {
4343
</EStyle>
4444
</EHead>
4545
<EPreview>{{ previewText }}</EPreview>
46-
<EBody class="bg-white my-auto mx-auto font-sans">
46+
<EBody class="bg-primary my-auto mx-auto font-sans">
4747
<EContainer class="border border-solid border-[#eaeaea] p-[20px] md:p-20 rounded my-[40px] mx-auto max-w-[465px]">
4848
<ESection class="mt-[32px] pager">
4949
<EImg src="/static/vercel-logo.png" width="40" height="37" alt="Vercel" class="my-0 mx-auto" />

playground/src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ const app = createApp(App)
66

77
app.use(VueEmailPlugin, {
88
baseUrl: 'https://vue-email-demo.vercel.app/',
9+
tailwind: {
10+
theme: {
11+
extend: {
12+
colors: {
13+
primary: '#ea580c',
14+
secondary: '#ca8a04',
15+
},
16+
},
17+
},
18+
},
919
})
1020

1121
app.mount('#app')

playground/tailwind.config.js renamed to playground/tailwind.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
export default {
33
content: [],
44
theme: {
5-
extend: {},
5+
extend: {
6+
colors: {
7+
primary: '#ea580c',
8+
secondary: '#ca8a04',
9+
},
10+
},
611
},
712
plugins: [],
813
}

src/components/ETailwind.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as domutils from 'domutils'
66
import render from 'dom-serializer'
77
import type { TailwindConfig } from '@vue-email/tailwind'
88
import { escapeClassName, getCssForMarkup, getStylesPerClassMap, minifyCss, useRgbNonSpacedSyntax } from '@vue-email/tailwind'
9+
import { config } from '../config'
910

1011
export default defineComponent({
1112
name: 'ETailwind',
@@ -23,8 +24,10 @@ export default defineComponent({
2324
let headStyles: string[] = []
2425
const markupWithTailwindClasses = await renderToString(h('div', $default)).then(html => html.replace(/^<div[^>]*>|<\/div>$/g, ''))
2526

27+
const tailwindConfig = props.config || config.tailwind
28+
2629
const markupCSS = useRgbNonSpacedSyntax(
27-
await getCssForMarkup(markupWithTailwindClasses, props.config as TailwindConfig),
30+
await getCssForMarkup(markupWithTailwindClasses, tailwindConfig),
2831
)
2932

3033
const nonMediaQueryCSS = markupCSS.replaceAll(

src/types/compiler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { TailwindConfig } from '@vue-email/tailwind'
2+
13
export interface VueEmailPluginOptions {
24
/**
35
* The base URL of your website.
@@ -14,6 +16,7 @@ export interface VueEmailPluginOptions {
1416
* @see
1517
*/
1618
i18n?: I18n
19+
tailwind?: TailwindConfig
1720
[key: string]: any
1821
}
1922

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy