-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update library to work with Tailwind 1.x
Complete rewrite of the format subclasses. Move to ES6+ BREAKING CHANGE: Works with new tailwind config structure
- Loading branch information
1 parent
46e8de5
commit e005737
Showing
24 changed files
with
17,543 additions
and
11,453 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,8 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules | ||
dist |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,26 +1,20 @@ | ||
const reduce = require('lodash.reduce') | ||
const Converter = require('./Converter.js') | ||
import Converter from './Converter.js' | ||
|
||
class LessConverter extends Converter { | ||
_convertObjectToVar (property, data) { | ||
return reduce(data, (all, value, metric) => { | ||
all += `@${this._propertyNameSanitizer(property, metric)}: ${this._sanitizePropValue(value)};\n` | ||
return all | ||
}, '') | ||
format = 'less' | ||
|
||
_buildVar (name, value) { | ||
return `@${name}: ${value};\n` | ||
} | ||
|
||
_convertObjectToMap (prop, data) { | ||
return this._convertObjectToVar(prop, data) | ||
} | ||
|
||
getFormat () { | ||
return 'less' | ||
} | ||
|
||
_sanitizePropValue (value) { | ||
if (Array.isArray(value)) return value.join(', ') | ||
return value | ||
} | ||
} | ||
|
||
module.exports = LessConverter | ||
export default LessConverter |
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 |
---|---|---|
@@ -1,28 +1,19 @@ | ||
const reduce = require('lodash.reduce') | ||
const foreach = require('lodash.foreach') | ||
|
||
const Converter = require('./Converter') | ||
import Converter from './Converter' | ||
import { indentWith } from './utils' | ||
|
||
class SassConverter extends Converter { | ||
_convertObjectToMap (property, data) { | ||
let buffer = '(\n' | ||
foreach(data, (value, metric) => { | ||
buffer += ` ${metric}: ${this._sanitizePropValue(value)},\n` | ||
}) | ||
buffer += ')' | ||
return `$${this._propertyNameSanitizer(property)}: ${buffer}` | ||
} | ||
format = 'sass' | ||
|
||
mapOpener = '(' | ||
mapCloser = ')' | ||
|
||
_convertObjectToVar (property, data) { | ||
return reduce(data, (all, value, metric) => { | ||
all += `$${this._propertyNameSanitizer(property, metric)}: ${this._sanitizePropValue(value)}\n` | ||
return all | ||
}, '') | ||
_buildVar (name, value) { | ||
return `$${name}: ${value}\n` | ||
} | ||
|
||
getFormat () { | ||
return 'sass' | ||
_buildObjectEntry (key, value, indent, index, metricIndex = 0) { | ||
return indentWith(`${key}: ${this._sanitizePropValue(value)},`, indent + ((!index && !metricIndex) ? 0 : 1)) | ||
} | ||
} | ||
|
||
module.exports = SassConverter | ||
export default SassConverter |
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 |
---|---|---|
@@ -1,31 +1,17 @@ | ||
const reduce = require('lodash.reduce') | ||
const foreach = require('lodash.foreach') | ||
|
||
const Converter = require('./Converter') | ||
import Converter from './Converter' | ||
|
||
/** | ||
* @extends Converter | ||
*/ | ||
class ScssConverter extends Converter { | ||
_convertObjectToMap (property, data) { | ||
let buffer = '(\n' | ||
foreach(data, (value, metric) => { | ||
buffer += ` ${metric}: ${this._sanitizePropValue(value)},\n` | ||
}) | ||
buffer += ')' | ||
return `$${this._propertyNameSanitizer(property)}: ${buffer};` | ||
} | ||
format = 'scss' | ||
|
||
_convertObjectToVar (prop, data) { | ||
return reduce(data, (all, value, metric) => { | ||
all += `$${this._propertyNameSanitizer(prop, metric)}: ${this._sanitizePropValue(value)};\n` | ||
return all | ||
}, '') | ||
} | ||
mapOpener = '(\n' | ||
mapCloser = ')' | ||
|
||
getFormat () { | ||
return 'scss' | ||
_buildVar (name, value) { | ||
return `$${name}: ${value};\n` | ||
} | ||
} | ||
|
||
module.exports = ScssConverter | ||
export default ScssConverter |
Oops, something went wrong.