postcss-ghost-utils is a PostCSS plugin.
This plugin can give you useful css syntax. It is NOT include old css technique (ex. clearfix).
$ npm install -D postcss postcss-ghost-utils
# or
$ yarn add -D postcss postcss-ghost-utils
.postcss.config.js
module.exports = {
plugins: [
require('postcss-ghost-utils')
]
}
Input | Output |
.one {
@ghost font-size-line-height(16px, 2px);
} |
.one {
font-size: 16px;
line-height: calc(16px + 2px * 2);
} |
Input | Output |
.one {
@ghost new-line;
} |
.one {
white-space: pre-wrap;
word-wrap: break-word;
} |
Input | Output |
.one {
@ghost truncate;
}
.two {
@ghost truncate('-');
} |
.one {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.two {
white-space: nowrap;
overflow: hidden;
text-overflow: '-';
} |
Input | Output |
.one {
@ghost margin-left-right(16px);
} |
.one {
margin-left: 16px;
margin-right: 16px;
} |
Input | Output |
.one {
@ghost margin-top-bottom(16px);
} |
.one {
margin-top: 16px;
margin-bottom: 16px;
} |
Input | Output |
.one {
@ghost padding-left-right(16px);
} |
.one {
padding-left: 16px;
padding-right: 16px;
} |
Input | Output |
.one {
@ghost padding-top-bottom(16px);
} |
.one {
padding-top: 16px;
padding-bottom: 16px;
} |
Input | Output |
.one {
@ghost border-left-right(2px solid black);
} |
.one {
border-left: 2px solid black;
border-right: 2px solid black;
} |
Input | Output |
.one {
@ghost border-top-bottom(2px solid black);
} |
.one {
border-top: 2px solid black;
border-bottom: 2px solid black;
} |
Input | Output |
.one {
@ghost border-top-radius(4px);
}
.two {
@ghost border-top-radius(4px 2px);
} |
.one {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.two {
border-top-left-radius: 4px 2px;
border-top-right-radius: 4px 2px;
} |
Input | Output |
.one {
@ghost border-bottom-radius(4px);
}
.two {
@ghost border-bottom-radius(4px 2px);
} |
.one {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.two {
border-bottom-left-radius: 4px 2px;
border-bottom-right-radius: 4px 2px;
} |
Input | Output |
.one {
@ghost border-left-radius(4px);
}
.two {
@ghost border-left-radius(4px 2px);
} |
.one {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.two {
border-top-left-radius: 4px 2px;
border-bottom-left-radius: 4px 2px;
} |
Input | Output |
.one {
@ghost border-right-radius(4px);
}
.two {
@ghost border-right-radius(4px 2px);
} |
.one {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.two {
border-top-right-radius: 4px 2px;
border-bottom-right-radius: 4px 2px;
} |
Input | Output |
.one {
@ghost size(160px);
}
.two {
@ghost size(160px, 240px);
} |
.one {
width: 160px;
height: 160px;
}
.two {
width: 160px;
height: 240px;
} |
Input | Output |
.one {
@ghost circle(200px);
background-color: #ff0000;
border: 10px solid #ffffff;
} |
.one {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #ff0000;
border: 10px solid #ffffff;
} |
Input | Output |
.one {
@ghost transition(100ms, ease-in, color);
}
.two {
@ghost transition(100ms, ease-in, color, background-color, border-color);
} |
.one {
transition: 100ms ease-in color;
}
.two {
transition: 100ms ease-in color, 100ms ease-in background-color, 100ms ease-in border-color;
} |
The following rules may not work with not pure css ex) LESS, SASS.
Input | Output |
@ghost all-buttons {
background-color: transparent;
border: none;
cursor: pointer;
outline: 0;
}
@ghost all-buttons(hover) {
transform: translateY(-2px);
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
@ghost all-buttons(active) {
transform: none;
box-shadow: none;
}
@ghost all-buttons(focus) {
transform: translateY(-2px);
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
} |
button, [type='button'], [type='reset'], [type='submit'] {
background-color: transparent;
border: none;
cursor: pointer;
outline: 0;
}
button:hover, [type='button']:hover, [type='reset']:hover, [type='submit']:hover {
transform: translateY(-2px);
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button:active, [type='button']:active, [type='reset']:active, [type='submit']:active {
transform: none;
box-shadow: none;
}
button:focus, [type='button']:focus, [type='reset']:focus, [type='submit']:focus {
transform: translateY(-2px);
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
} |