Skip to content

Commit

Permalink
generate negative marging values
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispymm committed Sep 17, 2021
1 parent 318ff04 commit 817e1c8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
27 changes: 21 additions & 6 deletions lib/fluidSpacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ module.exports = function( { addBase, addUtilities, e, theme, options } ) {
let properties = {};
let fallbackProperties = {};
attributes.forEach( (attribute) => {
properties[`${attribute}`] = `var(--fs-${size})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[size]}`;
if( className.startsWith('-') ){
properties[`${attribute}`] = `calc( var(--fs-${size}) * -1)`;
fallbackProperties[`${attribute}`] = `-${fallbackScale[size]}`;
} else {
properties[`${attribute}`] = `var(--fs-${size})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[size]}`;
}
});

result.push( {
Expand All @@ -159,8 +164,13 @@ module.exports = function( { addBase, addUtilities, e, theme, options } ) {
let properties = {};
let fallbackProperties = {};
attributes.forEach( (attribute) => {
properties[`${attribute}`] = `var(--fs-${fromSize}-${toSize})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[fromSize+'-'+toSize]}`;
if( className.startsWith('-') ){
properties[`${attribute}`] = `calc( var(--fs-${fromSize}-${toSize}) * -1)`;
fallbackProperties[`${attribute}`] = `-${fallbackScale[fromSize + '-' + toSize]}`;
} else {
properties[`${attribute}`] = `var(--fs-${fromSize}-${toSize})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[fromSize + '-' + toSize]}`;
}
});

result.push( {
Expand All @@ -175,8 +185,13 @@ module.exports = function( { addBase, addUtilities, e, theme, options } ) {
let properties = {};
let fallbackProperties = {};
attributes.forEach( (attribute) => {
properties[`${attribute}`] = `var(--fs-${fromSize}-${toSize})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[fromSize+'-'+toSize]}`;
if( className.startsWith('-') ){
properties[`${attribute}`] = `calc(var(--fs-${fromSize}-${toSize}) * -1)`;
fallbackProperties[`${attribute}`] = `-${fallbackScale[fromSize + '-' + toSize]}`;
} else {
properties[`${attribute}`] = `var(--fs-${fromSize}-${toSize})`;
fallbackProperties[`${attribute}`] = `${fallbackScale[fromSize + '-' + toSize]}`;
}
});

result.push( {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwind-utopia",
"version": "1.0.3",
"version": "1.0.4",
"description": "A Tailwind CSS plugin to generate utility classes for interpolated fluid type and space scales. ",
"main": "index.js",
"directories": {
Expand Down
7 changes: 7 additions & 0 deletions util/spacingClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module.exports = {
'ml': ['margin-left'],
'mx': ['margin-left', 'margin-right'],
'my': ['margin-top', 'margin-bottom'],
'-m': ['margin'],
'-mt': ['margin-top'],
'-mr': ['margin-right'],
'-mb': ['margin-bottom'],
'-ml': ['margin-left'],
'-mx': ['margin-left', 'margin-right'],
'-my': ['margin-top', 'margin-bottom'],
},
padding: {
'p': ['padding'],
Expand Down

0 comments on commit 817e1c8

Please sign in to comment.