0.3.7 • Published 3 months ago

tailwindinline v0.3.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Why?

I use this library to build a document that looks like the PDF I'd like with tailwind, use the frontend framework I'm using at the moment to insert data and/or graphs (that render to svg, I recommend apache echarts for this rendering functionality) and then output pure HTML from whatever format the framework uses (in react this is accomplished with ReactDOMServer.renderToString(component)), convert it to inline styled html with this package, and then send the pure html file to a html-to-pdf api like api2pdf (which while unaffiliated seems relatively cheap).

It enables you to at runtime convert from a html string with tailwind classes to a html string inline styled. I find this easier than supplying the PDF API with two files since I haven't found the most reliable pdf generation APIs.

Questions/comments/improvements/suggestions? Contributions welcome.

npm install tailwindinline

import convert from 'tailwindinline'
const htmlWithInlineStyles = convert('<div class="pt-2 pb-[40px] border-2 border-[#0f0]"></div>')
/*
<div 
	class="pt-2 pb-[40px] border-2 border-[#0f0]" 
	style="padding-top: 0.5rem; padding-bottom: 40px; border-width: 2px; border-color: #0f0; box-sizing: border-box;"
></div>

Tailwindinline

(Tries to) append a style attribute with computed tailwind classes to the end of each html tag that contained them.

Planned additions

  • remove unneeded styles from classList.json (hover, focus)
  • fix syntax of some classnames in classList.json (ex: placeholder:moz-...)
  • custom tailwind classes
  • add all tailwind auto-added classes (those that makes sense for this usage)
  • import and use a custom tailwindconfig
  • implement more consistent regex file
0.3.0

3 months ago

0.3.6

3 months ago

0.3.5

3 months ago

0.3.7

3 months ago

0.3.2

3 months ago

0.3.1

3 months ago

0.3.4

3 months ago

0.3.3

3 months ago

0.2.3

4 months ago

0.1.71

4 months ago

0.2.1

4 months ago

0.2.0

4 months ago

0.1.7

4 months ago

0.2.2

4 months ago

0.1.6

4 months ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago