Skip to content

Commit 1ab02f3

Browse files
authored
Merge pull request #6 from maizzle/2.0
feat: support tailwindcss 3.1.x
2 parents a2998ea + a0a4f5f commit 1ab02f3

File tree

5 files changed

+18
-118
lines changed

5 files changed

+18
-118
lines changed

README.md

-51
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,6 @@ Result:
115115
}
116116
```
117117

118-
### Outlook (webmail)
119-
120-
Use the `outlook-web` variant to target iOS Mail 15 specifically:
121-
122-
```html
123-
<div class="outlook-web:hidden">...</div>
124-
```
125-
126-
Result:
127-
128-
```css
129-
[class~="x_outlook-web\:hidden"] {
130-
display: none;
131-
}
132-
```
133-
134118
### Outlook.com dark mode
135119

136120
Change `color` and `background-color` of elements in [Outlook.com dark mode](https://www.hteumeuleu.com/2021/emails-react-outlook-com-dark-mode/).
@@ -172,38 +156,3 @@ Result:
172156
display: none;
173157
}
174158
```
175-
176-
## Configuration
177-
178-
You can add your own variants by passing a configuration object to the plugin.
179-
180-
```js
181-
// tailwind.config.js
182-
module.exports = {
183-
plugins: [
184-
require('tailwindcss-email-variants')({
185-
thunderbird: '.moz-text-html &', // & is the utility class
186-
example: ctx => `.example ${ctx.container.nodes[0].selector}` // using a function
187-
}),
188-
// ...
189-
],
190-
}
191-
```
192-
193-
Use it:
194-
195-
```html
196-
<div class="thunderbird:hidden example:flex">...</div>
197-
```
198-
199-
Result:
200-
201-
```css
202-
.moz-text-html .thunderbird\:hidden {
203-
display: none;
204-
}
205-
206-
.example .flex {
207-
display: flex;
208-
}
209-
```

package-lock.json

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"np": "^7.6.1",
2121
"postcss": "^8.2.2",
2222
"prettier": "^2.5.1",
23-
"tailwindcss": "^3.0.24"
23+
"tailwindcss": "^3.1.3"
2424
},
2525
"peerDependencies": {
26-
"tailwindcss": ">=3.0.0"
26+
"tailwindcss": ">=3.1.0"
2727
},
2828
"prettier": {
2929
"printWidth": 100,

src/index.js

-11
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,8 @@ const emailClientVariants = plugin.withOptions(
2525
// iOS Mail 15+
2626
addVariant('ios-15', '@supports (-webkit-overflow-scrolling:touch) and (aspect-ratio: 1 / 1)')
2727

28-
// Outlook (webmail)
29-
addVariant('outlook-web', ctx => {
30-
const foo = get(ctx.container.nodes[0], 'raws.tailwind.classCandidate', '&')
31-
return `[class~="x_outlook-web\\:${foo}"]`
32-
})
33-
3428
// Open-Xchange (multiple clients)
3529
addVariant('ox', '&[class^="ox-"]')
36-
37-
// User-defined variants
38-
Object.keys(userVariants).forEach(key => {
39-
addVariant(key, userVariants[key])
40-
})
4130
}
4231
}
4332
)

src/index.test.js

-38
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,6 @@ it('`ios-15` variant', () => {
111111
})
112112
})
113113

114-
it('`outlook-web` variant', () => {
115-
const config = {
116-
content: [{ raw: String.raw`<div class="outlook-web:hidden"></div>` }]
117-
}
118-
119-
return run(config).then((result) => {
120-
expect(result.css).toMatchCss(String.raw`
121-
[class~="x_outlook-web\:hidden"] {
122-
display: none;
123-
}
124-
`)
125-
})
126-
})
127-
128114
it('`apple-mail` variant', () => {
129115
const config = {
130116
content: [{ raw: String.raw`<div class="apple-mail:hidden"></div>` }]
@@ -152,27 +138,3 @@ it('`ox` variant', () => {
152138
`)
153139
})
154140
})
155-
156-
it('user-defined variants', () => {
157-
const config = {
158-
content: [{ raw: String.raw`<div class="thunderbird:hidden example:hidden"></div>` }],
159-
plugins: [
160-
etvPlugin({
161-
thunderbird: '.moz-text-html &',
162-
example: ctx => `.example ${ctx.container.nodes[0].selector}`
163-
})
164-
],
165-
}
166-
167-
return run(config).then((result) => {
168-
expect(result.css).toMatchCss(String.raw`
169-
.moz-text-html .thunderbird\:hidden {
170-
display: none;
171-
}
172-
173-
.example .hidden {
174-
display: none;
175-
}
176-
`)
177-
})
178-
})

0 commit comments

Comments
 (0)