Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-elm-tailwind

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-elm-tailwind - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.github/workflows/nodejs.yml

88

index.js
const fs = require("fs");
let postcss = require("postcss");
function fixClass(cls) {
var oldCls = cls;
cls = cls.replace(
/\:(responsive|group-hover|focus-within|first|last|odd|even|hover|focus|active|visited|disabled)$/,
""
); // remove extras at end
cls = cls.replace(/\::(placeholder)$/, ""); // remove extras at end
cls = cls.replace(/\\([/])/g, "\\\\$1"); // make \/ safe for elm
cls = cls.replace(/\\([:])/g, "$1"); // make \: safe for elm
cls = cls.replace(
/^(responsive|group-hover|focus-within|first|last|odd|even|hover|focus|active|visited|disabled)\\\\:/,
"$1:"
);
return cls;
}
let h = require("./helpers.js");
function elmFunction(cls, elm) {
return `
{-|Tailwind class:
${cls}"
-}
${elm} : Html.Attribute msg
${elm} =
A.class "${cls}"
`;
}
function elmBody(classes) {
let body = "";
for (var fn of classes.values()) {
body = body + fn;
}
return body;
}
function elmHeader(elm_fns) {
const s = new Set(elm_fns);
const l = Array.from(s.values()).join("\n , ");
const d = Array.from(s.values()).join(", ");
return `module TW exposing
( ${l}
)
{-| This library exports helper utilities - one for each tailwindcss class.
# Example
Html.div [TW.container, TW.mx_auto] []
will result in a centred container.
@docs ${d}
-}
import Html
import Html.Attributes as A
`;
}
let classes = new Map();

@@ -71,5 +11,10 @@ let elm_fns = new Array();

"postcss-elm-tailwind",
(opts = { elmFile }) => {
(opts = { elmFile, prefix }) => {
// Work with options here
opts.elmFile = "src/TW.elm";
if (!opts.elmFile) {
opts.elmFile = "src/TW.elm";
}
if (!opts.prefix) {
opts.prefix = "";
}

@@ -86,19 +31,10 @@ return (root, result) => {

// remove the dot
cls = cls.replace(/^(\.)/, "");
// keep only up to a comma or a space
cls = fixClass(cls);
cls = h.fixClass(cls);
elm = h.toElmName(cls, opts.prefix);
var elm = cls.split("\\\\:").join("_");
elm = elm.replace(/^-/, "neg_");
elm = elm.replace(/-/g, "_");
elm = elm.replace(/:/g, "_");
elm = elm.replace(/\\\\\//g, "over");
elm = elm.replace(/\\__/, "_");
classes.set(cls, elmFunction(cls, elm));
classes.set(cls, h.elmFunction(cls, elm));
elm_fns.push(elm);
});
const elmModule = elmHeader(elm_fns) + elmBody(classes);
const elmModule = h.elmHeader(elm_fns) + h.elmBody(classes);

@@ -105,0 +41,0 @@ // writing to disk

{
"name": "postcss-elm-tailwind",
"version": "0.1.0",
"version": "0.2.0",
"description": "PostCSS plugin Tailwind classes for Elm",

@@ -13,3 +13,4 @@ "keywords": [

"scripts": {
"build-elm-package": "postcss default.css > /dev/null"
"build-elm-package": "postcss default.css > /dev/null",
"test": "mocha"
},

@@ -19,6 +20,7 @@ "author": "Dean Montgomery",

"repository": "monty5811/postcss-elm-tailwind",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"elm": "^0.19.1-2",
"jest": "^24.9.0",
"mocha": "^6.2.2",
"postcss-cli": "^6.1.3",

@@ -25,0 +27,0 @@ "tailwindcss": "^1.1.2"

@@ -73,6 +73,6 @@ # Elm Tailwind

In order to get a small build, you'll need to build Tailwind twice - once
1. If you have set a `prefix` in your tailwind config, you must tell
`postcss-elm-tailwind` what it is too in your `postcss.config.js`. [demo](https://github.com/monty5811/postcss-elm-tailwind/blob/master/demo/postcss.config.js#L15).
2. In order to get a small build, you'll need to build Tailwind twice - once
without purgecss to build `TW.elm` with all the classes and once with purgecss
so that all the unused classes are removed.
The [demo does this](https://github.com/monty5811/postcss-elm-tailwind/blob/master/demo/package.json#L18).
so that all the unused classes are removed. [demo](https://github.com/monty5811/postcss-elm-tailwind/blob/master/demo/package.json#L18).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc